Fixup Augmentable and Identifiable methods changing
[openflowplugin.git] / openflowplugin-impl / src / main / java / org / opendaylight / openflowplugin / impl / registry / flow / DeviceFlowRegistryImpl.java
index 139499838f3a1777e7bff151a1fec47ad1f24eb9..83fd9b367f2bb688d7d9924365f5b82a09036175 100644 (file)
@@ -16,6 +16,7 @@ import com.google.common.util.concurrent.CheckedFuture;
 import com.google.common.util.concurrent.FutureCallback;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
+import com.google.common.util.concurrent.MoreExecutors;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Iterator;
@@ -126,7 +127,7 @@ public class DeviceFlowRegistryImpl implements DeviceFlowRegistry {
 
         Futures.addCallback(future, new FutureCallback<Optional<FlowCapableNode>>() {
             @Override
-            public void onSuccess(Optional<FlowCapableNode> result) {
+            public void onSuccess(@Nonnull Optional<FlowCapableNode> result) {
                 result.asSet().stream()
                         .filter(Objects::nonNull)
                         .filter(flowCapableNode -> Objects.nonNull(flowCapableNode.getTable()))
@@ -147,7 +148,7 @@ public class DeviceFlowRegistryImpl implements DeviceFlowRegistry {
                 // Even when read operation failed, close the transaction
                 transaction.close();
             }
-        });
+        }, MoreExecutors.directExecutor());
 
         return future;
     }
@@ -284,14 +285,16 @@ public class DeviceFlowRegistryImpl implements DeviceFlowRegistry {
     }
 
     private FlowRegistryKey getExistingKey(final FlowRegistryKey flowRegistryKey) {
-        if (flowRegistryKey.getMatch().getAugmentation(GeneralAugMatchNodesNodeTableFlow.class) == null) {
+        if (flowRegistryKey.getMatch().augmentation(GeneralAugMatchNodesNodeTableFlow.class) == null) {
             if (flowRegistry.containsKey(flowRegistryKey)) {
                 return flowRegistryKey;
             }
         } else {
-            for (Map.Entry<FlowRegistryKey, FlowDescriptor> keyValueSet : flowRegistry.entrySet()) {
-                if (keyValueSet.getKey().equals(flowRegistryKey)) {
-                    return keyValueSet.getKey();
+            synchronized (flowRegistry) {
+                for (Map.Entry<FlowRegistryKey, FlowDescriptor> keyValueSet : flowRegistry.entrySet()) {
+                    if (keyValueSet.getKey().equals(flowRegistryKey)) {
+                        return keyValueSet.getKey();
+                    }
                 }
             }
         }