Merge "Use equalsIgnoreCase when comparing subnet name to default subnet. Using equal...
authorGiovanni Meo <gmeo@cisco.com>
Tue, 17 Dec 2013 13:43:22 +0000 (13:43 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Tue, 17 Dec 2013 13:43:22 +0000 (13:43 +0000)
1  2 
opendaylight/switchmanager/implementation/src/main/java/org/opendaylight/controller/switchmanager/internal/SwitchManager.java

index f895ca0c85bd4583405453d65fcd4195dcb8b5ce,27365dbc2b0d4c0566737addfa49dd457a46d8d1..b5d0a48c28709e575f13646971e00ab1ddbc3ea0
@@@ -319,7 -319,7 +319,7 @@@ public class SwitchManager implements I
      @Override
      public SubnetConfig getSubnetConfig(String subnet) {
          // if there are no subnets, return the default subnet
-         if(subnetsConfigList.size() == 0 && subnet == DEFAULT_SUBNET_NAME){
+         if(subnetsConfigList.isEmpty() && subnet.equalsIgnoreCase(DEFAULT_SUBNET_NAME)){
              return DEFAULT_SUBNETCONFIG;
          }else{
              return subnetsConfigList.get(subnet);
      }
  
      private Status semanticCheck(SubnetConfig conf) {
-         Subnet newSubnet = new Subnet(conf);
          Set<InetAddress> IPs = subnets.keySet();
          if (IPs == null) {
              return new Status(StatusCode.SUCCESS);
          }
+         Subnet newSubnet = new Subnet(conf);
          for (InetAddress i : IPs) {
              Subnet existingSubnet = subnets.get(i);
              if ((existingSubnet != null) && !existingSubnet.isMutualExclusive(newSubnet)) {
                  return status;
              }
          } else {
-             if (conf.getName().equals(DEFAULT_SUBNET_NAME)) {
+             if (conf.getName().equalsIgnoreCase(DEFAULT_SUBNET_NAME)) {
                  return new Status(StatusCode.NOTALLOWED, "The specified subnet gateway cannot be removed");
              }
          }
  
      @Override
      public Status removeSubnet(String name) {
-         if (name.equals(DEFAULT_SUBNET_NAME)) {
+         if (name.equalsIgnoreCase(DEFAULT_SUBNET_NAME)) {
              return new Status(StatusCode.NOTALLOWED, "The specified subnet gateway cannot be removed");
          }
          SubnetConfig conf = subnetsConfigList.get(name);
              return DEFAULT_SUBNET;
          }
  
 -        Subnet sub;
 -        Set<InetAddress> indices = subnets.keySet();
 -        for (InetAddress i : indices) {
 -            sub = subnets.get(i);
 -            if (sub.isSubnetOf(networkAddress)) {
 -                return sub;
 +        for(Map.Entry<InetAddress,Subnet> subnetEntry : subnets.entrySet()) {
 +            if(subnetEntry.getValue().isSubnetOf(networkAddress)) {
 +                return subnetEntry.getValue();
              }
          }
          return null;