BUG-3363: code optimization and cleanup - Do not leak mutable collection 30/22330/2
authorRobert Varga <rovarga@cisco.com>
Sat, 6 Jun 2015 01:13:39 +0000 (03:13 +0200)
committermichal rehak <mirehak@cisco.com>
Thu, 11 Jun 2015 07:17:08 +0000 (07:17 +0000)
Flow descriptors should not be modified outside this class. Make sure
that is the case by wrapping it in an Collections.unmodifiableMap().

Change-Id: I188287d8d10911f6faabd5f31e028714ae005bce
Signed-off-by: Robert Varga <rovarga@cisco.com>
(cherry picked from commit 9930a5d6b7cfeed87e4e3308882b5375bea10f59)

openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/registry/flow/DeviceFlowRegistryImpl.java

index 8b802249e1b4ef80926a84037ed0ecbf21e16f69..ddf48078f7e6e33e909bd90426cf06acb724c3f8 100644 (file)
@@ -9,6 +9,7 @@
 package org.opendaylight.openflowplugin.impl.registry.flow;
 
 import java.util.Collection;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Map;
@@ -88,7 +89,7 @@ public class DeviceFlowRegistryImpl implements DeviceFlowRegistry {
 
     @Override
     public Map<FlowRegistryKey, FlowDescriptor> getAllFlowDescriptors() {
-        return flowRegistry;
+        return Collections.unmodifiableMap(flowRegistry);
     }
 
     @Override