yangtools.git
8 years agoSimplify check for tree/node match 72/28672/4
Robert Varga [Wed, 21 Oct 2015 23:16:18 +0000 (01:16 +0200)]
Simplify check for tree/node match

The check can be inverted to check for:

All nodes belong in TreeType.OPERATIONAL. Nodes which are in
TreeType.CONFIGURATION return this as a property.

Which can be written as a simple expression. Also expand javadoc a bit.

Change-Id: Ie10d9b4bc3f9f1e2d08f592cfec1bf4bc92ea21b
Signed-off-by: Robert Varga <robert.varga@pantheon.sk>
8 years agoBUG-4658: fix default value in BooleanType 42/30042/5
Robert Varga [Sat, 21 Nov 2015 20:08:36 +0000 (21:08 +0100)]
BUG-4658: fix default value in BooleanType

The default value should be null. Also fix up an ancient test case. Also
fix leafref and identityref.

Change-Id: Ib82952493360bf24ac9db41814094e879ecda0b0
Signed-off-by: Robert Varga <robert.varga@pantheon.sk>
8 years agoBUG-4638: rework getBaseType() for derived types 31/29831/3
Robert Varga [Tue, 17 Nov 2015 20:52:12 +0000 (21:52 +0100)]
BUG-4638: rework getBaseType() for derived types

Returning a restricted type will confuse users, who expect to follow
the YANG-implied derivation rules, which rely on type specification -- a
concept we do not have. Until we have proper mapping, hide the existence
restricted types.

Change-Id: I2980e617b168b9ce48a0e60cd7264d4a803ac627
Signed-off-by: Robert Varga <robert.varga@pantheon.sk>
8 years agoBug 4648: Fixed binary default value in old parser. 71/29971/1
Tony Tkacik [Fri, 20 Nov 2015 10:06:28 +0000 (11:06 +0100)]
Bug 4648: Fixed binary default value in old parser.

Change-Id: I3d4401aaddf5445f463a34683681646edb3098e2
Signed-off-by: Tony Tkacik <ttkacik@cisco.com>
8 years agoBUG-4638: rename LeafTypes to ConcreteTypes 74/29874/2
Robert Varga [Wed, 18 Nov 2015 17:14:49 +0000 (18:14 +0100)]
BUG-4638: rename LeafTypes to ConcreteTypes

This performs a rename to ConcreteTypes, addressing the FIXME left in
DerivedTypes.

Change-Id: I93f2a174e0cf554d192018fdf5c8a83b768cfcbe
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoBUG-4638: add more type checking methods 73/29873/2
Robert Varga [Wed, 18 Nov 2015 17:08:49 +0000 (18:08 +0100)]
BUG-4638: add more type checking methods

Update the both BaseTypes and DerivedTypes should have the uint
checkers, with the difference being that BaseTypes do not perform a
recursive lookup. That means that BaseTypes#isInt8() will return true
only for 'type int8;', not derived types.

Change-Id: I9c391e1f63c661e65c2e5d3a241465f1c326878d
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoBUG-4638: Implement enum build validation 70/29870/3
Robert Varga [Wed, 18 Nov 2015 15:06:23 +0000 (16:06 +0100)]
BUG-4638: Implement enum build validation

EnumPairs need to be validated fro conflicting values. Also, the parser
integration code needs to assign th eproper value.

Change-Id: I28a57656231b110110dff58ba69c57ec6d76e3c7
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoBUG-4638: implement bits validation 63/29863/4
Robert Varga [Wed, 18 Nov 2015 14:49:46 +0000 (15:49 +0100)]
BUG-4638: implement bits validation

BitsType needs to validate

Change-Id: Ib648b33302bef5e475f3b26edd9f242fbfdb4560
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoBUG-865: mark yang-model-util types as deprecated 24/29724/5
Robert Varga [Sun, 15 Nov 2015 11:47:51 +0000 (12:47 +0100)]
BUG-865: mark yang-model-util types as deprecated

Having these classes out in the open creates confusion in users.
Deprecate them in favor of util.type.{Base,Derived,Restricted}Types(),
which do not leak implementation details.

Change-Id: Ib690a43d7e956e5ed0cac13a6276cb03fd049843
Signed-off-by: Robert Varga <robert.varga@pantheon.sk>
8 years agoFilter non-Yang files when loading a directory 72/29872/2
Robert Varga [Wed, 18 Nov 2015 16:43:37 +0000 (17:43 +0100)]
Filter non-Yang files when loading a directory

If we happen to have a file in the directory, such as a vim buffer, the
test will fail. Make sure we load only files with .yang extension.

Change-Id: I8e8b0df8b34b93e9f4a1e863f95eef4bc779ba84
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoFix EnumEffectiveStatementImpl#getStatus() 69/29869/2
Robert Varga [Wed, 18 Nov 2015 16:27:54 +0000 (17:27 +0100)]
Fix EnumEffectiveStatementImpl#getStatus()

Status should default to CURRENT, e.g. we should never report it as
null.

Change-Id: I5741e4f65c0c254239851c83d79f094c540abaa0
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoBUG-4638: create a dedicated exception for range/length validation 59/29759/10
Robert Varga [Mon, 16 Nov 2015 15:37:37 +0000 (16:37 +0100)]
BUG-4638: create a dedicated exception for range/length validation

Having only an IllegalArgumentException is not sufficient, create a pair
of new ones.

Change-Id: I90ac46ac55d9745651a8408398330a2a337d3f9a
Signed-off-by: Robert Varga <robert.varga@pantheon.sk>
8 years agoBug 4645: Fixed binary default value. 51/29851/2
Tony Tkacik [Wed, 18 Nov 2015 12:48:37 +0000 (13:48 +0100)]
Bug 4645: Fixed binary default value.

Change-Id: Ic98b42f9923505631a558ea3971cfbc7776eafad
Signed-off-by: Tony Tkacik <ttkacik@cisco.com>
8 years agoBUG-4638: add utility check methods for base types 92/29792/3
Robert Varga [Tue, 17 Nov 2015 00:08:39 +0000 (01:08 +0100)]
BUG-4638: add utility check methods for base types

Some users, like the java binding, need to distriguish the various
integer base types in order to produce the correct type specification.
Add utility methods which check the concrete integer base type
(uint{8,16,32,64} and int{8,16,32,64}.

Change-Id: Idf4c71be6b135d68715fe095e1cc1f5033c4824c
Signed-off-by: Robert Varga <robert.varga@pantheon.sk>
8 years agoBUG-4638: do not rely on yang.model.util Types 89/29789/4
Robert Varga [Mon, 16 Nov 2015 22:59:28 +0000 (23:59 +0100)]
BUG-4638: do not rely on yang.model.util Types

Implementation and tests should not rely on a specific base type, but
should rather check for TypeDefinition interface.

Change-Id: Icd99b3f1f2c703a124c92169dbe60cabe2d2b797
Signed-off-by: Robert Varga <robert.varga@pantheon.sk>
8 years agoBug 4645: Fixed code-implied defaults. 49/29849/4
Tony Tkacik [Wed, 18 Nov 2015 11:44:01 +0000 (12:44 +0100)]
Bug 4645: Fixed code-implied defaults.

As turned out in parser some YANG types default values
were incorrectly hard-coded in code since Hydrogen
and were unnoticed till automated addition of
 default values in MD-SAL.

Change-Id: I1be1b8ec2358d794fa3ff51a71f392326271b55c
Signed-off-by: Tony Tkacik <ttkacik@cisco.com>
8 years agoBUG-865: deprecated DataNodeContainer.getDataChildByName(String) 98/29498/2
Robert Varga [Tue, 10 Nov 2015 13:51:08 +0000 (14:51 +0100)]
BUG-865: deprecated DataNodeContainer.getDataChildByName(String)

This method cannot be implemented in a predictable way and the caller
needs to deal with QName ambiguity. Deprecate it, scheduling it for
later removal.

Change-Id: I708dcecf80a5e735410f3bbf5cd604ebd054b51d
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoBUG-4369: remove dependency on MDSAL components 49/29649/2
Robert Varga [Fri, 13 Nov 2015 13:51:51 +0000 (14:51 +0100)]
BUG-4369: remove dependency on MDSAL components

This removes the single integration test which required the API plugin
and eradicates all mentions of the mdsal project in yangtools.

Change-Id: I04d9d864b6dd0da5e4dc7829d975cf73707b5605
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoBug 2496: Implement parser support for parsing YIN input 09/23409/26
Martin Ciglan [Tue, 3 Nov 2015 13:00:48 +0000 (14:00 +0100)]
Bug 2496: Implement parser support for parsing YIN input
          instead of YANG input

- redundant casting deleted
- code refactoring at various places
- various bug fix in YIN/YANG mutual code
- extensions namespace sorted out/ code review comments done
- fixed wildcard imports in unit test classes
- added new unit tests
- code changes based on code review
- refactored code
- set of YIN modules added for test
- TestUtils methods for YIN added

- types fix (mostly union affected)
- various bugs fixed, based on testing with huge set of YIN files (those not commited yet)

Change-Id: I9ebb60ecf596efe92c31f2ccc6a884c32c4c0a82
Signed-off-by: Martin Ciglan <mciglan@cisco.com>
Signed-off-by: Igor Foltin <igor.foltin@pantheon.sk>
8 years agoBUG-4638: Implement length restrictions 56/28856/13
Robert Varga [Wed, 21 Oct 2015 08:39:00 +0000 (10:39 +0200)]
BUG-4638: Implement length restrictions

Change-Id: I0cf0357a7bd44c825eb8c202cb649e009a3a74c3
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoBUG-4638: Split out Number comparator 85/28585/13
Robert Varga [Tue, 20 Oct 2015 09:47:46 +0000 (11:47 +0200)]
BUG-4638: Split out Number comparator

Comapring two Numbers of the same class is useful also for comparing
lengths. Split it out into utility methods.

Change-Id: I0203d191a7849b7485419a5ef9e32c0fef442ed3
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoBUG-4638: Emit a warning when units are redefined 21/29721/3
Robert Varga [Sun, 15 Nov 2015 10:14:55 +0000 (11:14 +0100)]
BUG-4638: Emit a warning when units are redefined

While RFC6020 does not define whether units can be redefined, they are
bound to the value, hence it makes sense to inherit them just as default
value is inherited.

Change-Id: I8e57d961ee1f7bf34ada817dd55f95045da4bc9a
Signed-off-by: Robert Varga <robert.varga@pantheon.sk>
8 years agoBUG-4638: Introduce LeafTypeBuilders 17/29717/5
Robert Varga [Sun, 15 Nov 2015 01:18:34 +0000 (02:18 +0100)]
BUG-4638: Introduce LeafTypeBuilders

Leaves need to override units/default value of their type, but unlike
typedefs do not need retain their SchemaPath.

Change-Id: I4c0539983b0f5023bd57a98c57aca75ebc9975fb
Signed-off-by: Robert Varga <robert.varga@pantheon.sk>
8 years agoShorted Decimal64Specification 09/29709/5
Robert Varga [Sat, 14 Nov 2015 21:06:50 +0000 (22:06 +0100)]
Shorted Decimal64Specification

Import Decimal64Specification directly.

Change-Id: Icb3d442331784c6d9704c124b3cff562b350fb75
Signed-off-by: Robert Varga <robert.varga@pantheon.sk>
8 years agoBUG-4638: Fix BaseTypes and DerivedTypes 94/29694/11
Robert Varga [Sat, 14 Nov 2015 00:04:02 +0000 (01:04 +0100)]
BUG-4638: Fix BaseTypes and DerivedTypes

Generics prevent proper call when dealing with wildcard arguments,
remove them from DerivedTypes.

BaseTypeBuilders should not leak the base types, as these are
package-private, but rather return a proper type definition.

Change-Id: Iacd97acbaf63896e8d7cd493d6a199d9c42501c4
Signed-off-by: Robert Varga <robert.varga@pantheon.sk>
8 years agoBUG-4629: cleanup YinSchemaSource 67/29567/4
Robert Varga [Wed, 11 Nov 2015 21:34:53 +0000 (22:34 +0100)]
BUG-4629: cleanup YinSchemaSource

This patch introduces Yang/YinSchemaSourceRepresentation, which mark
YANG and YIN schema sources irrespective of the format in which they are
available.

It then adds YimXmlSchemaSource, which allows access to YIN
representation as a javax.xml.transform.Source. Finally it deprecates
YinSchemaSource and provides a utility YinDomSchemaSource, which can
translate a YinXmlSchemaSource in the DOM representation.

Change-Id: I832b2f14637eeb3183c6fe3254f8129bccc0a7ba
Signed-off-by: Robert Varga <robert.varga@pantheon.sk>
8 years agoMake a method static 47/29647/1
Robert Varga [Fri, 13 Nov 2015 12:50:11 +0000 (13:50 +0100)]
Make a method static

Private method can be made static, make it so.

Change-Id: I21950b4acd92cce20b66a22360285c4c166f519c
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoBUG-865: deprecate DataTreeFactor.create() 40/29640/1
Robert Varga [Fri, 13 Nov 2015 11:24:18 +0000 (12:24 +0100)]
BUG-865: deprecate DataTreeFactor.create()

This method is provided for compatibility only and should be deprecated,
as the users do not know that they need to specify proper DataTreeType
to get config node enforcement.

Change-Id: I880c75fec2e4a28ae090016229415d0a676a657b
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoPreserve augmentation order in module. 96/29596/1
Tony Tkacik [Thu, 12 Nov 2015 13:34:46 +0000 (14:34 +0100)]
Preserve augmentation order in module.

Change-Id: I5a868b7f2fa9a411d66f978784b3fdae2b52fe28
Signed-off-by: Tony Tkacik <ttkacik@cisco.com>
8 years agoBug 4454: Write to datastore: elements count error 99/28599/7
Filip Gregor [Tue, 10 Nov 2015 13:03:32 +0000 (14:03 +0100)]
Bug 4454: Write to datastore: elements count error

added check for write
added aditional tests
added childrenBefore counter check

Change-Id: I970272520a2c97210cf10a7ff4aa92adc8dc6b27
Signed-off-by: Filip.Gregor <fgregor@cisco.com>
8 years agoMake InMemorySchemaSourceCache expire items 81/29481/1
Robert Varga [Tue, 10 Nov 2015 10:02:37 +0000 (11:02 +0100)]
Make InMemorySchemaSourceCache expire items

We use the class only for ASTs. Caching them is good for periods of
parsing churn, such as startup, but the items should expire after not
being used for some time.

Change-Id: I38d95b62fd823906b851466c39429aaab7a72b56
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoEliminate qname field 72/29472/4
Robert Varga [Mon, 9 Nov 2015 22:41:55 +0000 (23:41 +0100)]
Eliminate qname field

The QName always matches the last component of the SchemaPath, hence
eliminate the dedicated field and use SchemaPath#getLastComponent().
Reduces memory footprint of SchemaContext instances by about 1%.

Change-Id: I676b6ef8cd61737b60e7ef7edd86c8210645efd2
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoSplit off DeclaredEffectiveStatementBase 69/29469/3
Robert Varga [Mon, 9 Nov 2015 21:28:38 +0000 (22:28 +0100)]
Split off DeclaredEffectiveStatementBase

Since we are retaining declared statements, which already capture
details from StmtContext, let's specialize a
DesclaredEffectiveStatementBase, which forwards calls to argument and
co. to the declared statement. Reduces memory footprint of
EffectiveSchemaContexts by about 3%.

Change-Id: Icbfa99db841f850c1048fbfe06618613230c2503
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoShare MandatoryStatement instances 65/29465/3
Robert Varga [Mon, 9 Nov 2015 18:46:03 +0000 (19:46 +0100)]
Share MandatoryStatement instances

Heap dump analysis shows we are wasting memory on MandatoryStatementImpl
instances which are empty. Fix this by creating two dedicated classes
which handle the 'mandatory true' and 'mandatory false' cases.

Same goes for MandatoryEffectiveStatementImpl, for which we provide an
alternative implementation, requiring an MandatoryEffectiveStatement
interface, so that it can be looked up.

Change-Id: If126c3b8d81ad4a870088285ff8956724b199134
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoLower SchemaPath#getPath() memory overhead 57/29457/4
Robert Varga [Mon, 9 Nov 2015 17:44:52 +0000 (18:44 +0100)]
Lower SchemaPath#getPath() memory overhead

Acquiring forward path involves performing a reverse() on an
ImmutableList -- which results in an proxy object being created.
Each such object costs 24 bytes, leading to ~120K wasted memory on a
freshly-booted up BGP+OF instance.

Eliminate this overhead by instantiating a temporary ArrayList and
copying its reverse view. This way only a single object is retained.

Change-Id: If3b193e84f0f7ffc17997360ae5b02669c119321
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoInstantiate a QName cache 51/29451/2
Robert Varga [Mon, 9 Nov 2015 15:24:57 +0000 (16:24 +0100)]
Instantiate a QName cache

YANG parser needs to suppress duplicate QNames when a grouping is
instantiated to multiple places, for example. This the caching
infrastructure which can be reused.

Change-Id: Ic26298f768cba0a7f76610b93769ae1073c042a2
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoReuse integer QNames 79/29379/2
Robert Varga [Fri, 6 Nov 2015 10:44:22 +0000 (11:44 +0100)]
Reuse integer QNames

Use singleton constants instead of instantiating QNames over and over
again.

Change-Id: I1aa94a8c9bfd808d7928589e7f54d8b5224232d0
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoCache QNameModules during instantiation 80/29180/4
Robert Varga [Tue, 3 Nov 2015 02:24:33 +0000 (03:24 +0100)]
Cache QNameModules during instantiation

When constructing QNameModules in parser, we want to make sure we reuse
instances as much as possible. To do that, perform cached reference
lookup.

Change-Id: Ibeb26ee89db739a81605913d8fcae6c4e45ed764
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoBug 4501 - JSON for "type bits" in YANG models not handled correctly 14/28614/4
Peter Kajsa [Tue, 20 Oct 2015 15:38:13 +0000 (17:38 +0200)]
Bug 4501 - JSON for "type bits" in YANG models not handled correctly

- rejecting of value rewrite (quickfix)

Change-Id: I1007b15d5beacff2877137173fa09e009b877c57
Signed-off-by: Peter Kajsa <pkajsa@cisco.com>
8 years agoAdd/improve yang parser error reporting 66/27866/9
Tom Pantelis [Fri, 2 Oct 2015 16:18:50 +0000 (12:18 -0400)]
Add/improve yang parser error reporting

If a yang file fails to load/parse in karaf, it fails silently. The
first problem is that YangTextSchemaContextResolver#getSchemaContext
logs the SchemaResolutionException to debug as it retries with
getResolvedSources. But if getResolvedSources is empty, it ends up
silently returning an empty SchemaContext.

Another issue is that the underlying exceptions that are really relevant
are added as suppressed to the aggregating exception. This would be fine
if the underlying logger in karaf printed suppressed exceptions as
Throwable#printStackTrace does but it doesn't. The suppressed exceptions
do appear from maven (that underlying logger uses printStackTrace).

My first thought was to log the SchemaResolutionException if
SchemaResolutionException was empty but use printStackTrace to get the
suppressed exceptions. However there are 3 levels of exceptions which is
kind of ugly - one needs to sift thru a lot of noise and long stack
traces to find the relevant error.

So. to make it more user-friendly, I instead modified BundleGlobalContext
to log each source exception's suppressed exceptions as these contain the
actual parsing failures. I also only printed the exception message
normally to avoid the stack trace noise. The full trace can be seen with
debug enabled.

Change-Id: Ie603bab3caa4fabc421ffbd106fddd5176743d2b
Signed-off-by: Tom Pantelis <tpanteli@brocade.com>
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoBUG-4578: handle APPEARED/DISAPPEARED nodes 72/29272/2
Robert Varga [Wed, 4 Nov 2015 21:04:12 +0000 (22:04 +0100)]
BUG-4578: handle APPEARED/DISAPPEARED nodes

These two new events should be handled the same way SUBTREE_MODIFIED is
handled by performing operations on indicated nodes.

Change-Id: I1112f29b91f79712946a5778d1d02666612d38e6
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoStore key arguments in an ImmutableSet 79/29179/2
Robert Varga [Tue, 3 Nov 2015 11:48:01 +0000 (12:48 +0100)]
Store key arguments in an ImmutableSet

Make sure we copy key statements from groupings efficiently by reusing
SchemaNodeIdentifiers which have not changed. Also store them in an
ImmutableSet, rather than a HashSet.

Change-Id: I979e417d722bef54e395459403394bdaccdcc339
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoUse an ArrayList instead of LinkedList 44/29144/3
Robert Varga [Mon, 2 Nov 2015 14:42:18 +0000 (15:42 +0100)]
Use an ArrayList instead of LinkedList

ArrayLists are better at append+copy pattern.

Change-Id: I91e6c7344c9622319f0a7859139a14e924e6f2e1
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoExport yang-model-export via artifacts 98/29198/1
Robert Varga [Tue, 3 Nov 2015 16:13:17 +0000 (17:13 +0100)]
Export yang-model-export via artifacts

This is to enable downstream projects to not define the version of the
dependency.

Change-Id: I0d0861fb5b103abfb475656f1af3ce09ae07b8b1
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoRemove yang-data-operations 87/24087/5
Maros Marsalek [Tue, 14 Jul 2015 08:43:06 +0000 (10:43 +0200)]
Remove yang-data-operations

Not used anywhere and not needed anymore.

Change-Id: Ie21d18dfaaffe14ddbc843cc568fa1e47004644c
Signed-off-by: Maros Marsalek <mmarsale@cisco.com>
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoClean YangStatementParserListenerImpl up 41/29141/1
Robert Varga [Mon, 2 Nov 2015 14:35:02 +0000 (15:35 +0100)]
Clean YangStatementParserListenerImpl up

Various cleanups:
- unused try/catch block removal
- remove isType local variable
- use Preconditions.checkArgument()

Change-Id: I5a2b15681b9fa8fa3cdaef090a31ea585854da7e
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoSwitch StatementContextBase to use ArrayList 40/29140/1
Robert Varga [Mon, 2 Nov 2015 14:28:13 +0000 (15:28 +0100)]
Switch StatementContextBase to use ArrayList

This inlines the history initialization and uses an ArrayList instead of
a LinkedList.

Change-Id: I5980e6525f0b00c46b1f1f87dad941685042abe9
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoDo not use String.replace() 39/29139/1
Robert Varga [Mon, 2 Nov 2015 12:19:23 +0000 (13:19 +0100)]
Do not use String.replace()

Change-Id: I2ad218ca9a297300a506ec5984ab1b2fc4d86efa
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoRemove a search-before-remove on ArrayList 38/29138/1
Robert Varga [Mon, 2 Nov 2015 14:21:19 +0000 (15:21 +0100)]
Remove a search-before-remove on ArrayList

There is no need to make the removal conditional on presence. This
forces two linear searches of the list, instead of just one.

Change-Id: I3d3fb23ac02e95433cc17ccee119dbb1392cef42
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoShare empty ConstraintDefinition instances 98/29098/2
Robert Varga [Sun, 1 Nov 2015 18:27:29 +0000 (19:27 +0100)]
Share empty ConstraintDefinition instances

Introduce a specialized class with two singleton instances for holding
the (very common) empty ConstraintDefinition object. Hide
EffectiveConstraintDefinitionImpl and make it expose just a static
factory method, which does the right thing.

Also creates ConstraintDefinitions to hold common functions for the two
implementations.

Change-Id: I4c25aee638ddb0617030fffcb0bc54ac13d28bc1
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoMake SchemaNodeIdentifier.Relative final 97/29097/2
Robert Varga [Sun, 1 Nov 2015 17:08:27 +0000 (18:08 +0100)]
Make SchemaNodeIdentifier.Relative final

This makes sure we do not ever subclass it, preventing implementation
leakage.

Change-Id: I8901600968db777342ebb858279cb69b3e35997c
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoUse ImmutableList for unknown nodes 96/29096/2
Robert Varga [Sun, 1 Nov 2015 13:59:41 +0000 (14:59 +0100)]
Use ImmutableList for unknown nodes

Do not allow modification of unknown nodes, also saves some 30KiB from
1200 empty ArrayLists.

Change-Id: Ie0fa44ebdca237a31928718445e2b2deb41a2299
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoShare Integer.MAX_VALUE 95/29095/2
Robert Varga [Sun, 1 Nov 2015 13:54:35 +0000 (14:54 +0100)]
Share Integer.MAX_VALUE

As it turns out Integer.MAX_VALUE is not usually cached for boxing. Add
an explicit cache to eliminate ~160K Integers wasting 2.5MB on a simple
SchemaContext.

Change-Id: I47b5b00358d5726eddc8baf675bda1f850823362
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoBUG-4556: enable DataSchemaContextTrees to be scavenged 94/29094/2
Robert Varga [Sun, 1 Nov 2015 12:09:02 +0000 (13:09 +0100)]
BUG-4556: enable DataSchemaContextTrees to be scavenged

DataSchemaContextTree contains an internal weak-keyed cache, which is
used to speed up lookups and share DataSchemaContextNodes.

Unfortunately the cache uses strong references for values (e.g.
DataSchemaContextTree) instances, which transitively (via
DataSchemaContextNode) retain the reference to the key. This has the
effect of the key being always reachable, thus causing a memory leak.

Make the cache use weak references for values, which ensures that it
gets scavenged whenever its contents are no longer referenced.

Change-Id: I1684d1bf2c2c5cdc44cda1e8e508149ff3a8fae4
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoBUG-4556: Introduce StmtContext.getSchemaPath() 71/29071/6
Robert Varga [Sat, 31 Oct 2015 13:10:16 +0000 (14:10 +0100)]
BUG-4556: Introduce StmtContext.getSchemaPath()

SchemaContexts are created in top-to-bottom direction, making them
useful for holding SchemaPaths. This reduces the memory overhead
from not constructing SchemaPaths in a hierarchical manner.

Change-Id: I85a49c6c861543a585730c8dac12622605eb20d5
Signed-off-by: Robert Varga <robert.varga@pantheon.sk>
8 years agoCapture ANTLR4 syntax errors and log them 25/29025/3
Martin Ciglan [Fri, 30 Oct 2015 14:27:42 +0000 (15:27 +0100)]
Capture ANTLR4 syntax errors and log them

By default, ANTLR4 parser instance has ANTLR4's ConsoleErrorListener
attached to it, therefore error messages are piped to System.err.

In this patch, this is silenced and captured via existing
custom implementation of ANTLR4's BaseErrorListener.

Change-Id: I1922880bf09e69ca55316dacbca9b5fc338f721c
Signed-off-by: Martin Ciglan <mciglan@cisco.com>
8 years agoBug 4504 - YIN generation failed on openflow-protocol module 94/28894/5
Peter Kajsa [Wed, 28 Oct 2015 15:04:03 +0000 (16:04 +0100)]
Bug 4504 - YIN generation failed on openflow-protocol module

Unknown nodes added by augmentation shouldn't be exported by yin export
of a particular yang node.

Change-Id: I421aeee7732f40929f902546384c0a7bab0bf22c
Signed-off-by: Peter Kajsa <pkajsa@cisco.com>
8 years agoMake TestModel a utility class 76/28776/2
Robert Varga [Sat, 24 Oct 2015 18:18:59 +0000 (20:18 +0200)]
Make TestModel a utility class

Final and private contructor.

Change-Id: Ia42bda3b878caa44aa785529d38928f167a863fc
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoDo not leak internal methods 11/28711/3
Robert Varga [Thu, 22 Oct 2015 20:39:39 +0000 (22:39 +0200)]
Do not leak internal methods

applyTouch() is method internal to implementation, it should be left
protected, not public.

Change-Id: Ic57e5bffe66171747650bf13f501f89f8a59fd57
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoBUG-2399: Implement automatic container removal 30/17030/26
Jan Hajnar [Wed, 20 May 2015 09:47:30 +0000 (11:47 +0200)]
BUG-2399: Implement automatic container removal

Structural containers all all container nodes which do not contain a
presence statement. RFC6020 specifies that structural containers have no
semantic meaning aside from being containment nodes for their children
and therefore can be created when a child would appear and should
disappear when they lose their last child.

Containers which should not be subject to this lifecycle need to be
marked with a 'presence' statement, which attaches semantic meaning
to their presence.

Change-Id: Icb69c959a27726b549f563b84b52727592b67cb1
Signed-off-by: Robert Varga <rovarga@cisco.com>
Signed-off-by: Jan Hajnar <jhajnar@cisco.com>
8 years agoBug 4414: Shorthand case statement not working 68/28268/9
Martin Ciglan [Mon, 12 Oct 2015 07:40:46 +0000 (09:40 +0200)]
Bug 4414: Shorthand case statement not working

Original for shorthand-case was not set at all,
therefore definition in grouping causes
IncorrectNestingException: Supplied class is not valid case

- code refactored
- fix: getOriginal() returns proper value

Change-Id: I6941eea52a07967824d2653fbfaedebc5f35ddc9
Signed-off-by: Martin Ciglan <mciglan@cisco.com>
8 years agoLists with min-elements > 0 are mandatory 22/28722/3
Robert Varga [Fri, 23 Oct 2015 08:51:29 +0000 (10:51 +0200)]
Lists with min-elements > 0 are mandatory

As per https://tools.ietf.org/html/rfc6020#section-3.1, leaf-list and
list items which have min-elements greater than zero are considered
mandatory.

Adjust ConstrainDefinition implementations to take min-elements into
account and report isMandatory() as true in case it is non-zero.

Change-Id: I7d7a0c15ce26bab2eed5bc2569cc6b8904dac203
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoDo not retain build context via extensions. 83/28683/3
Tony Tkacik [Thu, 22 Oct 2015 09:01:49 +0000 (11:01 +0200)]
Do not retain build context via extensions.

Change-Id: I3a074d5c526668e85a516678f09b419f4d335347
Signed-off-by: Tony Tkacik <ttkacik@cisco.com>
8 years agoAdd range validation and normalization 72/28572/3
Robert Varga [Sun, 18 Oct 2015 11:20:15 +0000 (13:20 +0200)]
Add range validation and normalization

RangeRestrictedTypeBuilder now computes proper ranges, lowered to the
class defined by the base type, so we have the same types for
enforcement no matter the input.

Change-Id: Ibc139a3ff3d18bba87219a1fe91b2269b107a3c6
Signed-off-by: Robert Varga <robert.varga@pantheon.sk>
8 years agoFix various small warnings 71/28571/2
Robert Varga [Sun, 18 Oct 2015 11:19:52 +0000 (13:19 +0200)]
Fix various small warnings

Unused import and raw type reference.

Change-Id: I625813261450ff85dc349da19bfbfceab80ff305
Signed-off-by: Robert Varga <robert.varga@pantheon.sk>
8 years agoIntroduce UnresolvedNumber 54/28554/3
Robert Varga [Mon, 19 Oct 2015 13:11:02 +0000 (15:11 +0200)]
Introduce UnresolvedNumber

UnresolvedNumber is a better-designed replacement for
UnknownBoundaryNumber.

Change-Id: Id603529d9469684d853080d702db50637afe67b3
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoUtil types: implement hashCode()/equals()/toString() 38/28538/4
Robert Varga [Fri, 16 Oct 2015 17:52:10 +0000 (19:52 +0200)]
Util types: implement hashCode()/equals()/toString()

This patch adds the infrastructure and provides the base
hashCode/equals/toString implementations for all types.

Change-Id: I8e10bcc71e41bc07e5ff96f2746e3352b02abc39
Signed-off-by: Robert Varga <robert.varga@pantheon.sk>
8 years agoDo not lookup root operation explicitly 04/28504/2
Robert Varga [Fri, 16 Oct 2015 12:20:34 +0000 (14:20 +0200)]
Do not lookup root operation explicitly

Make sure we use the public API and not rely of internal workings in
tests.

Change-Id: I435a385e8279a1d1fb4f4860767c96846f759880
Signed-off-by: Robert Varga <robert.varga@pantheon.sk>
8 years agoReuse no-revision qnames 05/28505/2
Robert Varga [Fri, 16 Oct 2015 12:42:18 +0000 (14:42 +0200)]
Reuse no-revision qnames

The qname can be used twice, it makes sense to keep it around.

Change-Id: Iedf0fffb7a0791bb264edb43cb734d4e1289955e
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoBUG-4261: intern leaf nodes 07/28507/1
Robert Varga [Fri, 16 Oct 2015 13:03:22 +0000 (15:03 +0200)]
BUG-4261: intern leaf nodes

Look up the interner for leaf nodes based on the current schema node.

Change-Id: Ibd7ebc3affa315c650c3dce1cae7138d9aed43ab
Signed-off-by: Robert Varga <robert.varga@pantheon.sk>
8 years agoIntroduce model.util.type package 61/28261/7
Robert Varga [Sat, 10 Oct 2015 21:18:07 +0000 (23:18 +0200)]
Introduce model.util.type package

This package introduces new utility classes for implementing a
TypeDefinition hierarchy. The two entrypoints are RestrictedTypes and
DerivedTypes.

Change-Id: Icf0a91f09151c975a77461ee4488af1f5b300d27
Signed-off-by: Robert Varga <robert.varga@pantheon.sk>
8 years agoIntroduce TypeDefinitionAware 78/28478/2
Robert Varga [Thu, 15 Oct 2015 02:18:37 +0000 (04:18 +0200)]
Introduce TypeDefinitionAware

TypeEffectiveStatement and TypedefEffectiveStatement should expose the
underlying TypeDefinition, so it can be acquired for use with the type
system.

Change-Id: I58aaa33df077fc092db35f87be671a0b89e50fd3
Signed-off-by: Robert Varga <robert.varga@pantheon.sk>
8 years agoBug 3899: Milestone: Increase test coverage for YangTools (80%). 54/25354/6
Igor Foltin [Tue, 29 Sep 2015 08:49:25 +0000 (10:49 +0200)]
Bug 3899: Milestone: Increase test coverage for YangTools (80%).

- fixed wildcard imports and missing headers in test classes

Change-Id: Iaf12398e8190089daff248533bc4af1cc82a829e
Signed-off-by: Igor Foltin <igor.foltin@pantheon.sk>
Signed-off-by: Igor Foltin <ifoltin@cisco.com>
8 years agoBug 3799: NPE when including a submodule of a more recent revision than the module 22/26622/7
Peter Kajsa [Mon, 7 Sep 2015 15:12:35 +0000 (17:12 +0200)]
Bug 3799: NPE when including a submodule of a more recent revision than the module

Change-Id: Ieaff77303879d9f9eee4f4ae4840a517ada66a91
Signed-off-by: Peter Kajsa <pkajsa@cisco.com>
8 years agoCleanup a few warnings 90/27490/3
Robert Varga [Sat, 26 Sep 2015 12:38:28 +0000 (14:38 +0200)]
Cleanup a few warnings

Import ordering, methods which can be made static.

Change-Id: I0448e21fde4d54f264429ebbd0928b408d29af65
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoRemove unused imports 41/27941/5
Robert Varga [Sun, 4 Oct 2015 22:21:22 +0000 (00:21 +0200)]
Remove unused imports

Just a drive-by cleanup job.

Change-Id: I2b6620ee970e1bdaf0c2f99a61f089f46817c03f
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoLeafRefUtils is a utility class 65/27565/4
Robert Varga [Tue, 29 Sep 2015 05:34:48 +0000 (07:34 +0200)]
LeafRefUtils is a utility class

Should be final with a private constructor.

Change-Id: I5c45da74cc3cefc51094e3663beba690c08eef9d
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoBug 4349: Allowed UnkeyedListItem to be start event in Writer. 16/28316/2
Tony Tkacik [Tue, 13 Oct 2015 08:13:58 +0000 (10:13 +0200)]
Bug 4349: Allowed UnkeyedListItem to be start event in Writer.

Change-Id: I42fd224974e6fcc691c548978beebce9a6828257
Signed-off-by: Tony Tkacik <ttkacik@cisco.com>
8 years agoBug 4412: New yang parser effective statements cleanup 44/27744/6
Filip Gregor [Fri, 9 Oct 2015 12:43:44 +0000 (14:43 +0200)]
Bug 4412: New yang parser effective statements cleanup

- improved classes hierarchy and reduced source code duplicity
- fixed some major sonar issues

Change-Id: Ibec3da63b0a3ab0616402b52798e9450df7feb70
Signed-off-by: Peter Kajsa <pkajsa@cisco.com>
Signed-off-by: Filip Gregor <filip.gregor@pantheon.sk>
8 years agoBUG-4322: Leafref should not have a default value 53/28253/2
Robert Varga [Sat, 10 Oct 2015 18:05:18 +0000 (20:05 +0200)]
BUG-4322: Leafref should not have a default value

RFC6020 does not mention anything about the default value for leaf
references.

Change-Id: I0edcfe286aa6ac6fd93bb5f0074a51aeb18627d8
Signed-off-by: Robert Varga <nite@hq.sk>
8 years agoBUG-4261: convert JSON parser to pass down SchemaNode information 48/28248/3
Robert Varga [Fri, 9 Oct 2015 17:14:51 +0000 (19:14 +0200)]
BUG-4261: convert JSON parser to pass down SchemaNode information

Change-Id: I2519e3b77d88394c425e79610208a7c8d4a98b9f
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoBUG-4261: make ImmutableNormalizedNodeStreamWriter DataSchemaNodeAware 47/28247/3
Robert Varga [Fri, 9 Oct 2015 17:56:47 +0000 (19:56 +0200)]
BUG-4261: make ImmutableNormalizedNodeStreamWriter DataSchemaNodeAware

ImmutableNormalizedNodeStreamWriter can perform leaf node interning when
it knows what the schema is. Turn it into a DataSchemaNodeAware, so
users can pass down this information and make use of it when adding
leaves.

Change-Id: I7566a8705c0a05ea3cfa1335c7335021de6edccc
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoBUG-4261: introduce DataSchemaNodeAware NormalizedNodeStreamWriter 46/28246/3
Robert Varga [Fri, 9 Oct 2015 16:31:02 +0000 (18:31 +0200)]
BUG-4261: introduce DataSchemaNodeAware NormalizedNodeStreamWriter

This variant allows passing a DataSchemaNode from the user.
Implementations can take advantage of this information to optimize their
result. Utility no-op adaptors are provided, too.

Change-Id: I990197baf3a80f9826cd35d3bb3155d1b7a10cc3
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoBUG-4261; split NormalizedNodeInterners 45/28245/3
Robert Varga [Sat, 10 Oct 2015 11:46:55 +0000 (13:46 +0200)]
BUG-4261; split NormalizedNodeInterners

As it turns out, having separate classes is easier for users.
LeafsetEntryInterner can be used to check the type once and then rely on
this check. LeafInterner returns a no-op instance for convenience if the
schema is not available.

Change-Id: Iec2117be2f91114943d2896a6bfb273f683ea042
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoUse StringBuilder instead of StringWriter 44/28244/2
Robert Varga [Fri, 9 Oct 2015 16:59:31 +0000 (18:59 +0200)]
Use StringBuilder instead of StringWriter

We do not need a Writer interface, as we are simply compositing a
String.

Change-Id: Ied863fe0bf39e99dffe83c2520c56e735d4102d4
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoSuppress Version.nextVersion() warning 43/28243/2
Robert Varga [Fri, 9 Oct 2015 16:31:27 +0000 (18:31 +0200)]
Suppress Version.nextVersion() warning

The method could be static based on the currect implementation, but we
want to keep it an instance-method.

Change-Id: Ibb604f1038e6df9a6731504af67dc7d960dee6bf
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoBUG-4407: Fix a typo in Decimal64 range tables 49/28249/3
Robert Varga [Sat, 10 Oct 2015 13:47:30 +0000 (15:47 +0200)]
BUG-4407: Fix a typo in Decimal64 range tables

Simple typo results in both wrong range enforcement and an out-of-bounds
error with fraction-digits == 18.

Change-Id: I3e9916940e80fbeedadfdc9e8db35b584ea3e859
Signed-off-by: Robert Varga <robert.varga@pantheon.sk>
8 years agoBug 4314: maven plugin: switch logging 54/27354/3
Igor Foltin [Tue, 6 Oct 2015 11:43:45 +0000 (13:43 +0200)]
Bug 4314: maven plugin: switch logging
          to slf4j

Cleaned up use of maven Log in
yang-maven-plugin and switched to
slf4j.

Cleaned up use of static method
Util.message.

Change-Id: I6bf77b761facabfec5ba3a64b193e41b4dfc870f
Signed-off-by: Igor Foltin <igor.foltin@pantheon.sk>
Signed-off-by: Igor Foltin <ifoltin@cisco.com>
8 years agoBug 3899: Increase test coverage for YangTools 45/28045/2
Filip Gregor [Thu, 8 Oct 2015 08:31:10 +0000 (10:31 +0200)]
Bug 3899: Increase test coverage for YangTools
yang-parser rfc6020 effective type test coverage

Change-Id: I2cfc8eab9d52070907d53a8dacd376ffa2a1a170
Signed-off-by: Filip Gregor <filip.gregor@pantheon.sk>
8 years agoBUG-4359: use WRITE-implied metadata 24/27924/3
Robert Varga [Mon, 5 Oct 2015 17:30:13 +0000 (19:30 +0200)]
BUG-4359: use WRITE-implied metadata

When we apply an operation under a WRITE node, we need to look up the
metadata based on that write to correctly understand what the effect of
this operation is.

This is important when we modify data introduced by the WRITE node, as
without this lookup a WRITE/DELETE combination on the child will result
in a NONE logical operation, which means data introduced in the WRITE
node will not be modified and seemingly reappear.

Change-Id: I5a5a67470f1f8baafc7a71069341dead073ba84a
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoBUG-4407: Fix Decimal64 range enforcement 81/27881/4
Robert Varga [Sun, 4 Oct 2015 02:32:00 +0000 (04:32 +0200)]
BUG-4407: Fix Decimal64 range enforcement

Baseline ranges did not take into account the number of fraction digits,
but rather instantiated the most permissive range. Fix this by
pre-calculating all ranges specified in RFC6020 Section 9.3.4.

Also enforce SchemaPath presence, as that is the unique identifier of
the type.

Change-Id: I5e8799da618398ba458606226e71e434f5214f33
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoSpeed-up look up of namespace listeners. 68/27968/1
Tony Tkacik [Tue, 6 Oct 2015 13:55:25 +0000 (15:55 +0200)]
Speed-up look up of namespace listeners.

Change-Id: Ie704318ddabc94cf87ee7902c0185812e721da43
Signed-off-by: Tony Tkacik <ttkacik@cisco.com>
8 years agoFixed shared state in stateless ModuleStatementSupport. 90/27890/3
Tony Tkacik [Mon, 5 Oct 2015 08:42:27 +0000 (10:42 +0200)]
Fixed shared state in stateless ModuleStatementSupport.

Change-Id: I613e71b61038e7354db6a34559b5745baaeb7d09
Signed-off-by: Tony Tkacik <ttkacik@cisco.com>
8 years agoSpeeded up ANTLR tree walk for statement parser. 83/27883/1
Tony Tkacik [Sun, 4 Oct 2015 16:36:32 +0000 (18:36 +0200)]
Speeded up ANTLR tree walk for statement parser.

Change-Id: I49b28a3cb97bb2bb4f0f133d2ed6c97293cf59bd
Signed-off-by: Tony Tkacik <ttkacik@cisco.com>
8 years agoDeprecate InstanceIdentifierTypeDefinition.getRevisionAwareXPath() 82/27882/2
Robert Varga [Sun, 4 Oct 2015 05:14:55 +0000 (07:14 +0200)]
Deprecate InstanceIdentifierTypeDefinition.getRevisionAwareXPath()

This method has been added due to mis-reading of RFC6020. YANG actually
does not define this property, but rather specifies how
instance-identifier types are to be interpreted.

Change-Id: I484b655475f2817277b62dae5fc7462442ebf874
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoUse a proper NamespaceContext for XPaths 58/27858/6
Robert Varga [Fri, 2 Oct 2015 22:43:19 +0000 (00:43 +0200)]
Use a proper NamespaceContext for XPaths

Parsing an XPath which contains namespace prefixes requires a
NamespaceContext. Create a StmtContext-backed implementation and pass it
to XPath before we attempt to parse an XPath string.

Change-Id: Ib28cac2525ffcb6b8e3026e19e431cb9dc86c14b
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoRevert "Revert "Updated SchemaNodeIdentifier namespace handling."" 71/27871/2
Tony Tkacik [Sat, 3 Oct 2015 12:22:49 +0000 (12:22 +0000)]
Revert "Revert "Updated SchemaNodeIdentifier namespace handling.""

Bringing back updated augment lookup and validation code
which turned out to be correct, but unfortunatelly original
implementation of parser (from Hydrogen) accepted incorrect
values and "normalized" them to probably what user really intented.

New code is stricter and did not accept that input, since
it really was unclear what user intented.

Change-Id: I187c3479fd7bbb986f414805401e8b54f6b49ee0
Release-Note: Incompatible-Behaviour
Signed-off-by: Tony Tkacik <ttkacik@cisco.com>
8 years agoCentralize RevisionAwareXPath creation 65/27865/5
Robert Varga [Sat, 3 Oct 2015 01:54:57 +0000 (03:54 +0200)]
Centralize RevisionAwareXPath creation

Three call sites are performing the same thing, create a common method.

Change-Id: I274f23b1785210cef96465e4db944c3b923886a8
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoDo not compile augment/refine/deviate paths 64/27864/6
Robert Varga [Sat, 3 Oct 2015 01:41:35 +0000 (03:41 +0200)]
Do not compile augment/refine/deviate paths

These paths are not full XPaths, but rather SchemaNodeIdentifier paths.
Do not attempt to compile them, as we validate them by splitting and
look up of individual components.

Change-Id: If472ff6a2c795ce810794ad64dc643bf10a24199
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoUse a ThreadLocal XPathFactory 59/27859/8
Robert Varga [Sat, 3 Oct 2015 00:23:18 +0000 (02:23 +0200)]
Use a ThreadLocal XPathFactory

XPathFactory is documented to be non-threadsafe. While we could use
single shared instance, accessing it would require synchronization. Use
a ThreadLocal, so each thread gets its own instance.

Change-Id: I3f6a722df94d261c0680b30b9b65b73566350794
Signed-off-by: Robert Varga <rovarga@cisco.com>