Program: 106053
Project: 106053
Buggy source:
@Override @DB public NiciraNvpDeviceVO addNiciraNvpDevice(AddNiciraNvpDeviceCmd cmd){
  ServerResource resource=new NiciraNvpResource();
  final String deviceName=Network.Provider.NiciraNvp.getName();
  NetworkDevice networkDevice=NetworkDevice.getNetworkDevice(deviceName);
  final Long physicalNetworkId=cmd.getPhysicalNetworkId();
  PhysicalNetworkVO physicalNetwork=physicalNetworkDao.findById(physicalNetworkId);
  if (physicalNetwork == null) {
    throw new InvalidParameterValueException("String_Node_Str" + physicalNetworkId);
  }
  long zoneId=physicalNetwork.getDataCenterId();
  final PhysicalNetworkServiceProviderVO ntwkSvcProvider=physicalNetworkServiceProviderDao.findByServiceProvider(physicalNetwork.getId(),networkDevice.getNetworkServiceProvder());
  if (ntwkSvcProvider == null) {
    throw new CloudRuntimeException("String_Node_Str" + networkDevice.getNetworkServiceProvder() + "String_Node_Str"+ physicalNetworkId+ "String_Node_Str");
  }
 else   if (ntwkSvcProvider.getState() == PhysicalNetworkServiceProvider.State.Shutdown) {
    throw new CloudRuntimeException("String_Node_Str" + ntwkSvcProvider.getProviderName() + "String_Node_Str"+ physicalNetworkId+ "String_Node_Str");
  }
  if (niciraNvpDao.listByPhysicalNetwork(physicalNetworkId).size() != 0) {
    throw new CloudRuntimeException("String_Node_Str");
  }
  Map<String,String> params=new HashMap<String,String>();
  params.put("String_Node_Str",UUID.randomUUID().toString());
  params.put("String_Node_Str",String.valueOf(physicalNetwork.getDataCenterId()));
  params.put("String_Node_Str",String.valueOf(physicalNetwork.getId()));
  params.put("String_Node_Str","String_Node_Str" + cmd.getHost());
  params.put("String_Node_Str",cmd.getHost());
  params.put("String_Node_Str",cmd.getUsername());
  params.put("String_Node_Str",cmd.getPassword());
  params.put("String_Node_Str",cmd.getTransportzoneUuid());
  params.put("String_Node_Str",physicalNetwork.getIsolationMethods().get(0).toLowerCase());
  if (cmd.getL3GatewayServiceUuid() != null) {
    params.put("String_Node_Str",cmd.getL3GatewayServiceUuid());
  }
  Map<String,Object> hostdetails=new HashMap<String,Object>();
  hostdetails.putAll(params);
  try {
    resource.configure(cmd.getHost(),hostdetails);
    final Host host=resourceMgr.addHost(zoneId,resource,Host.Type.L2Networking,params);
    if (host != null) {
      return Transaction.execute(new TransactionCallback<NiciraNvpDeviceVO>(){
        @Override public NiciraNvpDeviceVO doInTransaction(        TransactionStatus status){
          NiciraNvpDeviceVO niciraNvpDevice=new NiciraNvpDeviceVO(host.getId(),physicalNetworkId,ntwkSvcProvider.getProviderName(),deviceName);
          niciraNvpDao.persist(niciraNvpDevice);
          DetailVO detail=new DetailVO(host.getId(),"String_Node_Str",String.valueOf(niciraNvpDevice.getId()));
          hostDetailsDao.persist(detail);
          return niciraNvpDevice;
        }
      }
);
    }
 else {
      throw new CloudRuntimeException("String_Node_Str");
    }
  }
 catch (  ConfigurationException e) {
    throw new CloudRuntimeException(e.getMessage());
  }
}

Fixed version (ground truth):
@Override @DB public NiciraNvpDeviceVO addNiciraNvpDevice(AddNiciraNvpDeviceCmd cmd){
  ServerResource resource=new NiciraNvpResource();
  final String deviceName=Network.Provider.NiciraNvp.getName();
  NetworkDevice networkDevice=NetworkDevice.getNetworkDevice(deviceName);
  if (networkDevice == null) {
    throw new CloudRuntimeException("String_Node_Str" + deviceName);
  }
  final Long physicalNetworkId=cmd.getPhysicalNetworkId();
  PhysicalNetworkVO physicalNetwork=physicalNetworkDao.findById(physicalNetworkId);
  if (physicalNetwork == null) {
    throw new InvalidParameterValueException("String_Node_Str" + physicalNetworkId);
  }
  long zoneId=physicalNetwork.getDataCenterId();
  final PhysicalNetworkServiceProviderVO ntwkSvcProvider=physicalNetworkServiceProviderDao.findByServiceProvider(physicalNetwork.getId(),networkDevice.getNetworkServiceProvder());
  if (ntwkSvcProvider == null) {
    throw new CloudRuntimeException("String_Node_Str" + networkDevice.getNetworkServiceProvder() + "String_Node_Str"+ physicalNetworkId+ "String_Node_Str");
  }
 else   if (ntwkSvcProvider.getState() == PhysicalNetworkServiceProvider.State.Shutdown) {
    throw new CloudRuntimeException("String_Node_Str" + ntwkSvcProvider.getProviderName() + "String_Node_Str"+ physicalNetworkId+ "String_Node_Str");
  }
  if (niciraNvpDao.listByPhysicalNetwork(physicalNetworkId).size() != 0) {
    throw new CloudRuntimeException("String_Node_Str");
  }
  Map<String,String> params=new HashMap<String,String>();
  params.put("String_Node_Str",UUID.randomUUID().toString());
  params.put("String_Node_Str",String.valueOf(physicalNetwork.getDataCenterId()));
  params.put("String_Node_Str",String.valueOf(physicalNetwork.getId()));
  params.put("String_Node_Str","String_Node_Str" + cmd.getHost());
  params.put("String_Node_Str",cmd.getHost());
  params.put("String_Node_Str",cmd.getUsername());
  params.put("String_Node_Str",cmd.getPassword());
  params.put("String_Node_Str",cmd.getTransportzoneUuid());
  params.put("String_Node_Str",physicalNetwork.getIsolationMethods().get(0).toLowerCase());
  if (cmd.getL3GatewayServiceUuid() != null) {
    params.put("String_Node_Str",cmd.getL3GatewayServiceUuid());
  }
  Map<String,Object> hostdetails=new HashMap<String,Object>();
  hostdetails.putAll(params);
  try {
    resource.configure(cmd.getHost(),hostdetails);
    final Host host=resourceMgr.addHost(zoneId,resource,Host.Type.L2Networking,params);
    if (host != null) {
      return Transaction.execute(new TransactionCallback<NiciraNvpDeviceVO>(){
        @Override public NiciraNvpDeviceVO doInTransaction(        TransactionStatus status){
          NiciraNvpDeviceVO niciraNvpDevice=new NiciraNvpDeviceVO(host.getId(),physicalNetworkId,ntwkSvcProvider.getProviderName(),deviceName);
          niciraNvpDao.persist(niciraNvpDevice);
          DetailVO detail=new DetailVO(host.getId(),"String_Node_Str",String.valueOf(niciraNvpDevice.getId()));
          hostDetailsDao.persist(detail);
          return niciraNvpDevice;
        }
      }
);
    }
 else {
      throw new CloudRuntimeException("String_Node_Str");
    }
  }
 catch (  ConfigurationException e) {
    throw new CloudRuntimeException(e.getMessage());
  }
}