Fix NPE in YangTextSchemaSourceSerializationProxy#getRepresentation 37/52337/4
authorJakub Morvay <jmorvay@cisco.com>
Tue, 28 Feb 2017 07:28:01 +0000 (08:28 +0100)
committerTom Pantelis <tpanteli@brocade.com>
Tue, 28 Feb 2017 11:52:53 +0000 (11:52 +0000)
According to its general contract, when revision is not found,
SourceIdentifier#getRevision method returns null. Wrap revision in
Optional#fromNullable to avoid possible NPE.

Change-Id: I78f544374f179c9486cc8dd09cbcf1eea379e1e9
Signed-off-by: Jakub Morvay <jmorvay@cisco.com>
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/schema/provider/impl/YangTextSchemaSourceSerializationProxy.java

index 6e6c6a8..39302e4 100644 (file)
@@ -34,7 +34,7 @@ public class YangTextSchemaSourceSerializationProxy implements Serializable {
     }
 
     public YangTextSchemaSource getRepresentation() {
-        return YangTextSchemaSource.delegateForByteSource(RevisionSourceIdentifier.create(name, Optional.of(revision)),
-            ByteSource.wrap(schemaSource));
+        return YangTextSchemaSource.delegateForByteSource(
+                RevisionSourceIdentifier.create(name, Optional.fromNullable(revision)), ByteSource.wrap(schemaSource));
     }
 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.