Closed RimShao closed 4 years ago
Hi,
Problem can be reproduced for a deviate replace statement, referencing another module as shown by the following two modules::
module ericsson-certm-ext-sgsn-mme {
yang-version 1.1;
namespace "urn:rdns:com:ericsson:oammodel:ericsson-certm-ext-sgsn-mme";
prefix certmxsgsnmme;
import ietf-yang-types {
prefix yang;
}
import ericsson-certm-sgsn-mme {
prefix ecertm;
}
revision "2019-01-24";
deviation /ecertm:certm/ecertm:user-label {
deviate replace {
type yang:date-and-time;
}
}
}
module ericsson-certm-sgsn-mme {
yang-version 1.1;
namespace "urn:rdns:com:ericsson:oammodel:ericsson-certm-sgsn-mme";
prefix ecertm;
revision "2019-08-21";
container certm {
leaf user-label {
type string;
description "Label for free use. An additional descriptive text.";
}
}
}
The following test code...
@Test
def void testExposeScopeContextProviderNPE_2() {
copyAll(dir, "ScopingNPETestModels2")
val yangFile1 = new File(dir, "ericsson-certm-ext-sgsn-mme.yang")
val URI yangFileURI = URI.createFileURI(yangFile1.canonicalPath)
val injector = XTextInjector.getInstance()
val xtextResourceSet = injector.getInstance(XtextResourceSet)
val resource = xtextResourceSet.getResource(yangFileURI, true)
val module = resource.contents?.get(0) as AbstractModule
println(module)
EcoreUtil.resolveAll(module)
}
throws the exception:
[20-04-27 21:12:55.611] ERROR LazyLinkingResource:getEObject:241 - resolution of uriFragment '|3' failed.
java.lang.NullPointerException
at io.typefox.yang.scoping.ScopeContextProvider.lambda$internalLinkNode$4(ScopeContextProvider.java:409)
at io.typefox.yang.scoping.Linker.link(Linker.java:46)
at io.typefox.yang.scoping.ScopeContextProvider.internalLinkNode(ScopeContextProvider.java:411)
at io.typefox.yang.scoping.ScopeContextProvider.internalLinkNode(ScopeContextProvider.java:405)
at io.typefox.yang.scoping.ScopeContextProvider.lambda$doLinkNodeLater$3(ScopeContextProvider.java:396)
at io.typefox.yang.scoping.ScopeContext.lambda$resolveAll$12(ScopeContext.java:438)
at java.util.ArrayList.forEach(Unknown Source)
at io.typefox.yang.scoping.ScopeContext.resolveAll(ScopeContext.java:440)
at io.typefox.yang.resource.YangResource.getEObject(YangResource.java:39)
at org.eclipse.xtext.linking.lazy.LazyLinkingResource.getEObject(LazyLinkingResource.java:236)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getEObject(ResourceSetImpl.java:223)
at org.eclipse.emf.ecore.util.EcoreUtil.resolve(EcoreUtil.java:199)
at org.eclipse.emf.ecore.util.EcoreUtil.resolve(EcoreUtil.java:259)
...
Thanks, Andreas
Notice that it is the referencing of another module inside the deviate replace statement that causes the problem. If you replace with a built-in type everything is fine.
I also face this issue. I'm attaching my stracktrace as well if that helps:
[Error - 11:48:58 AM] resolution of uriFragment '|34' failed.: java.lang.NullPointerException at io.typefox.yang.scoping.xpath.XpathResolver.isInstanceNode(XpathResolver.java:934) at io.typefox.yang.scoping.xpath.XpathResolver$1.computeNext(XpathResolver.java:913) at io.typefox.yang.scoping.xpath.XpathResolver$1.computeNext(XpathResolver.java:892) at com.google.common.collect.AbstractIterator.tryToComputeNext(AbstractIterator.java:141) at com.google.common.collect.AbstractIterator.hasNext(AbstractIterator.java:136) at com.google.common.collect.Iterators$5.computeNext(Iterators.java:635) at com.google.common.collect.AbstractIterator.tryToComputeNext(AbstractIterator.java:141) at com.google.common.collect.AbstractIterator.hasNext(AbstractIterator.java:136) at org.eclipse.xtext.xbase.lib.IterableExtensions.isEmpty(IterableExtensions.java:525) at io.typefox.yang.scoping.xpath.XpathResolver.lambda$findNodes$8(XpathResolver.java:853) at org.eclipse.xtext.xbase.lib.internal.BooleanFunctionDelegate.apply(BooleanFunctionDelegate.java:41) at com.google.common.collect.Iterators$5.computeNext(Iterators.java:637) at com.google.common.collect.AbstractIterator.tryToComputeNext(AbstractIterator.java:141) at com.google.common.collect.AbstractIterator.hasNext(AbstractIterator.java:136) at com.google.common.collect.Iterators.addAll(Iterators.java:355) at com.google.common.collect.Iterables.addAll(Iterables.java:320) at com.google.common.collect.Sets.newLinkedHashSet(Sets.java:365) at org.eclipse.xtext.xbase.lib.IterableExtensions.toSet(IterableExtensions.java:639) at io.typefox.yang.scoping.xpath.XpathResolver.findNodes(XpathResolver.java:859) at io.typefox.yang.scoping.xpath.XpathResolver.computeType(XpathResolver.java:791) at io.typefox.yang.scoping.xpath.XpathResolver.lambda$_internalResolveStep$5(XpathResolver.java:721) at io.typefox.yang.scoping.Linker.link(Linker.java:46) at io.typefox.yang.scoping.xpath.XpathResolver._internalResolveStep(XpathResolver.java:725) at io.typefox.yang.scoping.xpath.XpathResolver.internalResolveStep(XpathResolver.java:1022) at io.typefox.yang.scoping.xpath.XpathResolver._internalResolve(XpathResolver.java:396) at io.typefox.yang.scoping.xpath.XpathResolver.internalResolve(XpathResolver.java:987) at io.typefox.yang.scoping.xpath.XpathResolver._internalResolve(XpathResolver.java:395) at io.typefox.yang.scoping.xpath.XpathResolver.internalResolve(XpathResolver.java:987) at io.typefox.yang.scoping.xpath.XpathResolver.doResolve(XpathResolver.java:328) at io.typefox.yang.scoping.ScopeContextProvider.lambda$_computeScope$21(ScopeContextProvider.java:646) at io.typefox.yang.scoping.ScopeContext.lambda$resolveAll$12(ScopeContext.java:426) at java.base/java.util.ArrayList.forEach(ArrayList.java:1540) at io.typefox.yang.scoping.ScopeContext.resolveAll(ScopeContext.java:428) at io.typefox.yang.resource.YangResource.getEObject(YangResource.java:39) at org.eclipse.xtext.linking.lazy.LazyLinkingResource.getEObject(LazyLinkingResource.java:236) at org.eclipse.xtext.linking.lazy.LazyLinkingResource.doResolveLazyCrossReference(LazyLinkingResource.java:203) at org.eclipse.xtext.linking.lazy.LazyLinkingResource.resolveLazyCrossReference(LazyLinkingResource.java:162) at org.eclipse.xtext.linking.lazy.LazyLinkingResource.resolveLazyCrossReferences(LazyLinkingResource.java:148) at org.eclipse.xtext.EcoreUtil2.resolveLazyCrossReferences(EcoreUtil2.java:504) at org.eclipse.xtext.build.IncrementalBuilder$InternalStatefulIncrementalBuilder.lambda$launch$2(IncrementalBuilder.java:265) at com.google.common.collect.Iterators$6.transform(Iterators.java:783) at com.google.common.collect.TransformedIterator.next(TransformedIterator.java:47) at com.google.common.collect.FluentIterable.copyInto(FluentIterable.java:791) at org.eclipse.xtext.build.ClusteringStorageAwareResourceLoader.executeClustered(ClusteringStorageAwareResourceLoader.java:68) at org.eclipse.xtext.build.BuildContext.executeClustered(BuildContext.java:54) at org.eclipse.xtext.build.IncrementalBuilder$InternalStatefulIncrementalBuilder.launch(IncrementalBuilder.java:258) at org.eclipse.xtext.build.IncrementalBuilder.build(IncrementalBuilder.java:403) at org.eclipse.xtext.build.IncrementalBuilder.build(IncrementalBuilder.java:385) at org.eclipse.xtext.ide.server.ProjectManager.doBuild(ProjectManager.java:105) at org.eclipse.xtext.ide.server.BuildManager.internalBuild(BuildManager.java:198) at org.eclipse.xtext.ide.server.WorkspaceManager.lambda$didChangeFiles$1(WorkspaceManager.java:218) at org.eclipse.xtext.ide.server.LanguageServerImpl.lambda$runBuildable$15(LanguageServerImpl.java:441) at org.eclipse.xtext.ide.server.concurrent.WriteRequest.run(WriteRequest.java:40) at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) at java.base/java.lang.Thread.run(Thread.java:835) [Error - 11:48:58 AM] java.lang.IllegalStateException: getReferenceDescriptionsfile:///Users/bmigette/NSO/4.7.5/src/ncs/yang/tailf-ncs-devices.yang: java.lang.IllegalStateException: getReferenceDescriptionsfile:///Users/bmigette/NSO/4.7.5/src/ncs/yang/tailf-ncs-devices.yang at org.eclipse.xtext.build.Indexer$ResolvedResourceDescription.getReferenceDescriptions(Indexer.java:165) at io.typefox.yang.findReferences.YangReferenceFinder.lambda$null$0(YangReferenceFinder.java:93) at org.eclipse.xtext.xbase.lib.internal.FunctionDelegate.apply(FunctionDelegate.java:42) at com.google.common.collect.Iterables$5.lambda$forEach$0(Iterables.java:704) at java.base/java.lang.Iterable.forEach(Iterable.java:75) at com.google.common.collect.Iterables$5.forEach(Iterables.java:704) at io.typefox.yang.findReferences.YangReferenceFinder.lambda$collectReferences$3(YangReferenceFinder.java:101) at org.eclipse.xtext.util.OnChangeEvictingCache.get(OnChangeEvictingCache.java:76) at io.typefox.yang.findReferences.YangReferenceFinder.collectReferences(YangReferenceFinder.java:107) at io.typefox.yang.ide.codelens.CodeLensService.computeCodeLenses(CodeLensService.java:58) at org.eclipse.xtext.ide.server.LanguageServerImpl.lambda$codeLens$38(LanguageServerImpl.java:833) at org.eclipse.xtext.ide.server.WorkspaceManager.doRead(WorkspaceManager.java:412) at org.eclipse.xtext.ide.server.LanguageServerImpl.codeLens(LanguageServerImpl.java:832) at org.eclipse.xtext.ide.server.LanguageServerImpl.lambda$codeLens$37(LanguageServerImpl.java:819) at org.eclipse.xtext.ide.server.concurrent.ReadRequest.lambda$run$0(ReadRequest.java:37) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) at java.base/java.lang.Thread.run(Thread.java:835)
The reason was a too fragile solution for #156. I implemented a different solution now.
Hi Miro,
We found NullPointerException in our deviation test cases, if we remove deviation statement from test model then test cases work fine. the test model is attached ericsson-certm-mynode-yang.txt
20-04-20 15:34:45.694 ERROR LazyLinkingResource:241 - resolution of uriFragment '|1' failed. java.lang.NullPointerException at io.typefox.yang.scoping.ScopeContextProvider.lambda$internalLinkNode$4(ScopeContextProvider.java:411) at io.typefox.yang.scoping.Linker.link(Linker.java:46) at io.typefox.yang.scoping.ScopeContextProvider.internalLinkNode(ScopeContextProvider.java:413) at io.typefox.yang.scoping.ScopeContextProvider.lambda$doLinkNodeLater$3(ScopeContextProvider.java:398) at io.typefox.yang.scoping.ScopeContext.lambda$resolveAll$12(ScopeContext.java:426) at java.util.ArrayList.forEach(Unknown Source) at io.typefox.yang.scoping.ScopeContext.resolveAll(ScopeContext.java:428) at io.typefox.yang.resource.YangResource.getEObject(YangResource.java:39) at org.eclipse.xtext.linking.lazy.LazyLinkingResource.getEObject(LazyLinkingResource.java:236) at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getEObject(ResourceSetImpl.java:223) at org.eclipse.emf.ecore.util.EcoreUtil.resolve(EcoreUtil.java:199) at org.eclipse.emf.ecore.util.EcoreUtil.resolve(EcoreUtil.java:259) at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eResolveProxy(BasicEObjectImpl.java:1477) at io.typefox.yang.yang.impl.SchemaNodeIdentifierImpl.getSchemaNode(SchemaNodeIdentifierImpl.java:155) at io.typefox.yang.scoping.ScopeContextProvider.lambda$handleGeneric$22(ScopeContextProvider.java:719) at io.typefox.yang.scoping.ForwardingScopeContext.resolve(ForwardingScopeContext.java:25) at io.typefox.yang.scoping.ForwardingScopeContext.getExtensionScope(ForwardingScopeContext.java:73) at io.typefox.yang.scoping.ScopeContextProvider.lambda$null$14(ScopeContextProvider.java:592) at io.typefox.yang.scoping.Linker.link(Linker.java:46) at io.typefox.yang.scoping.ScopeContextProvider.lambda$_computeScope$15(ScopeContextProvider.java:594) at io.typefox.yang.scoping.ScopeContext.lambda$resolveDefinitionPhase$10(ScopeContext.java:403) at java.util.ArrayList.forEach(Unknown Source) at io.typefox.yang.scoping.ScopeContext.resolveDefinitionPhase(ScopeContext.java:405) at io.typefox.yang.resource.YangResource.getEObject(YangResource.java:42) at org.eclipse.xtext.linking.lazy.LazyLinkingResource.getEObject(LazyLinkingResource.java:236) at org.eclipse.xtext.linking.lazy.LazyLinkingResource.doResolveLazyCrossReference(LazyLinkingResource.java:203) at org.eclipse.xtext.linking.lazy.LazyLinkingResource.resolveLazyCrossReference(LazyLinkingResource.java:162) at org.eclipse.xtext.linking.lazy.LazyLinkingResource.resolveLazyCrossReferences(LazyLinkingResource.java:148) at org.eclipse.xtext.EcoreUtil2.resolveLazyCrossReferences(EcoreUtil2.java:504)