Committed by
Gerrit Code Review
Duplicate Null Check not required
Change-Id: Ifd7a6678674f9858e33c43d8f210e42964859b3e
Showing
1 changed file
with
27 additions
and
32 deletions
| ... | @@ -202,27 +202,24 @@ public class FloatingIpManager implements FloatingIpService { | ... | @@ -202,27 +202,24 @@ public class FloatingIpManager implements FloatingIpService { |
| 202 | public boolean updateFloatingIps(Collection<FloatingIp> floatingIps) { | 202 | public boolean updateFloatingIps(Collection<FloatingIp> floatingIps) { |
| 203 | checkNotNull(floatingIps, FLOATINGIP_NOT_NULL); | 203 | checkNotNull(floatingIps, FLOATINGIP_NOT_NULL); |
| 204 | boolean result = true; | 204 | boolean result = true; |
| 205 | - if (floatingIps != null) { | 205 | + for (FloatingIp floatingIp : floatingIps) { |
| 206 | - for (FloatingIp floatingIp : floatingIps) { | 206 | + verifyFloatingIpData(floatingIp); |
| 207 | - verifyFloatingIpData(floatingIp); | 207 | + if (floatingIp.portId() != null) { |
| 208 | - if (floatingIp.portId() != null) { | 208 | + floatingIpStore.put(floatingIp.id(), floatingIp); |
| 209 | - floatingIpStore.put(floatingIp.id(), floatingIp); | 209 | + if (!floatingIpStore.containsKey(floatingIp.id())) { |
| 210 | - if (!floatingIpStore.containsKey(floatingIp.id())) { | 210 | + log.debug("The floating Ip is updated failed whose identifier is {}", |
| 211 | + floatingIp.id().toString()); | ||
| 212 | + result = false; | ||
| 213 | + } | ||
| 214 | + } else { | ||
| 215 | + FloatingIp oldFloatingIp = floatingIpStore.get(floatingIp.id()); | ||
| 216 | + if (oldFloatingIp != null) { | ||
| 217 | + floatingIpStore.remove(floatingIp.id(), oldFloatingIp); | ||
| 218 | + if (floatingIpStore.containsKey(floatingIp.id())) { | ||
| 211 | log.debug("The floating Ip is updated failed whose identifier is {}", | 219 | log.debug("The floating Ip is updated failed whose identifier is {}", |
| 212 | floatingIp.id().toString()); | 220 | floatingIp.id().toString()); |
| 213 | result = false; | 221 | result = false; |
| 214 | } | 222 | } |
| 215 | - } else { | ||
| 216 | - FloatingIp oldFloatingIp = floatingIpStore.get(floatingIp | ||
| 217 | - .id()); | ||
| 218 | - if (oldFloatingIp != null) { | ||
| 219 | - floatingIpStore.remove(floatingIp.id(), oldFloatingIp); | ||
| 220 | - if (floatingIpStore.containsKey(floatingIp.id())) { | ||
| 221 | - log.debug("The floating Ip is updated failed whose identifier is {}", | ||
| 222 | - floatingIp.id().toString()); | ||
| 223 | - result = false; | ||
| 224 | - } | ||
| 225 | - } | ||
| 226 | } | 223 | } |
| 227 | } | 224 | } |
| 228 | } | 225 | } |
| ... | @@ -233,21 +230,19 @@ public class FloatingIpManager implements FloatingIpService { | ... | @@ -233,21 +230,19 @@ public class FloatingIpManager implements FloatingIpService { |
| 233 | public boolean removeFloatingIps(Collection<FloatingIpId> floatingIpIds) { | 230 | public boolean removeFloatingIps(Collection<FloatingIpId> floatingIpIds) { |
| 234 | checkNotNull(floatingIpIds, FLOATINGIP_ID_NOT_NULL); | 231 | checkNotNull(floatingIpIds, FLOATINGIP_ID_NOT_NULL); |
| 235 | boolean result = true; | 232 | boolean result = true; |
| 236 | - if (floatingIpIds != null) { | 233 | + for (FloatingIpId floatingIpId : floatingIpIds) { |
| 237 | - for (FloatingIpId floatingIpId : floatingIpIds) { | 234 | + if (!floatingIpStore.containsKey(floatingIpId)) { |
| 238 | - if (!floatingIpStore.containsKey(floatingIpId)) { | 235 | + log.debug("The floatingIp is not exist whose identifier is {}", |
| 239 | - log.debug("The floatingIp is not exist whose identifier is {}", | 236 | + floatingIpId.toString()); |
| 240 | - floatingIpId.toString()); | 237 | + throw new IllegalArgumentException( |
| 241 | - throw new IllegalArgumentException( | 238 | + "FloatingIP ID doesn't exist"); |
| 242 | - "FloatingIP ID doesn't exist"); | 239 | + } |
| 243 | - } | 240 | + FloatingIp floatingIp = floatingIpStore.get(floatingIpId); |
| 244 | - FloatingIp floatingIp = floatingIpStore.get(floatingIpId); | 241 | + floatingIpStore.remove(floatingIpId, floatingIp); |
| 245 | - floatingIpStore.remove(floatingIpId, floatingIp); | 242 | + if (floatingIpStore.containsKey(floatingIpId)) { |
| 246 | - if (floatingIpStore.containsKey(floatingIpId)) { | 243 | + log.debug("The floating Ip is deleted failed whose identifier is {}", |
| 247 | - log.debug("The floating Ip is deleted failed whose identifier is {}", | 244 | + floatingIpId.toString()); |
| 248 | - floatingIpId.toString()); | 245 | + result = false; |
| 249 | - result = false; | ||
| 250 | - } | ||
| 251 | } | 246 | } |
| 252 | } | 247 | } |
| 253 | return result; | 248 | return result; | ... | ... |
-
Please register or login to post a comment