Fix an eclipse nullness warning 24/77824/1
authorRobert Varga <robert.varga@pantheon.tech>
Wed, 14 Nov 2018 21:14:43 +0000 (22:14 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Wed, 14 Nov 2018 21:14:43 +0000 (22:14 +0100)
Eclipse (rightfully) flags this access as potentiall null. Since
we are invoking an interface getter, it is not statically known that
the two invocations will return the same value.

Cache the second field access in a local variable, which ensures
we access the property exactly once, which keeps eclipse happy.

In case the implementation LazyDataObjectModification, this has
the benefit of not deserializing twice.

Change-Id: Idfb8c631bc0267a63710c2cb650e6bda1c227df3
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/LocRibWriter.java

index 8f80cb871d309d5617c00888b84dd4fdcaa08ad4..5e03801026c463677e885be523ace22a1951405b 100644 (file)
@@ -270,10 +270,12 @@ final class LocRibWriter<C extends Routes & DataObject & ChoiceIn<Tables>, S ext
 
         final DataObjectModification<Attributes> attUpdate = table.getModifiedChildContainer(Attributes.class);
 
-        if (attUpdate != null && attUpdate.getDataAfter() != null) {
+        if (attUpdate != null) {
             final Attributes newAttValue = attUpdate.getDataAfter();
-            LOG.trace("Uptodate found for {}", newAttValue);
-            tx.put(LogicalDatastoreType.OPERATIONAL, this.locRibTableIID.child(Attributes.class), newAttValue);
+            if (newAttValue != null) {
+                LOG.trace("Uptodate found for {}", newAttValue);
+                tx.put(LogicalDatastoreType.OPERATIONAL, this.locRibTableIID.child(Attributes.class), newAttValue);
+            }
         }
 
         final DataObjectModification<S> routesChangesContainer