Program: 149383
Project: 149383
Buggy source:
@After public void tearDown() throws Exception {
  final Client client=cloud.getClient();
  final Map<String,IProgressMonitor> terminatingInstancIdToMonitorMap=new HashMap<String,IProgressMonitor>();
  for (Iterator<JSONObject> iter=objectsToDelete.iterator(); iter.hasNext(); ) {
    JSONObject object=iter.next();
    String uri=object.getString("String_Node_Str");
    if (uri != null && uri.startsWith("String_Node_Str")) {
      try {
        String instanceId=object.getString("String_Node_Str");
        IProgressMonitor monitor=client.forceTerminate(instanceId);
        terminatingInstancIdToMonitorMap.put(instanceId,monitor);
        iter.remove();
      }
 catch (      IOException ex) {
        LOGGER.log(Level.WARNING,ex.getMessage(),ex);
      }
    }
  }
  List<String> instanceIDs=new ArrayList<String>(terminatingInstancIdToMonitorMap.keySet());
  TestUtils.waitUntil(new TestUtils.Condition(){
    public boolean satisfied(){
      JSONArray instances;
      try {
        instances=client.getInstances(new ArrayList<String>(terminatingInstancIdToMonitorMap.keySet()));
      }
 catch (      IOException ex) {
        LOGGER.log(Level.SEVERE,ex.getMessage(),ex);
        return false;
      }
      Set<String> instanceIDs=new HashSet<String>();
      for (      Object instance : instances) {
        JSONObject instanceJson=(JSONObject)instance;
        String instanceId=instanceJson.getString("String_Node_Str");
        instanceIDs.add(instanceId);
        IProgressMonitor monitor=terminatingInstancIdToMonitorMap.get(instanceId);
        boolean done=false;
        try {
          done=monitor.isDone(instanceJson);
        }
 catch (        IProgressMonitor.IncompleteException ex) {
          done=true;
        }
catch (        IOException ex) {
          LOGGER.log(Level.SEVERE,ex.getMessage(),ex);
        }
        if (done) {
          terminatingInstancIdToMonitorMap.remove(instanceId);
        }
      }
      Set<String> notFoundInstanceIDs=new HashSet<String>(terminatingInstancIdToMonitorMap.keySet());
      notFoundInstanceIDs.removeAll(instanceIDs);
      terminatingInstancIdToMonitorMap.keySet().removeAll(notFoundInstanceIDs);
      return terminatingInstancIdToMonitorMap.isEmpty();
    }
  }
,180);
  for (  String instanceId : instanceIDs) {
    try {
      client.delete(instanceId);
    }
 catch (    IOException ex) {
      LOGGER.log(Level.WARNING,ex.getMessage(),ex);
    }
  }
  for (int i=objectsToDelete.size() - 1; i > -1; i--) {
    try {
      client.doDelete(objectsToDelete.get(i).getString("String_Node_Str"));
    }
 catch (    IOException ex) {
      LOGGER.log(Level.WARNING,ex.getMessage(),ex);
    }
  }
}

Fixed version (ground truth):
@After public void tearDown() throws Exception {
  final Client client=cloud.getClient();
  final Map<String,IProgressMonitor> terminatingInstancIdToMonitorMap=new HashMap<String,IProgressMonitor>();
  for (Iterator<JSONObject> iter=objectsToDelete.iterator(); iter.hasNext(); ) {
    JSONObject object=iter.next();
    String uri=object.getString("String_Node_Str");
    if (uri != null && uri.startsWith("String_Node_Str")) {
      try {
        String instanceId=object.getString("String_Node_Str");
        IProgressMonitor monitor=client.forceTerminate(instanceId);
        terminatingInstancIdToMonitorMap.put(instanceId,monitor);
        iter.remove();
      }
 catch (      IOException ex) {
        LOGGER.log(Level.WARNING,ex.getMessage(),ex);
      }
    }
  }
  List<String> instanceIDs=new ArrayList<String>(terminatingInstancIdToMonitorMap.keySet());
  new Condition(){
    public boolean satisfied(){
      JSONArray instances;
      try {
        instances=client.getInstances(new ArrayList<String>(terminatingInstancIdToMonitorMap.keySet()));
      }
 catch (      IOException ex) {
        LOGGER.log(Level.SEVERE,ex.getMessage(),ex);
        return false;
      }
      Set<String> instanceIDs=new HashSet<String>();
      for (      Object instance : instances) {
        JSONObject instanceJson=(JSONObject)instance;
        String instanceId=instanceJson.getString("String_Node_Str");
        instanceIDs.add(instanceId);
        IProgressMonitor monitor=terminatingInstancIdToMonitorMap.get(instanceId);
        boolean done=false;
        try {
          done=monitor.isDone(instanceJson);
        }
 catch (        IProgressMonitor.IncompleteException ex) {
          done=true;
        }
catch (        IOException ex) {
          LOGGER.log(Level.SEVERE,ex.getMessage(),ex);
        }
        if (done) {
          terminatingInstancIdToMonitorMap.remove(instanceId);
        }
      }
      Set<String> notFoundInstanceIDs=new HashSet<String>(terminatingInstancIdToMonitorMap.keySet());
      notFoundInstanceIDs.removeAll(instanceIDs);
      terminatingInstancIdToMonitorMap.keySet().removeAll(notFoundInstanceIDs);
      return terminatingInstancIdToMonitorMap.isEmpty();
    }
  }
.waitUntilSatisfied(180);
  for (  String instanceId : instanceIDs) {
    try {
      client.delete(instanceId);
    }
 catch (    IOException ex) {
      LOGGER.log(Level.WARNING,ex.getMessage(),ex);
    }
  }
  for (int i=objectsToDelete.size() - 1; i > -1; i--) {
    try {
      client.doDelete(objectsToDelete.get(i).getString("String_Node_Str"));
    }
 catch (    IOException ex) {
      LOGGER.log(Level.WARNING,ex.getMessage(),ex);
    }
  }
}