Program: 116012
Project: 116012
Buggy source:
/** 
 * Verify the existence of the application and add it.
 * @param appDefinition
 * @param ctxt
 * @param userName
 * @param tenantDomain
 * @throws RestAPIException
 */
public static void addApplication(ApplicationBean appDefinition,ConfigurationContext ctxt,String userName,String tenantDomain) throws RestAPIException {
  try {
    if (AutoscalerServiceClient.getInstance().getApplication(appDefinition.getApplicationId()) != null) {
      String msg="String_Node_Str" + appDefinition.getApplicationId();
      throw new RestAPIException(msg);
    }
  }
 catch (  RemoteException e) {
    throw new RestAPIException("String_Node_Str",e);
  }
  ApplicationContext applicationContext=ObjectConverter.convertApplicationDefinitionToStubApplicationContext(appDefinition);
  applicationContext.setTenantId(ApplicationManagementUtil.getTenantId(ctxt));
  applicationContext.setTenantDomain(tenantDomain);
  applicationContext.setTeantAdminUsername(userName);
  if (appDefinition.getProperty() != null) {
    org.apache.stratos.autoscaler.stub.Properties properties=new org.apache.stratos.autoscaler.stub.Properties();
    for (    PropertyBean propertyBean : appDefinition.getProperty()) {
      org.apache.stratos.autoscaler.stub.Property property=new org.apache.stratos.autoscaler.stub.Property();
      property.setName(propertyBean.getName());
      property.setValue(propertyBean.getValue());
      properties.addProperties(property);
    }
    applicationContext.setProperties(properties);
  }
  try {
    AutoscalerServiceClient.getInstance().addApplication(applicationContext);
  }
 catch (  AutoScalerServiceApplicationDefinitionExceptionException e) {
    throw new RestAPIException(e);
  }
catch (  RemoteException e) {
    throw new RestAPIException(e);
  }
}

Fixed version (ground truth):
/** 
 * Verify the existence of the application and add it.
 * @param appDefinition
 * @param ctxt
 * @param userName
 * @param tenantDomain
 * @throws RestAPIException
 */
public static void addApplication(ApplicationBean appDefinition,ConfigurationContext ctxt,String userName,String tenantDomain) throws RestAPIException {
  try {
    if (AutoscalerServiceClient.getInstance().getApplication(appDefinition.getApplicationId()) != null) {
      String msg="String_Node_Str" + appDefinition.getApplicationId();
      throw new RestAPIException(msg);
    }
  }
 catch (  RemoteException e) {
    throw new RestAPIException("String_Node_Str",e);
  }
  ApplicationContext applicationContext=ObjectConverter.convertApplicationDefinitionToStubApplicationContext(appDefinition);
  applicationContext.setTenantId(ApplicationManagementUtil.getTenantId(ctxt));
  applicationContext.setTenantDomain(tenantDomain);
  applicationContext.setTenantAdminUsername(userName);
  if (appDefinition.getProperty() != null) {
    org.apache.stratos.autoscaler.stub.Properties properties=new org.apache.stratos.autoscaler.stub.Properties();
    for (    PropertyBean propertyBean : appDefinition.getProperty()) {
      org.apache.stratos.autoscaler.stub.Property property=new org.apache.stratos.autoscaler.stub.Property();
      property.setName(propertyBean.getName());
      property.setValue(propertyBean.getValue());
      properties.addProperties(property);
    }
    applicationContext.setProperties(properties);
  }
  try {
    AutoscalerServiceClient.getInstance().addApplication(applicationContext);
  }
 catch (  AutoScalerServiceApplicationDefinitionExceptionException e) {
    throw new RestAPIException(e);
  }
catch (  RemoteException e) {
    throw new RestAPIException(e);
  }
}