Program: 115977
Project: 115977
Buggy source:
public static void removeApplication(String applicationId) throws RestAPIException {
  try {
    AutoscalerServiceClient asServiceClient=getAutoscalerServiceClient();
    ApplicationBean application=ObjectConverter.convertStubApplicationContextToApplicationDefinition(asServiceClient.getApplication(applicationId));
    asServiceClient.deleteApplication(applicationId);
    Set<String> cartridgeNames;
    Set<String> cartridgeGroupNames;
    StratosManagerServiceClient smServiceClient=getStratosManagerServiceClient();
    List<CartridgeReferenceBean> cartridges=application.getComponents().getCartridges();
    if (cartridges != null) {
      cartridgeNames=new HashSet<String>();
      for (      CartridgeReferenceBean cartridge : cartridges) {
        cartridgeNames.add(cartridge.getType());
      }
      smServiceClient.removeUsedCartridgesInApplications(application.getApplicationId(),(String[])cartridgeNames.toArray());
    }
    List<GroupReferenceBean> cartridgeGroups=application.getComponents().getGroups();
    if (cartridgeGroups != null) {
      cartridgeGroupNames=new HashSet<String>();
      for (      GroupReferenceBean cartridgeGroup : cartridgeGroups) {
        cartridgeGroupNames.add(cartridgeGroup.getName());
      }
      smServiceClient.removeUsedCartridgeGroupsInApplications(application.getApplicationId(),(String[])cartridgeGroupNames.toArray());
    }
  }
 catch (  RemoteException e) {
    String message="String_Node_Str" + applicationId;
    log.error(message,e);
    throw new RestAPIException(message,e);
  }
}

Fixed version (ground truth):
public static void removeApplication(String applicationId) throws RestAPIException {
  try {
    AutoscalerServiceClient asServiceClient=getAutoscalerServiceClient();
    ApplicationBean application=ObjectConverter.convertStubApplicationContextToApplicationDefinition(asServiceClient.getApplication(applicationId));
    asServiceClient.deleteApplication(applicationId);
    String[] cartridgeNames;
    String[] cartridgeGroupNames;
    StratosManagerServiceClient smServiceClient=getStratosManagerServiceClient();
    List<CartridgeReferenceBean> cartridges=application.getComponents().getCartridges();
    if (cartridges != null) {
      cartridgeNames=new String[cartridges.size()];
      int i=0;
      for (      CartridgeReferenceBean cartridge : cartridges) {
        cartridgeNames[i]=cartridge.getType();
        i++;
      }
      smServiceClient.removeUsedCartridgesInApplications(application.getApplicationId(),cartridgeNames);
    }
    List<GroupReferenceBean> cartridgeGroups=application.getComponents().getGroups();
    if (cartridgeGroups != null) {
      cartridgeGroupNames=new String[cartridgeGroups.size()];
      int i=0;
      for (      GroupReferenceBean cartridgeGroup : cartridgeGroups) {
        cartridgeGroupNames[i]=cartridgeGroup.getName();
        i++;
      }
      smServiceClient.removeUsedCartridgeGroupsInApplications(application.getApplicationId(),cartridgeGroupNames);
    }
  }
 catch (  RemoteException e) {
    String message="String_Node_Str" + applicationId;
    log.error(message,e);
    throw new RestAPIException(message,e);
  }
}