Program: 115517
Project: 115517
Buggy source:
/** 
 * Assert application activation
 * @param applicationUuid
 */
private void assertApplicationUndeploy(String applicationUuid){
  long startTime=System.currentTimeMillis();
  Application application=ApplicationManager.getApplications().getApplication(applicationUuid);
  ApplicationContext applicationContext=null;
  try {
    applicationContext=AutoscalerServiceClient.getInstance().getApplication(applicationUuid);
  }
 catch (  RemoteException e) {
    log.error("String_Node_Str" + applicationUuid);
  }
  while (((application != null) && application.getInstanceContextCount() > 0) || (applicationContext == null || applicationContext.getStatus().equals(APPLICATION_STATUS_UNDEPLOYING))) {
    try {
      Thread.sleep(1000);
    }
 catch (    InterruptedException ignore) {
    }
    application=ApplicationManager.getApplications().getApplication(applicationUuid);
    try {
      applicationContext=AutoscalerServiceClient.getInstance().getApplication(applicationUuid);
    }
 catch (    RemoteException e) {
      log.error("String_Node_Str" + applicationUuid);
    }
    if ((System.currentTimeMillis() - startTime) > APPLICATION_ACTIVATION_TIMEOUT) {
      break;
    }
  }
  assertNotNull(String.format("String_Node_Str",applicationUuid),application);
  assertNotNull(String.format("String_Node_Str",applicationUuid),applicationContext);
  if (application.getInstanceContextCount() > 0 || applicationContext.getStatus().equals(APPLICATION_STATUS_UNDEPLOYING)) {
    log.info("String_Node_Str" + applicationUuid);
    applicationTest.forceUndeployApplication(applicationUuid,endpoint,restClient);
    while (application.getInstanceContextCount() > 0 || applicationContext.getStatus().equals(APPLICATION_STATUS_UNDEPLOYING)) {
      try {
        Thread.sleep(1000);
      }
 catch (      InterruptedException ignore) {
      }
      application=ApplicationManager.getApplications().getApplication(applicationUuid);
      if ((System.currentTimeMillis() - startTime) > APPLICATION_ACTIVATION_TIMEOUT) {
        break;
      }
    }
  }
  assertEquals(String.format("String_Node_Str",applicationUuid),APPLICATION_STATUS_CREATED,applicationContext.getStatus());
}

Fixed version (ground truth):
/** 
 * Assert application activation
 * @param applicationId
 */
private void assertApplicationUndeploy(String applicationId,int tenantId){
  long startTime=System.currentTimeMillis();
  Application application=ApplicationManager.getApplications().getApplicationByTenant(applicationId,tenantId);
  ApplicationContext applicationContext=null;
  try {
    applicationContext=AutoscalerServiceClient.getInstance().getApplicationByTenant(applicationId,tenantId);
  }
 catch (  RemoteException e) {
    log.error("String_Node_Str" + applicationId);
  }
  while (((application != null) && application.getInstanceContextCount() > 0) || (applicationContext == null || applicationContext.getStatus().equals(APPLICATION_STATUS_UNDEPLOYING))) {
    try {
      Thread.sleep(1000);
    }
 catch (    InterruptedException ignore) {
    }
    application=ApplicationManager.getApplications().getApplicationByTenant(applicationId,tenantId);
    try {
      applicationContext=AutoscalerServiceClient.getInstance().getApplicationByTenant(applicationId,tenantId);
    }
 catch (    RemoteException e) {
      log.error("String_Node_Str" + applicationId);
    }
    if ((System.currentTimeMillis() - startTime) > APPLICATION_ACTIVATION_TIMEOUT) {
      break;
    }
  }
  assertNotNull(String.format("String_Node_Str",applicationId),application);
  assertNotNull(String.format("String_Node_Str",applicationId),applicationContext);
  if (application.getInstanceContextCount() > 0 || applicationContext.getStatus().equals(APPLICATION_STATUS_UNDEPLOYING)) {
    log.info("String_Node_Str" + applicationId);
    applicationTest.forceUndeployApplication(applicationId,endpoint,restClient);
    while (application.getInstanceContextCount() > 0 || applicationContext.getStatus().equals(APPLICATION_STATUS_UNDEPLOYING)) {
      try {
        Thread.sleep(1000);
      }
 catch (      InterruptedException ignore) {
      }
      application=ApplicationManager.getApplications().getApplicationByTenant(applicationId,tenantId);
      if ((System.currentTimeMillis() - startTime) > APPLICATION_ACTIVATION_TIMEOUT) {
        break;
      }
    }
  }
  assertEquals(String.format("String_Node_Str",applicationId),APPLICATION_STATUS_CREATED,applicationContext.getStatus());
}