Program: 89153
Project: 89153
Buggy source:
@Override @DB @ActionEvent(eventType=EventTypes.EVENT_PHYSICAL_NETWORK_UPDATE,eventDescription="String_Node_Str",async=true) public PhysicalNetwork updatePhysicalNetwork(Long id,String networkSpeed,List<String> tags,String newVnetRangeString,String state){
  PhysicalNetworkVO network=_physicalNetworkDao.findById(id);
  if (network == null) {
    throw new InvalidParameterValueException("String_Node_Str" + id + "String_Node_Str");
  }
  DataCenter zone=_dcDao.findById(network.getDataCenterId());
  if (zone == null) {
    throw new InvalidParameterValueException("String_Node_Str" + network.getDataCenterId() + "String_Node_Str");
  }
  if (newVnetRangeString != null) {
    if (zone.getNetworkType() == NetworkType.Basic || (zone.getNetworkType() == NetworkType.Advanced && zone.isSecurityGroupEnabled())) {
      throw new InvalidParameterValueException("String_Node_Str" + zone.getNetworkType() + "String_Node_Str"+ zone.isSecurityGroupEnabled());
    }
  }
  if (tags != null && tags.size() > 1) {
    throw new InvalidParameterException("String_Node_Str");
  }
  PhysicalNetwork.State networkState=null;
  if (state != null && !state.isEmpty()) {
    try {
      networkState=PhysicalNetwork.State.valueOf(state);
    }
 catch (    IllegalArgumentException ex) {
      throw new InvalidParameterValueException("String_Node_Str" + state + "String_Node_Str");
    }
  }
  if (state != null) {
    network.setState(networkState);
  }
  if (tags != null) {
    network.setTags(tags);
  }
  if (networkSpeed != null) {
    network.setSpeed(networkSpeed);
  }
  boolean replaceVnet=false;
  ArrayList<Pair<Integer,Integer>> vnetsToAdd=new ArrayList<Pair<Integer,Integer>>(2);
  if (newVnetRangeString != null) {
    Integer newStartVnet=0;
    Integer newEndVnet=0;
    String[] newVnetRange=newVnetRangeString.split("String_Node_Str");
    if (newVnetRange.length < 2) {
      throw new InvalidParameterValueException("String_Node_Str");
    }
    if (newVnetRange[0] == null || newVnetRange[1] == null) {
      throw new InvalidParameterValueException("String_Node_Str");
    }
    try {
      newStartVnet=Integer.parseInt(newVnetRange[0]);
      newEndVnet=Integer.parseInt(newVnetRange[1]);
    }
 catch (    NumberFormatException e) {
      s_logger.warn("String_Node_Str",e);
      throw new InvalidParameterValueException("String_Node_Str");
    }
    if (newStartVnet < 0 || newEndVnet > 4096) {
      throw new InvalidParameterValueException("String_Node_Str");
    }
    if (newStartVnet > newEndVnet) {
      throw new InvalidParameterValueException("String_Node_Str");
    }
    if (physicalNetworkHasAllocatedVnets(network.getDataCenterId(),network.getId())) {
      String[] existingRange=network.getVnet().split("String_Node_Str");
      int existingStartVnet=Integer.parseInt(existingRange[0]);
      int existingEndVnet=Integer.parseInt(existingRange[1]);
      if (!(newStartVnet.intValue() > existingStartVnet && newEndVnet.intValue() < existingEndVnet)) {
        throw new InvalidParameterValueException("String_Node_Str");
      }
      if (newStartVnet < existingStartVnet) {
        vnetsToAdd.add(new Pair<Integer,Integer>(newStartVnet,existingStartVnet - 1));
      }
      if (newEndVnet > existingEndVnet) {
        vnetsToAdd.add(new Pair<Integer,Integer>(existingEndVnet + 1,newEndVnet));
      }
    }
 else {
      vnetsToAdd.add(new Pair<Integer,Integer>(newStartVnet,newEndVnet));
      replaceVnet=true;
    }
  }
  if (newVnetRangeString != null) {
    network.setVnet(newVnetRangeString);
  }
  _physicalNetworkDao.update(id,network);
  if (replaceVnet) {
    s_logger.debug("String_Node_Str" + id + "String_Node_Str"+ network.getDataCenterId()+ "String_Node_Str");
    _dcDao.deleteVnet(network.getId());
  }
  for (  Pair<Integer,Integer> vnetToAdd : vnetsToAdd) {
    s_logger.debug("String_Node_Str" + vnetToAdd.first() + "String_Node_Str"+ vnetToAdd.second()+ "String_Node_Str"+ id+ "String_Node_Str"+ network.getDataCenterId()+ "String_Node_Str");
    _dcDao.addVnet(network.getDataCenterId(),network.getId(),vnetToAdd.first(),vnetToAdd.second());
  }
  return network;
}

Fixed version (ground truth):
@Override @DB @ActionEvent(eventType=EventTypes.EVENT_PHYSICAL_NETWORK_UPDATE,eventDescription="String_Node_Str",async=true) public PhysicalNetwork updatePhysicalNetwork(Long id,String networkSpeed,List<String> tags,String newVnetRangeString,String state){
  PhysicalNetworkVO network=_physicalNetworkDao.findById(id);
  if (network == null) {
    throw new InvalidParameterValueException("String_Node_Str" + id + "String_Node_Str");
  }
  DataCenter zone=_dcDao.findById(network.getDataCenterId());
  if (zone == null) {
    throw new InvalidParameterValueException("String_Node_Str" + network.getDataCenterId() + "String_Node_Str");
  }
  if (newVnetRangeString != null) {
    if (zone.getNetworkType() == NetworkType.Basic || (zone.getNetworkType() == NetworkType.Advanced && zone.isSecurityGroupEnabled())) {
      throw new InvalidParameterValueException("String_Node_Str" + zone.getNetworkType() + "String_Node_Str"+ zone.isSecurityGroupEnabled());
    }
  }
  if (tags != null && tags.size() > 1) {
    throw new InvalidParameterException("String_Node_Str");
  }
  PhysicalNetwork.State networkState=null;
  if (state != null && !state.isEmpty()) {
    try {
      networkState=PhysicalNetwork.State.valueOf(state);
    }
 catch (    IllegalArgumentException ex) {
      throw new InvalidParameterValueException("String_Node_Str" + state + "String_Node_Str");
    }
  }
  if (state != null) {
    network.setState(networkState);
  }
  if (tags != null) {
    network.setTags(tags);
  }
  if (networkSpeed != null) {
    network.setSpeed(networkSpeed);
  }
  boolean replaceVnet=false;
  ArrayList<Pair<Integer,Integer>> vnetsToAdd=new ArrayList<Pair<Integer,Integer>>(2);
  if (newVnetRangeString != null) {
    Integer newStartVnet=0;
    Integer newEndVnet=0;
    String[] newVnetRange=newVnetRangeString.split("String_Node_Str");
    if (newVnetRange.length < 2) {
      throw new InvalidParameterValueException("String_Node_Str");
    }
    if (newVnetRange[0] == null || newVnetRange[1] == null) {
      throw new InvalidParameterValueException("String_Node_Str");
    }
    try {
      newStartVnet=Integer.parseInt(newVnetRange[0]);
      newEndVnet=Integer.parseInt(newVnetRange[1]);
    }
 catch (    NumberFormatException e) {
      s_logger.warn("String_Node_Str",e);
      throw new InvalidParameterValueException("String_Node_Str");
    }
    if (newStartVnet < 0 || newEndVnet > 4096) {
      throw new InvalidParameterValueException("String_Node_Str");
    }
    if (newStartVnet > newEndVnet) {
      throw new InvalidParameterValueException("String_Node_Str");
    }
    if (physicalNetworkHasAllocatedVnets(network.getDataCenterId(),network.getId())) {
      String[] existingRange=network.getVnet().split("String_Node_Str");
      int existingStartVnet=Integer.parseInt(existingRange[0]);
      int existingEndVnet=Integer.parseInt(existingRange[1]);
      if (newStartVnet.intValue() > existingStartVnet || newEndVnet.intValue() < existingEndVnet) {
        throw new InvalidParameterValueException("String_Node_Str");
      }
      if (newStartVnet < existingStartVnet) {
        vnetsToAdd.add(new Pair<Integer,Integer>(newStartVnet,existingStartVnet - 1));
      }
      if (newEndVnet > existingEndVnet) {
        vnetsToAdd.add(new Pair<Integer,Integer>(existingEndVnet + 1,newEndVnet));
      }
    }
 else {
      vnetsToAdd.add(new Pair<Integer,Integer>(newStartVnet,newEndVnet));
      replaceVnet=true;
    }
  }
  if (newVnetRangeString != null) {
    network.setVnet(newVnetRangeString);
  }
  _physicalNetworkDao.update(id,network);
  if (replaceVnet) {
    s_logger.debug("String_Node_Str" + id + "String_Node_Str"+ network.getDataCenterId()+ "String_Node_Str");
    _dcDao.deleteVnet(network.getId());
  }
  for (  Pair<Integer,Integer> vnetToAdd : vnetsToAdd) {
    s_logger.debug("String_Node_Str" + vnetToAdd.first() + "String_Node_Str"+ vnetToAdd.second()+ "String_Node_Str"+ id+ "String_Node_Str"+ network.getDataCenterId()+ "String_Node_Str");
    _dcDao.addVnet(network.getDataCenterId(),network.getId(),vnetToAdd.first(),vnetToAdd.second());
  }
  return network;
}