yangtools.git
5 weeks agoRelease yangtools v10.0.13
jenkins-releng [Wed, 24 Apr 2024 10:51:32 +0000 (10:51 +0000)]
Release yangtools

5 weeks agoBump odlparent to 12.0.11 05/111505/2
Robert Varga [Wed, 24 Apr 2024 09:22:18 +0000 (11:22 +0200)]
Bump odlparent to 12.0.11

Pick up upgrades from upstream. Also fixup javadoc configuration, so
that extensions actually pass.

Change-Id: I387a74b82f85f42ae7b4e1c5cc35a5ed877be1ee
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 weeks agoDefeat potential singleton pollution attacks 49/111349/2
Robert Varga [Wed, 10 Apr 2024 13:50:16 +0000 (15:50 +0200)]
Defeat potential singleton pollution attacks

yang.common.Empty is a Serializable, which has no state beside its class
hierarchy. It therefore lends itself to having a singleton value object
-- except SpotBugs flags this as a violation MSC07-J rule in SEI CERT
Oracle Coding Standard for Java.

Digging into this, the readResolve() guard could be defeated via
hand-crafted serialization -- and thus could in theory have more than
once instance. Doing so would allow to have two Empty instances which
have the same Class, but do not compare as equal.

This patch erases that possibility, fixing a possibility of the error.

Also update documentation a bit to remove the word 'singleton', so users
are not tempted to use '==' for comparison -- which is already a bad
idea anyway.

Change-Id: Ibccd2909790e7a46d002d80f7b36280ff27fb724
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 5d2a3a0e46e802de92e96b2e28bc29a7ae43a2b0)
(cherry picked from commit b9118b432bc59a86c101cb428eae494e69647731)

2 months agoAdd JSONCodec.parseValue(String) 03/111203/1
Robert Varga [Mon, 1 Apr 2024 18:12:36 +0000 (20:12 +0200)]
Add JSONCodec.parseValue(String)

JSONCodec's parsing does not have a document context, add convenience
a convenience method.

JIRA: YANGTOOLS-1567
Change-Id: Iae1329be54bcb2f9249d0a159b4aa316be2e8d3d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit cb951e4f37815b4c71824a8f52f3629ec61858f3)
(cherry picked from commit 6b8d443df940608b9166fd740383be2e75ef6aaa)

2 months agoUse JsonWriter.nullValue() 02/111202/1
Robert Varga [Tue, 2 Apr 2024 08:29:14 +0000 (10:29 +0200)]
Use JsonWriter.nullValue()

We are passing a null String, which ends up calling to nullValue().
Short-circuit this.

Change-Id: I75423bee13cb2d73ef1b817b975a9cb155721c02
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit c42dafd31ad302197718b5fde00914adbdd13fb5)
(cherry picked from commit 871844d401e90434c0ce39ee15169a0883bf9a58)

2 months agoWriteout primitive boolean 01/111201/1
Robert Varga [Tue, 2 Apr 2024 08:21:13 +0000 (10:21 +0200)]
Writeout primitive boolean

We know the value is non-null, hence we can short-circuit to
JsonWriter.value(boolean).

Change-Id: I9340c2ebd8adfe34323e13f35a74ae78d24c2ce2
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit e6cef6ee0a9561b60924a09aac0e9d4038635c13)
(cherry picked from commit c82482008b700301878a1fcac07a23b75889d0c2)

4 months agoMake Empty hashcode deterministic 06/110106/1
Robert Varga [Wed, 31 Jan 2024 08:57:36 +0000 (09:57 +0100)]
Make Empty hashcode deterministic

All our YANG value types have a deterministic hash code, except Empty.
Fix that by assigning a hard-coded value.

Change-Id: I35d5b7a8d3bf653a2e85fc5e8fcbfe6baadc06b7
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit bd3f43b357bc9e1226501a283c2071f8ff5074c0)

4 months agoAdd Empty.{completed,immediate}Future() 05/110105/1
Robert Varga [Tue, 30 Jan 2024 01:13:27 +0000 (02:13 +0100)]
Add Empty.{completed,immediate}Future()

A number of downstream users are using Empty as a result of a future
which should only report empty success without relying on
java.lang.Void.

Since we are not playing favorites, let's expose two versions in keeping
with Java/Guava naming conventions:
- completedFuture() is the CompletionStage
- immediateFuture() is the ListenableFuture

JIRA: YANGTOOLS-1566
Change-Id: I5897ef561f562440e5d81fa7b0711e139dc6d6ee
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit d17a3554514d8a3439e60c2a7eda88ef712dbeac)

4 months agoFix Javadoc 21 violations 97/109797/1
Robert Varga [Fri, 12 Jan 2024 00:53:49 +0000 (01:53 +0100)]
Fix Javadoc 21 violations

Java 21 seems to have a more aggresive warning set, make sure these do
not crop up where we enforce javadoc.

Change-Id: Iae3e82a11848aeb404a4058ad4cc43d8c47225f3
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit a0b86779b2ef21b35d2bbc1f6b956548a94ba1f3)
(cherry picked from commit c9370eadfcbb3d2b6c18b1367e648ab257266a6d)

6 months agoAdd Inference.of() 32/109132/1
Robert Varga [Thu, 30 Nov 2023 19:15:53 +0000 (20:15 +0100)]
Add Inference.of()

Improve documentation and a shortcut method to create an empty
Inference.

Change-Id: I431042cb04fd7812733a8f9b72480d3761695aa5
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 4a6f52974c9f6c32461bf5596705de4a2ecd2a43)

6 months agoImprove SchemaInferenceStack javadocs 31/109131/1
Robert Varga [Mon, 6 Mar 2023 14:06:04 +0000 (15:06 +0100)]
Improve SchemaInferenceStack javadocs

Use {@code blocks} to highlight null/true/false. Also fix a tiny typo.

Change-Id: I531de055f437c0633bc7353c6d023a797f386323
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 73945d1ae208fbaac992b593ed964cef5cf7614c)

6 months agoImprove ListEntryNodeDataWithSchema error reporting 21/109121/2
Robert Varga [Tue, 28 Nov 2023 23:49:13 +0000 (00:49 +0100)]
Improve ListEntryNodeDataWithSchema error reporting

When we encounter a keyed list entry which does not have all keys
specified we should report which keys are missing through an
IOException.

JIRA: YANGTOOLS-1550
Change-Id: I40a7c04970b244c893f4541469efe7e562b49e71
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 2e968f918f6604ca1f870a7c87f0542c739cec87)

6 months agoImprove OffsetMapTemplate error reporting 20/109120/1
Robert Varga [Tue, 28 Nov 2023 22:36:32 +0000 (23:36 +0100)]
Improve OffsetMapTemplate error reporting

Include a human-readable message when we throw an IAE.

JIRA: YANGTOOLS-1550
Change-Id: I7acb3e9b23ed20a00551435ce68c68d138a052e6
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 4cf1abaf27f887d580ee3e5a263a263f055f63d0)

7 months agoUpdate XmlToNormalizedNodesTest 39/108739/1
Robert Varga [Mon, 30 Oct 2023 09:32:50 +0000 (10:32 +0100)]
Update XmlToNormalizedNodesTest

Spell out the two YANG files used in the test.

Change-Id: Ic7fa9d591afd5985adc647dad2656a5ce2a4d9df
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 8ffdededfd03af7351389e8b1b355a7c7b62fe09)

7 months agoBump versions to 10.0.13-SNAPSHOT 41/108641/1
Robert Varga [Tue, 24 Oct 2023 17:39:26 +0000 (19:39 +0200)]
Bump versions to 10.0.13-SNAPSHOT

This starts the next development iteration.

Change-Id: If36c4f0e1efcb7be9b5d61ea768594c054ba758b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoRelease yangtools v10.0.12
jenkins-releng [Tue, 24 Oct 2023 14:23:34 +0000 (14:23 +0000)]
Release yangtools

7 months agoBump odlparent to 12.0.10 22/108622/1
Robert Varga [Tue, 24 Oct 2023 13:05:22 +0000 (15:05 +0200)]
Bump odlparent to 12.0.10

Pick up updates from upstream.

Change-Id: I989898bf45369b0f6cfceb8876ce556d0b61292b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoBump versions to 10.0.12-SNAPSHOT 86/108586/1
Robert Varga [Sat, 21 Oct 2023 05:02:56 +0000 (07:02 +0200)]
Bump versions to 10.0.12-SNAPSHOT

This starts the next development iteration.

Change-Id: I00124e57bb32b27b0da5f2e3a5f08ec739c54f2d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoRelease yangtools v10.0.11
jenkins-releng [Fri, 20 Oct 2023 16:54:21 +0000 (16:54 +0000)]
Release yangtools

7 months agoBump odlparent to 12.0.9 66/108566/1
Robert Varga [Fri, 20 Oct 2023 15:58:19 +0000 (17:58 +0200)]
Bump odlparent to 12.0.9

Adopt fixes from upstream.

Change-Id: I53e46908ba2112e89c31d6e2ff011ce16f60701b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoDo not create effective copy for unsupported statements 91/108491/1
Sangwook Ha [Thu, 10 Aug 2023 23:15:25 +0000 (16:15 -0700)]
Do not create effective copy for unsupported statements

If we are encountering a statement which is not supported, we should not
create an effective copy of it for the purposes of comparison.

JIRA: YANGTOOLS-1532
Change-Id: I4407e38f2a62c911b653191bf7c6cfd82ba0225e
Signed-off-by: Sangwook Ha <sangwook.ha@verizon.com>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 10442e262ee9ef3452f8fa4112e47e2c8d7306c7)
(cherry picked from commit 041a3ae205f0388f5f0df15bbedb27a4aa627cce)

7 months agoBump versions to 10.0.11-SNAPSHOT 86/108286/1
Robert Varga [Mon, 9 Oct 2023 10:11:48 +0000 (12:11 +0200)]
Bump versions to 10.0.11-SNAPSHOT

This starts the next development iteration.

Change-Id: I146b3c259c6d473c1e0d387d61eaa653dce97a95
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoRelease yangtools v10.0.10
jenkins-releng [Mon, 9 Oct 2023 08:46:08 +0000 (08:46 +0000)]
Release yangtools

7 months agoCheck rc:yang-data template name duplications 60/108260/1
Robert Varga [Thu, 5 Oct 2023 16:54:16 +0000 (18:54 +0200)]
Check rc:yang-data template name duplications

yang-data template names have a global scope, similar to schema tree
namespace. Enforce non-overlap of template names in a particular
reactor.

JIRA: YANGTOOLS-1482
Change-Id: I2da9188d5a95baa591b8ceef585a3e84fa18f531
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 961ab82940317c2d5b538aea9cb4d6bf02c1b072)

7 months agoMigrate yang-model-export to xmlunit-core 06/108206/1
Robert Varga [Fri, 29 Sep 2023 17:09:49 +0000 (19:09 +0200)]
Migrate yang-model-export to xmlunit-core

Migrate legacy comparison, fixing up expected data, as we maintain the
proper order.

Change-Id: I0e243cd7ba4f95e7bd36b23a0fcd7592d08dfce7
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit da3d0e7dcd123a710f37241dd2a3e59e9ac4ced7)

7 months agoBump odlparent to 12.0.8 89/108189/2
Robert Varga [Tue, 3 Oct 2023 13:26:51 +0000 (15:26 +0200)]
Bump odlparent to 12.0.8

Pick up latest upgrades from upstream.

Change-Id: If9a284438be4965feb6be701b49cbf41fa038102
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoFixup checkstyle in yang-repo-spi 04/108204/1
Robert Varga [Wed, 30 Aug 2023 11:38:44 +0000 (13:38 +0200)]
Fixup checkstyle in yang-repo-spi

Upgraded checkstyle is finding some violations, clean them up.

Change-Id: Iebc51805be902b15cc40e88c43e5c346e8936b6a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 7414266f72092cb017df815eeca87f26c7aea432)

8 months agoMake model prefix handling optional 06/108106/1
Robert Varga [Sat, 30 Sep 2023 00:22:32 +0000 (02:22 +0200)]
Make model prefix handling optional

Taking model-based prefixes into account is bound to change our output,
making the encoding a tad more dense. Make the feature selectable by
users as a first step, with an eye towards making it the default.

JIRA: YANGTOOLS-1544
Change-Id: Icedf67b408182e57a99d5d1f52f728c3f64c8657
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 9d64ed881c503da6edea8b14d9ecd763a586b4c3)

8 months agoClean up NamespacePrefixesTest 05/108105/1
Robert Varga [Sun, 1 Oct 2023 14:51:12 +0000 (16:51 +0200)]
Clean up NamespacePrefixesTest

Now that we have moved decode(), we can specialize it to asserts,
cleaning things up a bit.

Change-Id: I073fde327587bcc78619b2c227f01a5f24057d40
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 9c84c22a4d712c9925b584a60fabea0fb172ee57)

8 months agoRemove references to TestCase 04/108104/1
Robert Varga [Fri, 29 Sep 2023 19:00:37 +0000 (21:00 +0200)]
Remove references to TestCase

All we are doing is subclassing and routing to XMLAssert. Just route a
static call.

Change-Id: I786cef83dea43af0d10fab72da202a0989099acb
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 248767ccb030bd71494eb4251d7a792d4460b23e)

8 months agoEnforce mocking in yang-data-codec-xml tests 03/108103/1
Robert Varga [Thu, 28 Sep 2023 19:22:18 +0000 (21:22 +0200)]
Enforce mocking in yang-data-codec-xml tests

Pull in our mockito-configuration, so that we correctly mock all
interactions.

Change-Id: I065b44f7fc62a052475892738a310e7894962da6
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 8081f3f15e1c5c91d18c0de54efc17ee3612ec50)

8 months agoUse YANG-derived prefixes 53/108053/6
Robert Varga [Thu, 28 Sep 2023 20:33:47 +0000 (22:33 +0200)]
Use YANG-derived prefixes

All XML examples starting from RFC6020 onwards use a module's prefix to
identify the module.

This is not something that is universally feasible to do, as the
document context may indicate a different namespace mapping, which may
be more efficient to use.

Such assignments may also conflict with already-assigned prefixes and
redefining XML namespaces increases cognitive load in analysis -- hence
we have to avoid that.

Also prefix assignments are not a global namespace, so we could easily
end up with ambigous mappings. This is unlikely, but it can easily
happen.

With an EffectiveModelContext we can perform analysis on what is valid
within that enclosed world and use that as a guide. When
NamespacePrefixes decides current RandomPrefix (which is not random at
all!) does not have a mapping, we can consult an analysis object to give
us guidance.

This patch renames RandomPrefix to 'NamespacePrefixes' and introduces
PreferredPrefixes, which can be computed from an EffectiveModelContext.

These two then act in unison to assign prefixes based on prefix
statements present in modules forming an EffectiveModelContext whenever
we need to do such a thing.

JIRA: YANGTOOLS-1544
Change-Id: Iafc5806f53d8927e46f059287e2ae3ed2c77ff26
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 316df6dff3f5d3126840db3b732a0797fbd3d35a)

8 months agoClean up XML instance identifier class naming 52/108052/6
Robert Varga [Thu, 28 Sep 2023 17:39:39 +0000 (19:39 +0200)]
Clean up XML instance identifier class naming

Naming of things here is not great. We have two distinct implementations
of a full Codec, one of which can handle serialization and the other can
handle parsing.

Clean up naming, by having a top-level, fixed,
InstanceIdentifierXmlCodec, which is what we give users. We then have
InstanceIdentifier{Deserializer,Serializer}, which are bound, single-use
delegates.

This allows us to ditch the thread local stack we have been keeping to
deal with the fact that the implementation is directly internal.

Furthermore we optimize instantiation, so that we minimize the number of
calls to DataSchemaContextTree.from().

JIRA: YANGTOOLS-1543
Change-Id: I1ca884fe57086311111f12b3ba223d08f3676a93
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 99715f7b5483c08f7fe4ec9232281ea04a3941b2)

8 months agoFix XML instance identifier encoding 51/108051/6
Robert Varga [Thu, 28 Sep 2023 15:19:05 +0000 (17:19 +0200)]
Fix XML instance identifier encoding

XmlStringInstanceIdentifierCodec is not encoding prefixes properly. Use
the same trick we use for normal writeout.

Also improve mocking to cover all interactions we expect to happen.

JIRA: YANGTOOLS-1543
Change-Id: Ie018137599bd5a79db962da9573cbbca6bfc0599
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 9eb8ac2c8481d48e9eac7f39be3b7b89a4629e8f)

8 months agoImprove YT1473Test stubbing 46/108046/6
Robert Varga [Thu, 28 Sep 2023 16:55:28 +0000 (18:55 +0200)]
Improve YT1473Test stubbing

Execute this test with MockitoExtension, which automatically verifies
all subbings. Refactor assertions accordingly.

JIRA: YANGTOOLS-1543
Change-Id: I099611b575f6a0775600c03e5f3edca41ff0bdd5
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 4703e9b77dd0d52ce0e7019f718d42f52eed3bb5)

8 months agoDo not pass null to codec 47/108047/5
Robert Varga [Thu, 28 Sep 2023 17:06:20 +0000 (19:06 +0200)]
Do not pass null to codec

We are expecting a checked exception and are passing a null argument for
something which we are supposed to interact with. Use a proper mock for
argument. This will allow us to further extend verification should the
implementation change.

JIRA: YANGTOOLS-1543
Change-Id: I0f1defd442ae60ee9e9b1b7a43949eed320ac148
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 3462009a37acbe180611e93f8c479bb6fcf62e8a)

8 months agoImprove context reporting 83/108083/1
Robert Varga [Fri, 22 Sep 2023 23:56:17 +0000 (01:56 +0200)]
Improve context reporting

If we fail at first step, we end up emitting an empty string, which
makes the output not nice. Quote the emitted string.

Change-Id: Ic54f7fd69a902de03205355b37fdc72d9979c051
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit ac5a7ba138a2a091f395a2df7b9316c4ebf86e03)

8 months agoMigrate RandomPrefixTest to JUnit5 50/108050/5
Robert Varga [Thu, 28 Sep 2023 19:45:46 +0000 (21:45 +0200)]
Migrate RandomPrefixTest to JUnit5

Hide the test and clean it up.

Change-Id: I7c5ddc6d04e40e42967089ccea9777347a4daa30
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit f8cd76e304a92b75d50171a12817bc3ad4e8e210)

8 months agoClean up XmlStringInstanceIdentifierCodec instantiation 48/108048/5
Robert Varga [Thu, 28 Sep 2023 17:21:32 +0000 (19:21 +0200)]
Clean up XmlStringInstanceIdentifierCodec instantiation

We are inherently tied to the model context of our XmlCodecFactory.
Simplify the constructor and do not store the EffectiveModelContext.

Change-Id: I7676813295275926642018665908f11ec47f402b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 14e932f10fd660f7faca0053a94b4c3d29b86653)

8 months agoModernize SchemaAwareXMLStreamWriterUtils a bit 45/108045/4
Robert Varga [Thu, 28 Sep 2023 16:02:36 +0000 (18:02 +0200)]
Modernize SchemaAwareXMLStreamWriterUtils a bit

Do not implemented EffectiveModelContextProvider to improve visibility
into invocations. Also use local variable type inference for brevity.

Change-Id: I3141562b0050435ed79f9bd06aa2dac03e59ec08
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit ca4f2e05e9916b6843889ccf860a1a531960e22b)

8 months agoSimplify SchemaAwareXMLStreamNormalizedNodeStreamWriter 44/108044/4
Robert Varga [Thu, 28 Sep 2023 16:04:48 +0000 (18:04 +0200)]
Simplify SchemaAwareXMLStreamNormalizedNodeStreamWriter

There is no need to implement EffectiveModelContext provider here.

Change-Id: I39585b8dc2cefa844110ccf87aa52e9e925599f9
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 8e96df87d83477b78145e71d8db6781aeaf22a55)

8 months agoReparent RandomPrefixInstanceIdentifierSerializer 49/108049/3
Robert Varga [Thu, 28 Sep 2023 18:33:54 +0000 (20:33 +0200)]
Reparent RandomPrefixInstanceIdentifierSerializer

We are the only direct subclass of
AbstractStringInstanceIdentifierCodec, which is a direct superclass of
AbstractModuleStringInstanceIdentifierCodec.

Use the latter as superclass, opening up the possiblity of merging the
two abstract classes.

Change-Id: Iee985fb54b102c4764fa4e9685652762db5265b2
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 99ba8bec562610435ec94949e1c205b9676c0b84)

8 months agoModernize SchemaAwareXMLStreamNormalizedNodeStreamWriter a bit 43/108043/1
Robert Varga [Thu, 28 Sep 2023 16:01:25 +0000 (18:01 +0200)]
Modernize SchemaAwareXMLStreamNormalizedNodeStreamWriter a bit

Use instanceof patterns to eliminate explicit casts.

Change-Id: I63e7dc828c03ea4110793b9dd86f0add1ac16c0a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 585f8b98cad6508a63fa311f270791d20b487600)

8 months agoModernize XMLStreamWriterUtils 42/108042/1
Robert Varga [Wed, 27 Sep 2023 20:11:26 +0000 (22:11 +0200)]
Modernize XMLStreamWriterUtils

Use instanceof patterns and local variable type inference.

Change-Id: I13ace859c67f508955666d7a8f6599b66b083d96
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 7416872ac820bc8c1c49a16b52eb9294f1915eea)

8 months agoReport checked exception in instance identifier writeout 41/108041/1
Robert Varga [Fri, 22 Sep 2023 23:33:03 +0000 (01:33 +0200)]
Report checked exception in instance identifier writeout

Both XML and JSON codecs are talking to a source of
IllegalArgumentExceptions. They should convert them to
XMLStreamException/IOException.

JIRA: YANGTOOLS-1542
Change-Id: Ia5ac633e37ed19c29d4593e2e886501c7baa59dd
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 1ca7a65e5458b997162fb7255d7cbc782ae28371)

8 months agoExpose JSONCodec and XmlCodec 82/107882/1
Robert Varga [Thu, 14 Sep 2023 19:55:17 +0000 (21:55 +0200)]
Expose JSONCodec and XmlCodec

We have a need to emit YangInstanceIdentifier values into raw writers.
We already have this capability exposed through
{JSON,Xml}Codec.writeValue().

This patch exposes that ability, forcing all AbstractCodecFactories to
do so.

JIRA: YANGTOOLS-1541
Change-Id: I854d67b6a1a57b6a8288c41db9714a3292fef093
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 5e6c947ffadb6e3bf6c230abd813ee1c27b08819)

8 months agoRevert "Hide XmlCodecFactory internals" 81/107881/1
Robert Varga [Fri, 15 Sep 2023 13:56:34 +0000 (15:56 +0200)]
Revert "Hide XmlCodecFactory internals"

This reverts commit db06703aa3c1c68d9481b5823c16a570a23dfb6e. It is not
needed as we are about to expose XmlCodec.

JIRA: YANGTOOLS-1541
Change-Id: I861f0363d995517aa6a5a41f1e9077842379dfbe
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
8 months agoIssue releaseFence() at the of ready() 18/107718/2
Robert Varga [Mon, 4 Sep 2023 20:35:22 +0000 (22:35 +0200)]
Issue releaseFence() at the of ready()

We seem to be observing stale state during modification validation. Make
sure we flush out any and all modifications before we complete ready().

Change-Id: I0f388d143526c96ff1684828dd16fc9ee681305b
JIRA: YANGTOOLS-1537
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 85b0d24aae1ea5d90d07f08dc2da3998bf9a299e)

8 months agoClean up checkSealed() 17/107717/2
Robert Varga [Mon, 4 Sep 2023 21:00:34 +0000 (23:00 +0200)]
Clean up checkSealed()

This method is mis-named, it should be called checkOpen(). Also use
an explicit if/throw to eliminate a negation.

Change-Id: Ia7baa03708711b8076ffdd512fbccacd906e3ffb
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit d62bf8450405d2487e0ab1b8bff63f50fcb9b991)

8 months agoUse Optional.isEmpty() 16/107716/2
Robert Varga [Mon, 4 Sep 2023 20:46:15 +0000 (22:46 +0200)]
Use Optional.isEmpty()

We have a number of calls to '!Optional.isPresent()'. Java 11 provides a
convenience Optional.isEmpty() for this case, so use that instead.

Change-Id: I519671f470d804e62bae07ec4c5a71aaa08a29f8
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit a115f79e3818c774d7fc932426d9ef2b65fcae4f)

8 months agoFix ModifiedNode.identifier nullness 03/107703/1
Robert Varga [Mon, 4 Sep 2023 18:06:12 +0000 (20:06 +0200)]
Fix ModifiedNode.identifier nullness

The identifier should always we present, enforce and annotate that.

Change-Id: I0bcebec56ab6fcee6b3c3b396dddbda92282729f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit d761afdb4ea3eab052038dfd185fc5ef65fb2696)

8 months agoMove ModifiedNode.IS_TERMINAL_PREDICATE 02/107702/1
Robert Varga [Mon, 4 Sep 2023 17:41:10 +0000 (19:41 +0200)]
Move ModifiedNode.IS_TERMINAL_PREDICATE

This predicate has a single user, inline it. Also modernize
InMemoryDataTreeModification while we are in the area.

Change-Id: I3cb15fbcb75d0a28c158256e3ef01e218b90dd2a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit ca6c727d73497c2fce7d5be59f9fcc4dff860d70)

8 months agoAdd ValidatedTreeNode 01/107701/1
Robert Varga [Sun, 3 Sep 2023 21:10:01 +0000 (23:10 +0200)]
Add ValidatedTreeNode

We need to @SuppressFBWarnings a use of Optional<TreeNode> being
nullable. Replace Optional with a dedicated record, which provides
adaptation.

Change-Id: Idcd57cc899cacb09d7bec1711d0d084027716734
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 6e154f382548320411bc0c22523f2885d00eb802)

8 months agoUse an instanceof expression 00/107700/1
Robert Varga [Sun, 3 Sep 2023 19:01:59 +0000 (21:01 +0200)]
Use an instanceof expression

We have an-if-and-a-cast, use an instanceof expression instead.

Change-Id: Iee350a79fe740e2434ea1ce35071aa63315f1ae6
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 5c7760892986122a248ca9baffdd1a16035a90bb)

8 months agoImprove NodeModification 99/107699/1
Robert Varga [Sun, 3 Sep 2023 18:42:24 +0000 (20:42 +0200)]
Improve NodeModification

This is a faux-interface to split access. Seal it an allow it to be
implemented only by ModifiedNode.

Introduce NodeModification.isEmpty(), which short-circuits the access to
children.value(). Convert users to prefer this method over accessing
getChildren() -- i.e. moving the potential allocation further down.

Change-Id: Ibce631b729fd496374580be94902c2b18e55268f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit dba093af96755e7fa599b455048b5eab92526d35)

9 months agoHide XmlCodecFactory internals 36/107536/2
Robert Varga [Mon, 28 Aug 2023 11:15:55 +0000 (13:15 +0200)]
Hide XmlCodecFactory internals

We are getting warnings about leaking XmlCodec. While this is not
exactly true, mitigate these warnings by splitting the real logic
into a package-private class while retaining the same external
XmlCodecFactory facade.

JIRA: YANGTOOLS-1534
Change-Id: I719cf82f00d4580505d92d7126be6d2c09c26a4b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit db06703aa3c1c68d9481b5823c16a570a23dfb6e)

9 months agoFix XML codec error reporting 35/107535/2
Robert Varga [Sat, 26 Aug 2023 20:59:58 +0000 (22:59 +0200)]
Fix XML codec error reporting

When we deal with anything ContainerLike, aside of ContainerSchemaNode
and ListNodeSchemaNode, we should just accept there is no support and
proceed to throw a descriptive exception.

JIRA: YANGTOOLS-1533
Change-Id: I7a173f3a21dd55d21e48570690427cee0c0ad16f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 2ebb91d3916ba7d252df9386cf3c0067040d4a9b)

9 months agoSeal XmlCodec 34/107534/1
Robert Varga [Sat, 26 Aug 2023 21:13:12 +0000 (23:13 +0200)]
Seal XmlCodec

We require Java 17, make sure XmlCodec is sealed to be explicit about
what implementations are there.

JIRA: YANGTOOLS-1534
Change-Id: I12ca115663a06666345e956ea9b0901834d1c4c8
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 64826bc2c5d076bc1f241c0a03a13f12b8b60d4b)

9 months agoAdd Inference.isEmpty() 33/107533/1
Robert Varga [Wed, 16 Aug 2023 08:48:38 +0000 (10:48 +0200)]
Add Inference.isEmpty()

Downstreams need logic to adjust the inference unless it is empty.
Expose an isEmpty() method, which efficiently indicates whether the
inference is empty.

Change-Id: Ief6df4d8c2e1db34ea65bb6bdbd7e47525683dad
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 1fb404a623cfde730cfd9d6d7f2c34595028e80a)

9 months agoClean up Bug890Test 21/107521/1
Robert Varga [Sat, 26 Aug 2023 20:58:23 +0000 (22:58 +0200)]
Clean up Bug890Test

Use a multiline string to inline the XML and move the module to
top-level.

Change-Id: Ifda8d6f0fead26b5a813c8e28171032be12e9534
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 6066f250f1882e4926399e50782e25f103b5ff79)

10 months agoBump versions to 10.0.10-SNAPSHOT 48/107048/1
Robert Varga [Tue, 25 Jul 2023 14:16:35 +0000 (16:16 +0200)]
Bump versions to 10.0.10-SNAPSHOT

This starts the next development iteration.

Change-Id: I2460e2f129f2c23a2092d68d0f4787de76821390
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 months agoRelease yangtools v10.0.9
jenkins-releng [Tue, 25 Jul 2023 12:56:57 +0000 (12:56 +0000)]
Release yangtools

10 months agoAdd FluentFutures.submit() 37/107037/1
Robert Varga [Tue, 4 Jul 2023 19:28:54 +0000 (21:28 +0200)]
Add FluentFutures.submit()

This method mirrors Futures.submit(), but results in a FluentFuture.

Change-Id: Ie56ff26cb12a74b5021495cb33029c799d0cb721
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 8db95e038c56d4c56383e948f7836ff98f45668b)

10 months agoBump odlparent to 12.0.7 34/107034/1
Robert Varga [Tue, 25 Jul 2023 11:27:51 +0000 (13:27 +0200)]
Bump odlparent to 12.0.7

Pick up latest updates from upstream.

Change-Id: I281f146c00b5e7aa6a38c89fbd7545b37d0d1e12
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
10 months agoDo not trim element content for string leaf values 59/106959/3
Robert Varga [Thu, 20 Jul 2023 23:35:57 +0000 (01:35 +0200)]
Do not trim element content for string leaf values

Trimming element text leads to values being mis-represented -- for
example if the content is a YANG string, we really need to pick it up
directly.

We should completely avoid trimming, but that would lead to not
recognizing previously-accepted XML documents, for example those which
correspond to a uint8 with leading whitespace.

JIRA: YANGTOOLS-1522
Change-Id: Ib1e05a9428a66765b2f85cfde723fe27076f68ee
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit e4d7042ceaaf302725209f5bdb037be99a092790)

10 months agoEnrich YangParserTestUtils with parseYang(String) 62/106962/2
matus.matok [Thu, 20 Apr 2023 10:13:56 +0000 (12:13 +0200)]
Enrich YangParserTestUtils with parseYang(String)

Added a new static method parseYang() to YangParserTestUtils which allows for
parsing a yang file directly from s string input. This allows for higher
flexibility as we do not need to deal with resource accessibility across
modules. Additionally, it is sometimes more convenient to prefer this new form
of input rather than the old one.

JIRA: YANGTOOLS-1483
Change-Id: I4865b73ba8770669a54dd5be167b2ca2d63f3585
Signed-off-by: matus.matok <matus.matok@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit a0e551c041c426eecd6c6ee6456abe3fa6922a6f)

10 months agoImprove XmlParserStream error reporting 58/106958/1
Robert Varga [Fri, 21 Jul 2023 05:04:55 +0000 (07:04 +0200)]
Improve XmlParserStream error reporting

When we encounter an unhandled schema, we should report ISE instead of
IAE to differentiate the two cases.

Change-Id: I9222f821a259ede5b8d56e5111297de565f01d2d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit f7f98cc72d28be550a0bd93c25e21abb5184168d)

11 months agoBump versions to 10.0.9-SNAPSHOT 84/106384/1
Robert Varga [Mon, 5 Jun 2023 10:10:57 +0000 (12:10 +0200)]
Bump versions to 10.0.9-SNAPSHOT

This starts the next development iteration.

Change-Id: I8451ad867fb870ec69e4d868514b0a98f6b7a66f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
11 months agoRelease yangtools v10.0.8
jenkins-releng [Mon, 5 Jun 2023 08:39:34 +0000 (08:39 +0000)]
Release yangtools

12 months agoFix InferredStatementContext.isSupportedByFeatures() 65/106365/1
Robert Varga [Thu, 1 Jun 2023 14:24:45 +0000 (16:24 +0200)]
Fix InferredStatementContext.isSupportedByFeatures()

StmtContextUtils.checkFeatureSupport() does not work for
InferredStatementContext, as it does not have any declared
substatements -- that only works for OriginalStmtCtx and its subclasses.

Split out computation of this statement's contribution to
isSupportedByFeatures() into a separate method -- allowing
{Inferred,Replica}StatementContext to forward to their prototype or
source.

This also flushes out a bad assertion in YT1393Test, as the second
augment now get correctly disabled.

JIRA: YANGTOOLS-1514
Change-Id: Icf9740cd828bd337b76f38cf33ee29d607f680aa
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 17e18b8ef8877adeaa56e05bcacb3c47c2b6e1c6)

12 months agoRemove unneeded FutureCallback type 02/105902/1
Robert Varga [Tue, 30 May 2023 15:02:48 +0000 (17:02 +0200)]
Remove unneeded FutureCallback type

We do not need to specify EffectiveModelContext, which also fixes an
Eclipse warning.

Change-Id: I3033abf79b70182f767a8672efff6a2c53bee37c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 2ba4770b7de435a3d81d224d3c85f772d75970c2)

12 months agoBump versions to 10.0.8-SNAPSHOT 73/106173/1
Robert Varga [Fri, 26 May 2023 20:58:35 +0000 (22:58 +0200)]
Bump versions to 10.0.8-SNAPSHOT

This starts the next development iteration.

Change-Id: Iae7acd123d0cdf29b6209561ca989dc54e668fa6
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
12 months agoRelease yangtools v10.0.7
jenkins-releng [Fri, 26 May 2023 19:38:15 +0000 (19:38 +0000)]
Release yangtools

12 months agoBump odlparent to 12.0.6 69/106169/1
Robert Varga [Fri, 26 May 2023 14:54:14 +0000 (16:54 +0200)]
Bump odlparent to 12.0.6

Pick up latest upgrades from upstream.

Change-Id: I5f8ccbd6769a3ef3a550cd5aab435fd9ec93f8b5
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 2c85155a40d52bd95178451eed05030be2f00367)

12 months agoConvert dependency checking to aether 67/105967/2
Robert Varga [Mon, 15 May 2023 16:44:12 +0000 (18:44 +0200)]
Convert dependency checking to aether

maven-3.9.1 warns when we are using the RepositorySystem. Convert type
checks and remove the mocked test. This allows us to hide the
checkClasspath() method and use injected values. Also inline
getPluginTransitiveDependencies(), as it is now a single-caller thing.

JIRA: YANGTOOLS-1505
Change-Id: I9585774047b99fac557b6b92f5d51eaacfdd0af3
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 3873a00f5e83dd912df147d75ad600324b30c427)

12 months agoRemove YangToSourcesMojo.remoteRepos 66/105966/2
Robert Varga [Mon, 15 May 2023 15:52:09 +0000 (17:52 +0200)]
Remove YangToSourcesMojo.remoteRepos

This is a shorthand and the only user already has project handy.

Change-Id: I1fd6e98c9b781f30a978dc194aacaaa25deec498
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 0e7c0c09ddfec121a558b7d918eeffce7e33c86c)

12 months agoMove yang.skip property 65/105965/2
Robert Varga [Sat, 13 May 2023 18:33:20 +0000 (20:33 +0200)]
Move yang.skip property

Clean up order of user-visible properties vs. components.

Change-Id: I73f019f98a669b65b411af26681dc98390dc2c40
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit bfd37c967ea3341cfd0b6df4beb1059a31f2befa)

12 months agoRemove YangToSourcesMojo.parserMode 64/105964/1
Robert Varga [Sat, 13 May 2023 17:16:06 +0000 (19:16 +0200)]
Remove YangToSourcesMojo.parserMode

The parser mode is picked up from the code generators now, remove it.

Change-Id: I9ef0c93c7a7e78c5b1b04459b56257a173eea83a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 56c86596327ef6782006c99c52af2dc4969d03b5)

13 months agoAdd explicit test for getChildArg() 49/105449/1
Robert Varga [Mon, 24 Apr 2023 11:04:00 +0000 (13:04 +0200)]
Add explicit test for getChildArg()

Make sure the method is tested to assert.

Change-Id: I3e0c3abf4b48e70fce63dd42647b4718cdcea77f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit e536c4690de4904547036b59e1dce6b46a7ed056)

13 months agoImprove DistinctNodeContainer.getChildByArg() 46/105446/1
Robert Varga [Sun, 23 Apr 2023 06:51:50 +0000 (08:51 +0200)]
Improve DistinctNodeContainer.getChildByArg()

Improve the reported exception to include the key that was being looked
up.

Change-Id: Ica2885543d5d2c68fd84db54c57948f468f8fa2e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 01eb4c388c218d3cf47d36e0b1258de0150cdef6)

13 months agoBump versions to 10.0.7-SNAPSHOT 40/105540/1
Robert Varga [Thu, 20 Apr 2023 09:32:10 +0000 (11:32 +0200)]
Bump versions to 10.0.7-SNAPSHOT

This starts the next development iteration.

Change-Id: If3c849bc1344391d1b226087cbfde0a7be3dc104
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
13 months agoBump odlparent to 12.0.5 36/105536/4
Robert Varga [Thu, 20 Apr 2023 07:37:36 +0000 (09:37 +0200)]
Bump odlparent to 12.0.5

Pick up a regression fix and a few updates.

Change-Id: Ie9c8e08a130b305bc9f99e68eb881190641595c3
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
13 months agoFix yang-common-netty module warnings 35/105535/1
Robert Varga [Wed, 19 Apr 2023 16:05:30 +0000 (18:05 +0200)]
Fix yang-common-netty module warnings

Explicitly require netty-common and document the module.

Change-Id: I08c4762b12be7b65ce7d0088c8e842165bfb4c9f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 7df85ae3b5d8e08efa4ecfa2eb0e48d47571ece9)

13 months agoClean up warnings in concepts 34/105534/1
Robert Varga [Wed, 19 Apr 2023 18:05:22 +0000 (20:05 +0200)]
Clean up warnings in concepts

Fix a javadoc typo, document module-info and require checker-qual
transitively.

Change-Id: I76bf827437ca60500d142ec999dee2782f1ffe8b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 18c386b6b6ec0c9a6cfdb09936d7280e50e82f01)

13 months agoBump versions to 10.0.6-SNAPSHOT 75/105375/1
Robert Varga [Tue, 11 Apr 2023 15:59:03 +0000 (17:59 +0200)]
Bump versions to 10.0.6-SNAPSHOT

This starts the next development iteration.

Change-Id: Ia0fdb408184e91038fd9565dfe36ba9bb8292599
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
13 months agoAdd YangTextSchemaContextResolver feature support 74/105374/1
matus.matok [Mon, 27 Mar 2023 11:31:23 +0000 (13:31 +0200)]
Add YangTextSchemaContextResolver feature support

YangTextSchemaContextResolver does not provide a facility to control the
set of supported features. Add
YangTextSchemaContextResolver.registeredFeatures() and a specialized
Set<QName> implementation to provide backwards-compatible way of
specifying features.

The specialized implementation does not completely conform to
Set.equals()/Set.hashCode() specification and we therefore need to dance
a bit around it.

JIRA: YANGTOOLS-1463
Change-Id: I443d42a6859ce97f238117fabdb7bbdd42488ee5
Signed-off-by: matus.matok <matus.matok@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 9c36059723b4daa02b34e404da78d1cbfe8281d5)

13 months agoUse a switch expression in SubstatementValidator 73/105373/1
Robert Varga [Wed, 5 Apr 2023 15:28:35 +0000 (17:28 +0200)]
Use a switch expression in SubstatementValidator

An expression implies exhaustiveness, which iis a tad more defensive.

Change-Id: I5d76093a1e45e152b1e57e5c320d8a77b539bbf9
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit d2bca86f454529685d6e3a6b92c577f17fb16564)

13 months agoRemove obsolete FIXME 72/105372/1
Robert Varga [Wed, 5 Apr 2023 15:12:04 +0000 (17:12 +0200)]
Remove obsolete FIXME

Namespace type captures were removed in commit 81b0bd062d5, hence this
FIXME is no longer relevant.

Change-Id: Iece723604116d7327084b492473aa95e4be4ebc9
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 9eb117af68e59bc800633b04b3dbacddb255a3ea)

13 months agoClean up YangTextSchemaContextResolver 71/105371/1
Robert Varga [Wed, 5 Apr 2023 00:12:06 +0000 (02:12 +0200)]
Clean up YangTextSchemaContextResolver

Use local variable type inference and instanceof patterns to reduce
clutter a bit.

Change-Id: I955bdc8c133631cabeac138d0509b03cd679ad5b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 23b53872f768efca5c651d54f08c6dfdc7a6c45d)

13 months agoBump odlparent to 12.0.4 47/105347/4
Robert Varga [Mon, 10 Apr 2023 23:08:32 +0000 (01:08 +0200)]
Bump odlparent to 12.0.4

Adopt latest updates from upstream.

Change-Id: I9dcad627cd3c0530add6ec902f5d96a90b8f45a6
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
13 months agoFixup Optional.get() removal 53/105353/1
Robert Varga [Tue, 11 Apr 2023 01:02:36 +0000 (03:02 +0200)]
Fixup Optional.get() removal

We missed three places still calling Optional.get(), convert them.

Change-Id: Ifd045209cc150a6d4f8007eb3562e0119542fcbe
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
13 months agoMigrate users of Optional.get() 45/105345/1
Robert Varga [Sat, 8 Apr 2023 20:28:58 +0000 (22:28 +0200)]
Migrate users of Optional.get()

Optional.orElseThrow() has a more explicit name, preventing potential
confusion with Future.get() and making it clear there might be an
exception coming.

Also take the time to modernize code with local variable type inference,
instanceof patterns and similar.

Change-Id: Ifca580e0f6c652da270260dc126f79d7f32b9ff2
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit c5e2515ee057d1a7f63d88053a77678739356054)

13 months agoUse instanceof pattern 59/105059/2
Robert Varga [Sat, 8 Apr 2023 19:56:30 +0000 (21:56 +0200)]
Use instanceof pattern

This removes an unnecessary cast.

Change-Id: I5fed4dbc753f7691b89fe059cbb4f89cf0fc3600
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 623a947f51795732fa55dd77861a194ec238bce8)

13 months agoSimplify InferredStatementContext.hasEmptySubstatements() 42/105342/1
Robert Varga [Mon, 10 Apr 2023 18:33:27 +0000 (20:33 +0200)]
Simplify InferredStatementContext.hasEmptySubstatements()

SonarCloud is pointing out a code smell around explicit 'false',
refactor to eliminate it.

Change-Id: I7d6eb0f902d72dcdf616b48f9b02994b7280358c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 55f97a833864de6a596f6584d1da38f574ee3f78)

13 months agoRefactor globalOrStatementSpecific() 19/105319/1
Robert Varga [Thu, 6 Apr 2023 21:42:52 +0000 (23:42 +0200)]
Refactor globalOrStatementSpecific()

Current implementation elicits a nullness warning, which is not quite
there -- at the cost of verifyNotNull().

If we refactor checks we can actually make it more performant and
transparent. This is advanteous bacause a null parent implies current is
a GLOBAL storage -- and we therefore can just check the storage type for
STATEMENT_LOCAL.

As it turns out we can refactor the loop to make it obvious, in that we
manually check parent storage. This makes the code flow nicer and more
transparent -- there are no IDE-invisible non-null guarantees. A null
parent storage indicates GLOBAL storage, hence we can bail.

A further boon is that we can simplify the StorageType check to only
compare to STATEMENT_LOCAL.

Change-Id: I5a5b7faf312db6de7f1cebe654f18e9785f58bac
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 6f866bb7c52a0ed2d4fb9bd4f590fd1a325fc50a)

13 months agoImprove findFirstDeclaredSubstatement() 46/105246/1
Robert Varga [Tue, 4 Apr 2023 22:04:25 +0000 (00:04 +0200)]
Improve findFirstDeclaredSubstatement()

Remove a raw Class cast, which in turn removes the need to do unchecked
casts.

Change-Id: I4f3a58e78dc6c87866d7878383169f9efefbde94
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 7cdca9b60e1e469bf078de11a57bee8ef4d087ff)

13 months agoImprove mutatesCtxImpl() 45/105245/1
Robert Varga [Tue, 4 Apr 2023 21:54:25 +0000 (23:54 +0200)]
Improve mutatesCtxImpl()

Remove raw type cast, which removes the need for suppressions.

Change-Id: Ibab30378d693b28bbf85e3ba92607e71aa3eba84
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 0b2e7abaaf5ccf1b98ed44ef79cae34045fd2548)

13 months agoImprove EffectiveInstances.attachCopy() 44/105244/1
Robert Varga [Tue, 4 Apr 2023 21:44:52 +0000 (23:44 +0200)]
Improve EffectiveInstances.attachCopy()

Use local variable type inference to reduce code clutter.

Change-Id: I52d3450d87aefbd1ae3bb806fbfd37aee52c979f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 8603bcefe673fde7f83d019af3ed9c32e99045a2)

13 months agoRemove an explicit cast from unmaskUndeclared() 43/105243/1
Robert Varga [Tue, 4 Apr 2023 21:41:43 +0000 (23:41 +0200)]
Remove an explicit cast from unmaskUndeclared()

Use an instanceof pattern to have the return readily-cast.

Change-Id: I253fc8848f828e76fb421a86430b490646bc1d9a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 569c06570e4f8c3c8071e6ac0ea3e7f0a1e8ae2b)

13 months agoImprove StatementContextBase.wrapWithOriginal() 42/105242/1
Robert Varga [Tue, 4 Apr 2023 21:28:17 +0000 (23:28 +0200)]
Improve StatementContextBase.wrapWithOriginal()

We can use local variable type inference to reduce warnings and also
instanceof pattern to remove an explicit cast.

Change-Id: I80572a5392b9a94ed46fa6fdf28cb4a21580995c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 7da54f0e7e2ba48120f70cd6022af9c19bec4e17)