Add an explicit null data check 52/62652/3
authorRobert Varga <robert.varga@pantheon.tech>
Mon, 4 Sep 2017 20:38:11 +0000 (22:38 +0200)
committerStephen Kitt <skitt@redhat.com>
Tue, 5 Sep 2017 08:37:35 +0000 (08:37 +0000)
We have observed restconf attempting to put null data into a path,
leading to an implicit NPE without any explanation. Add an explicit
guard to catch such attempts.

Change-Id: I2e2125b04782d4f1c050d0aeb72161158da28c9f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/AbstractDOMBrokerWriteTransaction.java

index 0fe26ed48dae5d8b68dc41f22c617ea78d3da8bd..5dd8bd3e3ed7fcb0b42b3fd3acb6a32f2f229d65 100644 (file)
@@ -82,6 +82,7 @@ public abstract class AbstractDOMBrokerWriteTransaction<T extends DOMStoreWriteT
 
     private static void checkInstanceIdentifierReferencesData(final YangInstanceIdentifier path,
             final NormalizedNode<?, ?> data) {
 
     private static void checkInstanceIdentifierReferencesData(final YangInstanceIdentifier path,
             final NormalizedNode<?, ?> data) {
+        Preconditions.checkArgument(data != null, "Attempted to store null data at %s", path);
         final PathArgument lastArg = path.getLastPathArgument();
         Preconditions.checkArgument(
                 lastArg == data.getIdentifier() || lastArg != null && lastArg.equals(data.getIdentifier()),
         final PathArgument lastArg = path.getLastPathArgument();
         Preconditions.checkArgument(
                 lastArg == data.getIdentifier() || lastArg != null && lastArg.equals(data.getIdentifier()),