From 7ccaaca230ae4afc4bc4defb927a6e9180342503 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Fri, 24 Feb 2017 14:04:43 +0100 Subject: [PATCH] BUG-7850: SourceIdentifier.getRevision() can return null Fix assumptions which are not in-line with API documentation, i.e. that getRevision() will return a magic string and never null. Once the users are fixed, getRevision() will return null as per its defined contract. Change-Id: Ia7d45325d9f45ff6dc237461fc4ea4d45901675a Signed-off-by: Robert Varga --- .../sal/connect/netconf/NetconfDevice.java | 41 +++++++++---------- ...NetconfRemoteSchemaYangSourceProvider.java | 3 +- 2 files changed, 21 insertions(+), 23 deletions(-) diff --git a/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/NetconfDevice.java b/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/NetconfDevice.java index 04953133a3..520ec3dd27 100644 --- a/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/NetconfDevice.java +++ b/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/NetconfDevice.java @@ -79,13 +79,9 @@ public class NetconfDevice implements RemoteDevice QNAME_TO_SOURCE_ID_FUNCTION = new Function() { - @Override - public SourceIdentifier apply(final QName input) { - return RevisionSourceIdentifier - .create(input.getLocalName(), Optional.fromNullable(input.getFormattedRevision())); - } - }; + public static final Function QNAME_TO_SOURCE_ID_FUNCTION = + input -> RevisionSourceIdentifier.create(input.getLocalName(), + Optional.fromNullable(input.getFormattedRevision())); protected final RemoteDeviceId id; private final boolean reconnectOnSchemasChange; @@ -168,8 +164,9 @@ public class NetconfDevice implements RemoteDevice rpcResultListenableFuture = - deviceRpc.invokeRpc(NetconfMessageTransformUtil.toPath(NetconfMessageTransformUtil.CREATE_SUBSCRIPTION_RPC_QNAME), NetconfMessageTransformUtil.CREATE_SUBSCRIPTION_RPC_CONTENT); + final CheckedFuture rpcResultListenableFuture = deviceRpc.invokeRpc( + NetconfMessageTransformUtil.toPath(NetconfMessageTransformUtil.CREATE_SUBSCRIPTION_RPC_QNAME), + NetconfMessageTransformUtil.CREATE_SUBSCRIPTION_RPC_CONTENT); final NotificationHandler.NotificationFilter filter = new NotificationHandler.NotificationFilter() { @Override @@ -534,12 +531,7 @@ public class NetconfDevice implements RemoteDevice getQNameFromSourceIdentifiers(final Collection identifiers) { - final Collection qNames = Collections2.transform(identifiers, new Function() { - @Override - public QName apply(final SourceIdentifier sourceIdentifier) { - return getQNameFromSourceIdentifier(sourceIdentifier); - } - }); + final Collection qNames = Collections2.transform(identifiers, this::getQNameFromSourceIdentifier); if (qNames.isEmpty()) { LOG.debug("{}: Unable to map any source identifiers to a capability reported by device : {}", id, identifiers); @@ -550,16 +542,16 @@ public class NetconfDevice implements RemoteDevice revision = Optional.fromNullable(formattedRevision); final NormalizedNode getSchemaRequest = createGetSchemaRequest(moduleName, revision); -- 2.36.6