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 6e6c6a88f1086370b8a8a4073b361eb3c94310ef..39302e4f5621865130ef2c307843095af93862ae 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));
     }
 }