Program: 25486
Project: 25486
Buggy source:
/** 
 * reloadConfig - reloads the configuration of FSF disconnects/re-connects/and connects to slices as the FSF config specifies this is only called via the web-service
 */
@SuppressWarnings("String_Node_Str") public boolean reloadConfig(){
  ArrayList<HashMap<Long,Slicer>> newSlices;
  ArrayList<IOFSwitch> newSwitches;
  try {
    List<HashMap<Long,Slicer>> mySlices=Collections.synchronizedList(this.slices);
    newSlices=ConfigParser.parseConfig("String_Node_Str");
synchronized (mySlices) {
      if (newSlices.size() == 0) {
        logger.error("String_Node_Str");
        return false;
      }
 else {
        mySlices.clear();
        mySlices.addAll(newSlices);
      }
    }
    newSwitches=(ArrayList<IOFSwitch>)this.switches.clone();
    logger.error("String_Node_Str" + newSwitches.size());
    Iterator<IOFSwitch> it=newSwitches.iterator();
    while (it.hasNext()) {
      IOFSwitch sw=it.next();
      List<Proxy> proxies=controllerConnector.getSwitchProxies(sw.getId());
      if (proxies == null) {
        logger.error("String_Node_Str");
      }
      if (proxies != null) {
        List<Proxy> myProxies=Collections.synchronizedList(controllerConnector.getSwitchProxies(sw.getId()));
synchronized (myProxies) {
          if (myProxies != null) {
            logger.warn("String_Node_Str" + myProxies.size());
            Iterator<Proxy> proxyIt=myProxies.iterator();
            while (proxyIt.hasNext()) {
              Proxy p=proxyIt.next();
              boolean updated=false;
              for (              HashMap<Long,Slicer> slice : newSlices) {
                logger.error("String_Node_Str" + slice.keySet().size());
                if (slice.containsKey(sw.getId()) && slice.get(sw.getId()).getSliceName().equals(p.getSlicer().getSliceName())) {
                  p.setSlicer(slice.get(sw.getId()));
                  logger.warn("String_Node_Str" + p.getSlicer().getSliceName() + "String_Node_Str");
                  slice.remove(sw.getId());
                  updated=true;
                }
              }
              if (updated == false) {
                logger.warn("String_Node_Str" + p.getSlicer().getSliceName() + "String_Node_Str");
                p.disconnect();
                proxyIt.remove();
              }
            }
          }
        }
      }
    }
    Iterator<HashMap<Long,Slicer>> sliceIt=newSlices.iterator();
    logger.warn("String_Node_Str" + newSlices.size());
    while (sliceIt.hasNext()) {
      HashMap<Long,Slicer> slice=sliceIt.next();
      if (slice.isEmpty()) {
      }
 else {
        for (        Long dpid : slice.keySet()) {
          if (newSwitches.contains(dpid)) {
            IOFSwitch sw=floodlightProvider.getSwitch(dpid);
            Slicer vlanSlicer=slice.get(dpid);
            controllerConnector.addProxy(dpid,new Proxy(sw,vlanSlicer,this));
          }
        }
      }
    }
  }
 catch (  IOException e) {
    e.printStackTrace();
    return false;
  }
catch (  SAXException e) {
    e.printStackTrace();
    return false;
  }
catch (  ParserConfigurationException e) {
    logger.error(e.getMessage());
    return false;
  }
catch (  XPathExpressionException e) {
    logger.error(e.getMessage());
    return false;
  }
  logger.error("String_Node_Str" + this.slices.size());
  return true;
}

Fixed version (ground truth):
/** 
 * reloadConfig - reloads the configuration of FSF disconnects/re-connects/and connects to slices as the FSF config specifies this is only called via the web-service
 */
public boolean reloadConfig(){
  ArrayList<HashMap<Long,Slicer>> newSlices;
  ArrayList<Proxy> toBeRemoved=new ArrayList<Proxy>();
  try {
    newSlices=ConfigParser.parseConfig("String_Node_Str");
    for (    HashMap<Long,Slicer> slice : newSlices) {
      for (      Long dpid : slice.keySet()) {
        this.setSlice(dpid,slice.get(dpid).getSliceName(),slice.get(dpid));
      }
    }
    for (    IOFSwitch sw : this.switches) {
      logger.error("String_Node_Str" + controllerConnector.getSwitchProxies(sw.getId()).size());
      List<Proxy> proxies=controllerConnector.getSwitchProxies(sw.getId());
      if (proxies == null) {
        logger.error("String_Node_Str");
        continue;
      }
      logger.warn("String_Node_Str" + proxies.size());
      for (      Proxy p : proxies) {
        boolean updated=false;
        for (        HashMap<Long,Slicer> slice : newSlices) {
          logger.error("String_Node_Str" + slice.keySet().size());
          if (slice.containsKey(sw.getId()) && slice.get(sw.getId()).getSliceName().equals(p.getSlicer().getSliceName())) {
            p.setSlicer(slice.get(sw.getId()));
            logger.warn("String_Node_Str" + p.getSlicer().getSliceName() + "String_Node_Str");
            updated=true;
            slice.remove(sw.getId());
          }
        }
        if (!updated) {
          logger.warn("String_Node_Str" + p.getSlicer().getSliceName() + "String_Node_Str"+ sw.getStringId()+ "String_Node_Str");
          p.disconnect();
          toBeRemoved.add(p);
        }
      }
    }
    Iterator<HashMap<Long,Slicer>> sliceIt=newSlices.iterator();
    logger.warn("String_Node_Str" + newSlices.size());
    while (sliceIt.hasNext()) {
      HashMap<Long,Slicer> slice=sliceIt.next();
      if (slice.isEmpty()) {
      }
 else {
        for (        Long dpid : slice.keySet()) {
          if (this.switches.contains(dpid)) {
            IOFSwitch sw=floodlightProvider.getSwitch(dpid);
            Slicer vlanSlicer=slice.get(dpid);
            controllerConnector.addProxy(dpid,new Proxy(sw,vlanSlicer,this));
          }
        }
      }
    }
    for (    Proxy p : toBeRemoved) {
      this.removeProxy(p.getSwitch().getId(),p);
      this.removeSlice(p.getSwitch().getId(),p.getSlicer().getSliceName());
    }
  }
 catch (  IOException e) {
    e.printStackTrace();
    return false;
  }
catch (  SAXException e) {
    e.printStackTrace();
    return false;
  }
catch (  ParserConfigurationException e) {
    logger.error(e.getMessage());
    return false;
  }
catch (  XPathExpressionException e) {
    logger.error(e.getMessage());
    return false;
  }
  logger.error("String_Node_Str" + this.slices.size());
  return true;
}