Fix findbugs violations in applications
[openflowplugin.git] / applications / forwardingrules-sync / src / main / java / org / opendaylight / openflowplugin / applications / frsync / impl / SyncReactorRetryDecorator.java
index 9ab76dfe19847b074e9949f694039d78b808005f..102e37000052d2266851388167f324188c39cb11 100644 (file)
@@ -8,9 +8,9 @@
 
 package org.opendaylight.openflowplugin.applications.frsync.impl;
 
-import com.google.common.base.Function;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
+import com.google.common.util.concurrent.MoreExecutors;
 import org.opendaylight.openflowplugin.applications.frsync.SyncReactor;
 import org.opendaylight.openflowplugin.applications.frsync.util.PathUtil;
 import org.opendaylight.openflowplugin.applications.frsync.util.ReconciliationRegistry;
@@ -27,7 +27,6 @@ import org.slf4j.LoggerFactory;
 public class SyncReactorRetryDecorator implements SyncReactor {
 
     private static final Logger LOG = LoggerFactory.getLogger(SyncReactorRetryDecorator.class);
-
     private final SyncReactor delegate;
     private final ReconciliationRegistry reconciliationRegistry;
 
@@ -36,31 +35,26 @@ public class SyncReactorRetryDecorator implements SyncReactor {
         this.reconciliationRegistry = reconciliationRegistry;
     }
 
+    @Override
     public ListenableFuture<Boolean> syncup(final InstanceIdentifier<FlowCapableNode> flowcapableNodePath,
-                                            final SyncupEntry syncupEntry) throws InterruptedException {
+                                            final SyncupEntry syncupEntry) {
 
         final NodeId nodeId = PathUtil.digNodeId(flowcapableNodePath);
-        LOG.trace("syncup retry decorator: {}", nodeId.getValue());
-
         if (syncupEntry.isOptimizedConfigDelta() && reconciliationRegistry.isRegistered(nodeId)) {
             LOG.debug("Config change ignored because {} is in reconcile.", nodeId.getValue());
-            return Futures.immediateFuture(Boolean.FALSE);
+            return Futures.immediateFuture(Boolean.TRUE);
         }
 
         ListenableFuture<Boolean> syncupResult = delegate.syncup(flowcapableNodePath,syncupEntry);
 
-        return Futures.transform(syncupResult, new Function<Boolean, Boolean>() {
-            @Override
-            public Boolean apply(Boolean result) {
-                LOG.trace("syncup return in retry decorator: {} [{}]", nodeId.getValue(), result);
-                if (result) {
-                    reconciliationRegistry.unregisterIfRegistered(nodeId);
-                    return true;
-                } else {
-                    reconciliationRegistry.register(nodeId);
-                    return false;
-                }
+        return Futures.transform(syncupResult, result -> {
+            if (result) {
+                reconciliationRegistry.unregisterIfRegistered(nodeId);
+            } else {
+                reconciliationRegistry.register(nodeId);
             }
-        });
+
+            return result;
+        }, MoreExecutors.directExecutor());
     }
 }