[YANGTOOLS-122] Failed to maps instance-identifier (XML node) into Java InstanceIdentifier Created: 26/Mar/14  Updated: 10/Apr/22  Due: 15/Apr/14  Resolved: 23/Apr/14

Status: Resolved
Project: yangtools
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug
Reporter: Milos Fabian Assignee: Unassigned
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Operating System: Linux
Platform: PC


Attachments: Java Source File RestconfUtilsTest.java     File notification.xml    
Issue Links:
Blocks
blocks CONTROLLER-227 Websockets: Test & fix data change no... Resolved
External issue ID: 595

 Description   

java.lang.ClassCastException: java.lang.String cannot be cast to org.opendaylight.yangtools.yang.data.api.InstanceIdentifier

yang module snippet:
leaf path {
type instance-identifier;
}

xml input snippet:
<path xmlns:topo="urn:TBD:params:xml:ns:yang:network-topology">/topo:network-topology/topo:topology[topo:topology-id="pcep-topology"]</path>



 Comments   
Comment by Milos Fabian [ 26/Mar/14 ]

test code:

private RuntimeGeneratedMappingServiceImpl mappingService;

@Before
public void setup()

{ this.mappingService = new RuntimeGeneratedMappingServiceImpl(); this.mappingService.setPool(new ClassPool()); this.mappingService.init(); final ModuleInfoBackedContext moduleInfo = ModuleInfoBackedContext.create(); moduleInfo.addModuleInfos(BindingReflections.loadModuleInfos()); this.mappingService.onGlobalContextUpdated(moduleInfo.tryToCreateSchemaContext().get()); }

@Test
public void testNotificationTransformation() throws Exception

{ YangModuleInfo moduleInfo = BindingReflections.getModuleInfo(DataChangedNotification.class); Module module = mappingService.getSchemaContext().findModuleByName(moduleInfo.getName(),org.opendaylight.yangtools.yang.common.QName.parseRevision(moduleInfo.getRevision())); Document doc = XmlTools.fromXml(getClass().getClassLoader().getResourceAsStream("notification.xml")); CompositeNode cn = XmlDocumentUtils.notificationToDomNodes(doc, Optional.of(module.getNotifications())); DataChangedNotification notification = (DataChangedNotification) this.mappingService.dataObjectFromDataDom(DataChangedNotification.class, cn); assertTrue(notification.getDataChangeEvent().size() > 0); }
Comment by Milos Fabian [ 26/Mar/14 ]

Attachment notification.xml has been added with description: test input xml

Comment by Milos Fabian [ 26/Mar/14 ]

Attachment RestconfUtilsTest.java has been added with description: test java class

Comment by Milos Fabian [ 26/Mar/14 ]

(In reply to Milos Fabian from comment #3)
> Created attachment 79 [details]
> test java class

required dependency:
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>sal-remote</artifactId>
<version>1.1-SNAPSHOT</version>
<scope>test</scope>
</dependency>

Comment by Robert Varga [ 09/Apr/14 ]

Bump importance, this is blocking RESTCONF broker usability.

Comment by Jozef Gloncak [ 10/Apr/14 ]

Conversion of String to InstanceIdentifier was added. See
https://git.opendaylight.org/gerrit/#/c/6021/

Curently test specified above is falling on LazyGeneratedCodecRegistry.getClassForPath()

See stack trace:
Caused by: java.lang.NullPointerException
at org.opendaylight.yangtools.sal.binding.generator.impl.LazyGeneratedCodecRegistry.getClassForPath(LazyGeneratedCodecRegistry.java:229)
at org.opendaylight.yangtools.sal.binding.generator.impl.InstanceIdentifierCodecImpl._deserializePathArgument(InstanceIdentifierCodecImpl.java:90)
at org.opendaylight.yangtools.sal.binding.generator.impl.InstanceIdentifierCodecImpl.deserializePathArgument(InstanceIdentifierCodecImpl.java:189)
at org.opendaylight.yangtools.sal.binding.generator.impl.InstanceIdentifierCodecImpl.deserialize(InstanceIdentifierCodecImpl.java:69)
at org.opendaylight.yangtools.sal.binding.generator.impl.InstanceIdentifierCodecImpl.deserialize(InstanceIdentifierCodecImpl.java:47)
----- OMITTED -----------

Comment by Jozef Gloncak [ 10/Apr/14 ]

String representation of InstanceIdentifier (from enclosed namespace.xml)
topo="urn:TBD:params:xml:ns:yang:network-topology

Regarding creating of InstanceIdentifier from string maybe some of this question should be also solved:

  • if in xml is specified namespace which revision of module should be used? Currently is used youngest yang module
  • what instances of PathArgument should be used in InstanceIdentifier? Currently is used InstanceIdentifier.NodeIdentifier and InstanceIdentifier.NodeIdentifierWithPredicates.
Comment by Jozef Gloncak [ 10/Apr/14 ]

Under
https://git.opendaylight.org/gerrit/#/c/6021/
there are:

  • patch set 2 - solution with independent InstanceIdentifierParser
  • patch set 3 - solution where InstanceIdentifierCodecStringImpl is added to TypeDefinitionAwareCodec
Comment by Jozef Gloncak [ 15/Apr/14 ]

https://git.opendaylight.org/gerrit/#/c/6192/

  • patch set contains standalone codec for InstanceIdentifier type with serialize and deserialize methods implemented which is part of TypeDefinitionAwareCodec class.
Comment by Tony Tkacik [ 16/Apr/14 ]

DOM part of the codec was merged into master.

Generated at Wed Feb 07 20:52:19 UTC 2024 using Jira 8.20.10#820010-sha1:ace47f9899e9ee25d7157d59aa17ab06aee30d3d.