From 1af3f672250584a51ad463174c520448bff73cdb Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Fri, 13 Oct 2017 11:00:03 +0200 Subject: [PATCH] Fix augmentation node lookup This fixes an issue where we erroneously checked instanceof against optional rather than its content -- which is obviously wrong. Change-Id: I1b60d35c5ca85444fd7f6595606e82f72f06f1d4 Signed-off-by: Robert Varga --- .../netconf/sal/restconf/impl/RestconfImpl.java | 14 +++++++++----- .../nb/rfc8040/rests/utils/CreateStreamUtil.java | 15 +++++++++------ 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/restconf/impl/RestconfImpl.java b/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/restconf/impl/RestconfImpl.java index 818e76844e..090e861eef 100644 --- a/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/restconf/impl/RestconfImpl.java +++ b/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/restconf/impl/RestconfImpl.java @@ -1347,13 +1347,17 @@ public class RestconfImpl implements RestconfService { */ private static T parseEnumTypeParameter(final ContainerNode value, final Class classDescriptor, final String paramName) { - final Optional> augNode = - value.getChild(SAL_REMOTE_AUG_IDENTIFIER); - if (!augNode.isPresent() && !(augNode instanceof AugmentationNode)) { + final Optional> optAugNode = value.getChild( + SAL_REMOTE_AUG_IDENTIFIER); + if (!optAugNode.isPresent()) { return null; } - final Optional> enumNode = ((AugmentationNode) augNode.get()) - .getChild(new NodeIdentifier(QName.create(SAL_REMOTE_AUGMENT, paramName))); + final DataContainerChild augNode = optAugNode.get(); + if (!(augNode instanceof AugmentationNode)) { + return null; + } + final Optional> enumNode = ((AugmentationNode) augNode).getChild( + new NodeIdentifier(QName.create(SAL_REMOTE_AUGMENT, paramName))); if (!enumNode.isPresent()) { return null; } diff --git a/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/rests/utils/CreateStreamUtil.java b/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/rests/utils/CreateStreamUtil.java index 3459036502..3986598cff 100644 --- a/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/rests/utils/CreateStreamUtil.java +++ b/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/rests/utils/CreateStreamUtil.java @@ -149,14 +149,17 @@ public final class CreateStreamUtil { } private static T parseEnum(final ContainerNode data, final Class clazz, final String paramName) { - final Optional> augNode = data - .getChild(RestconfStreamsConstants.SAL_REMOTE_AUG_IDENTIFIER); - if (!augNode.isPresent() && !(augNode instanceof AugmentationNode)) { + final Optional> optAugNode = data.getChild( + RestconfStreamsConstants.SAL_REMOTE_AUG_IDENTIFIER); + if (!optAugNode.isPresent()) { return null; } - final Optional> enumNode = - ((AugmentationNode) augNode.get()).getChild( - new NodeIdentifier(QName.create(RestconfStreamsConstants.SAL_REMOTE_AUGMENT, paramName))); + final DataContainerChild augNode = optAugNode.get(); + if (!(augNode instanceof AugmentationNode)) { + return null; + } + final Optional> enumNode = ((AugmentationNode) augNode).getChild( + new NodeIdentifier(QName.create(RestconfStreamsConstants.SAL_REMOTE_AUGMENT, paramName))); if (!enumNode.isPresent()) { return null; } -- 2.36.6