From: Jakub Morvay Date: Tue, 28 Feb 2017 07:28:01 +0000 (+0100) Subject: Fix NPE in YangTextSchemaSourceSerializationProxy#getRepresentation X-Git-Tag: release/carbon~244 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=40723a37cc98de6c7dc396ca2558f7ef51e7337a;hp=271e66acd1391895c006806dfe76ae6d09017a83 Fix NPE in YangTextSchemaSourceSerializationProxy#getRepresentation 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 --- diff --git a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/schema/provider/impl/YangTextSchemaSourceSerializationProxy.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/schema/provider/impl/YangTextSchemaSourceSerializationProxy.java index 6e6c6a88f1..39302e4f56 100644 --- a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/schema/provider/impl/YangTextSchemaSourceSerializationProxy.java +++ b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/schema/provider/impl/YangTextSchemaSourceSerializationProxy.java @@ -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)); } }