Enable spotbugs in mdsal-{binding,dom}-spi
[mdsal.git] / dom / mdsal-dom-spi / src / main / java / org / opendaylight / mdsal / dom / spi / shard / DOMDataTreeListenerAggregator.java
index 98b1905c08c07cb755c900d7ab1cf61d47a1fcc4..7d5a74adcc14d2b59668edc93c96b1493c1473ca 100644 (file)
@@ -7,8 +7,9 @@
  */
 package org.opendaylight.mdsal.dom.spi.shard;
 
+import static java.util.Objects.requireNonNull;
+
 import com.google.common.annotations.Beta;
-import com.google.common.base.Preconditions;
 import com.google.common.base.Stopwatch;
 import com.google.common.base.Verify;
 import com.google.common.collect.ImmutableList;
@@ -58,9 +59,9 @@ public final class DOMDataTreeListenerAggregator
         Aggregated(final Collection<DataTreeCandidate> changes,
             final Map<DOMDataTreeIdentifier, NormalizedNode<?, ?>> subtrees,
             final Collection<DOMDataTreeListeningException> failures) {
-            this.changes = Preconditions.checkNotNull(changes);
-            this.subtrees = Preconditions.checkNotNull(subtrees);
-            this.failures = Preconditions.checkNotNull(failures);
+            this.changes = requireNonNull(changes);
+            this.subtrees = requireNonNull(subtrees);
+            this.failures = requireNonNull(failures);
         }
     }
 
@@ -70,8 +71,8 @@ public final class DOMDataTreeListenerAggregator
 
         Changes(final Collection<DataTreeCandidate> changes,
             final Map<DOMDataTreeIdentifier, NormalizedNode<?, ?>> subtrees) {
-            this.changes = Preconditions.checkNotNull(changes);
-            this.subtrees = Preconditions.checkNotNull(subtrees);
+            this.changes = requireNonNull(changes);
+            this.subtrees = requireNonNull(subtrees);
         }
     }
 
@@ -79,7 +80,7 @@ public final class DOMDataTreeListenerAggregator
         final Collection<DOMDataTreeListeningException> causes;
 
         Failure(final Collection<DOMDataTreeListeningException> causes) {
-            this.causes = Preconditions.checkNotNull(causes);
+            this.causes = requireNonNull(causes);
         }
     }
 
@@ -92,11 +93,11 @@ public final class DOMDataTreeListenerAggregator
         private Map<DOMDataTreeIdentifier, NormalizedNode<?, ?>> subtrees = ImmutableMap.of();
 
         @Override
-        protected void append(final State state) {
+        protected synchronized void append(final State state) {
             if (state instanceof Changes) {
-                final Changes changes = (Changes) state;
-                this.changes.addAll(changes.changes);
-                subtrees = ImmutableMap.copyOf(changes.subtrees);
+                final Changes changesState = (Changes) state;
+                this.changes.addAll(changesState.changes);
+                subtrees = ImmutableMap.copyOf(changesState.subtrees);
             } else if (state instanceof Failure) {
                 causes.addAll(((Failure) state).causes);
             } else {
@@ -108,9 +109,9 @@ public final class DOMDataTreeListenerAggregator
         protected synchronized void appendInitial(final State state) {
             // TODO: we could index and compress state changes here
             if (state instanceof Changes) {
-                final Changes changes = (Changes) state;
-                this.changes.addAll(changes.changes);
-                subtrees = ImmutableMap.copyOf(changes.subtrees);
+                final Changes changesState = (Changes) state;
+                this.changes.addAll(changesState.changes);
+                subtrees = ImmutableMap.copyOf(changesState.subtrees);
             } else if (state instanceof Failure) {
                 causes.addAll(((Failure) state).causes);
             } else {
@@ -135,13 +136,13 @@ public final class DOMDataTreeListenerAggregator
         Operational(final Collection<AbstractStateAggregator.StateBuilder<State>> builders,
                 final DOMDataTreeListener listener) {
             super(builders);
-            this.listener = Preconditions.checkNotNull(listener);
+            this.listener = requireNonNull(listener);
         }
 
         @Override
         protected void notifyListener(final Iterator<State> iterator) {
             if (failed) {
-                iterator.forEachRemaining(state -> LOG.debug("Listener {} failed, ignoring state {}", state));
+                iterator.forEachRemaining(state -> LOG.debug("Listener {} failed, ignoring state {}", listener, state));
                 return;
             }