Refactor if/else with dead branch to explain corner case better
[controller.git] / opendaylight / networkconfiguration / neutron / src / main / java / org / opendaylight / controller / networkconfig / neutron / NeutronSubnet.java
index 1072a344b0e1f0ac35e2dab68a420892df6e0ee0..d7919394867b0ef67b43ca7c20498f3a21df6ae7 100644 (file)
@@ -341,15 +341,18 @@ public class NeutronSubnet {
         List<NeutronSubnet_IPAllocationPool> newList = new ArrayList<NeutronSubnet_IPAllocationPool>();    // we have to modify a separate list\r
         while (i.hasNext()) {\r
             NeutronSubnet_IPAllocationPool pool = i.next();\r
-            if (pool.getPoolEnd().equalsIgnoreCase(ipAddress) &&\r
-                    pool.getPoolStart().equalsIgnoreCase(ipAddress))\r
-                ; // do nothing, i.e. don't add the current pool to the new list\r
-            else\r
+            /* if the pool contains a single address element and we are allocating it\r
+             * then we don't need to copy the pool over.  Otherwise, we need to possibly\r
+             * split the pool and add both pieces to the new list\r
+             */\r
+            if (!(pool.getPoolEnd().equalsIgnoreCase(ipAddress) &&\r
+                    pool.getPoolStart().equalsIgnoreCase(ipAddress))) {\r
                 if (pool.contains(ipAddress)) {\r
                     List<NeutronSubnet_IPAllocationPool> pools = pool.splitPool(ipAddress);\r
                     newList.addAll(pools);\r
                 } else\r
                     newList.add(pool);\r
+            }\r
         }\r
         allocationPools = newList;\r
     }\r