Program: 145527
Project: 145527
Buggy source:
public Cancellable startRequest(final XMLHttpRequest req,String requestData,final Callback<XMLHttpRequest> onSuccess,final Callback<XMLHttpRequest> onFailure) throws Exception {
  req.setOnReadyStateChange(new ReadyStateChangeHandler(){
    public void onReadyStateChange(    XMLHttpRequest xhr){
      if (xhr.getReadyState() == XMLHttpRequest.DONE) {
        xhr.clearOnReadyStateChange();
        String errorMsg=XMLHttpRequest2.getBrowserSpecificFailure(req);
        if (errorMsg != null) {
          Throwable exception=new RuntimeException(errorMsg);
          Logger.getLogger(AppClient.class.getName()).log(Level.SEVERE,null,exception);
          try {
            if (onFailure != null)             onFailure.run(xhr);
          }
 catch (          Exception ex) {
            Logger.getLogger(AppClient.class.getName()).log(Level.SEVERE,null,ex);
          }
        }
 else {
          try {
            if (xhr.getStatus() == Response.SC_OK) {
              if (onSuccess != null)               onSuccess.run(xhr);
            }
 else {
              if (onFailure != null)               onFailure.run(xhr);
            }
          }
 catch (          Exception ex) {
            Logger.getLogger(AppClient.class.getName()).log(Level.SEVERE,null,ex);
          }
        }
      }
    }
  }
);
  if (requestData != null && !requestData.isEmpty())   req.send(requestData);
 else   req.send();
  return new Cancellable(){
    @Override public void cancel(){
      req.clearOnReadyStateChange();
      req.abort();
      if (onSuccess != null) {
        onSuccess.cancel();
      }
      if (onFailure != null) {
        onFailure.cancel();
      }
    }
  }
;
}

Fixed version (ground truth):
public Cancellable startRequest(final XMLHttpRequest req,String requestData,final Callback<XMLHttpRequest> onSuccess,final Callback<XMLHttpRequest> onFailure) throws Exception {
  req.setOnReadyStateChange(new ReadyStateChangeHandler(){
    public void onReadyStateChange(    XMLHttpRequest xhr){
      if (xhr.getReadyState() == XMLHttpRequest.DONE) {
        xhr.clearOnReadyStateChange();
        String errorMsg=XMLHttpRequest2.getBrowserSpecificFailure(xhr);
        if (errorMsg != null) {
          Throwable exception=new RuntimeException(errorMsg);
          Logger.getLogger(AppClient.class.getName()).log(Level.SEVERE,null,exception);
          try {
            if (onFailure != null)             onFailure.run(xhr);
          }
 catch (          Exception ex) {
            Logger.getLogger(AppClient.class.getName()).log(Level.SEVERE,null,ex);
          }
        }
 else {
          try {
            if (xhr.getStatus() == Response.SC_OK) {
              if (onSuccess != null)               onSuccess.run(xhr);
            }
 else {
              if (onFailure != null)               onFailure.run(xhr);
            }
          }
 catch (          Exception ex) {
            Logger.getLogger(AppClient.class.getName()).log(Level.SEVERE,null,ex);
          }
        }
      }
    }
  }
);
  if (requestData != null && !requestData.isEmpty())   req.send(requestData);
 else   req.send();
  return new Cancellable(){
    @Override public void cancel(){
      req.clearOnReadyStateChange();
      req.abort();
      if (onSuccess != null) {
        onSuccess.cancel();
      }
      if (onFailure != null) {
        onFailure.cancel();
      }
    }
  }
;
}