Add missing iteration synchronisation 39/72239/1
authorStephen Kitt <skitt@redhat.com>
Thu, 24 May 2018 15:00:20 +0000 (17:00 +0200)
committerStephen Kitt <skitt@redhat.com>
Thu, 24 May 2018 15:00:20 +0000 (17:00 +0200)
Synchronised BiMaps need to have their iterations protected by
explicit synchronisation (see the javadocs); this patch adds a missing
synchronisation in getExistingKey.

Change-Id: I4bea65e06aee26cf2d5e6ebae86f3bedd2dd6fc6
JIRA: OPNFLWPLUG-1013
Signed-off-by: Stephen Kitt <skitt@redhat.com>
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/registry/flow/DeviceFlowRegistryImpl.java

index 67e113edf7fe11adca681668d39fe4d9a0b987a4..f5f812157ee3f1dc0078a0c1ecec4946d410746a 100644 (file)
@@ -290,9 +290,11 @@ public class DeviceFlowRegistryImpl implements DeviceFlowRegistry {
                 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();
+                    }
                 }
             }
         }