Bug 7901: Prevent null Modification in BatchedModifications 83/52883/4
authorTom Pantelis <tpanteli@brocade.com>
Mon, 6 Mar 2017 13:44:41 +0000 (08:44 -0500)
committerTom Pantelis <tpanteli@brocade.com>
Thu, 9 Mar 2017 11:41:51 +0000 (11:41 +0000)
commit8f2b69d0944fe8ebc7e4300bb7a05265c7c290d7
tree3df97e87223c49b587a89471d835bb877661353e
parent88852df542314ff2cb6f3669f4a2e1018e664769
Bug 7901: Prevent null Modification in BatchedModifications

Caused by: java.lang.NullPointerException
   at org.opendaylight.controller.cluster.datastore.modification.
      MutableCompositeModification.writeExternal(MutableCompositeModification.java:120)

Somehow a null Modification instance got added to the modifications List.
Looking at the callers of addModification, it is not clear which call site
might have been the culprit. So I added a guard in addModification against
a null input Modification and logged an error with stack trace. I also
modified getModifications to return an immutable List to prevent callers
from directly modifying the List (there was one).

Change-Id: Ic63aa9daada0548da05fe663a0d22cdcb3e7bceb
Signed-off-by: Tom Pantelis <tpanteli@brocade.com>
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/RemoteTransactionContext.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/entityownership/EntityOwnershipShardCommitCoordinator.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/CompositeModification.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/MutableCompositeModification.java