SwitchManager: getSwitchState() should not return null 28/15628/2
authorIsaku Yamahata <isaku.yamahata@intel.com>
Mon, 23 Feb 2015 19:27:49 +0000 (11:27 -0800)
committerThomas Bachman <tbachman@yahoo.com>
Mon, 23 Feb 2015 22:46:17 +0000 (22:46 +0000)
getSwitchState method populates switch state to switches in thread-safe
way. When race occurred, it should return already populated one.
The callers of it, updateSwitch and updateSwitchConfig, access the result
without null check. This is found by code review.
This semantics is same to other similar helper methods, getEPNGSet(),
getConfdGroupOrdinal(), getContextOrdinal().

Change-Id: I88d03a8f0b0109921377bc1fd4628a072c6b0552
Signed-off-by: Isaku Yamahata <isaku.yamahata@intel.com>
groupbasedpolicy/src/main/java/org/opendaylight/groupbasedpolicy/renderer/ofoverlay/SwitchManager.java

index 1ba543e5af5988fddf95fa70f885c72a39342fae..c9d9827eefd8a2e8157c1ea6956c9385b85567bc 100644 (file)
@@ -214,7 +214,7 @@ public class SwitchManager implements AutoCloseable {
             SwitchState old = 
                     switches.putIfAbsent(id, state);
             if (old != null)
-                state = null;
+                state = old;
         }
         return state;
     }