Program: 113517
Project: 113517
Buggy source:
/** 
 * Operation to give a failure back to the client. Will decide, if a   {@link RedirectException} should be returned.
 * @param error - Exception thrown.
 * @param rq - original {@link DIRRequest}.
 */
void requestFailed(Exception error,DIRRequest rq){
  InetSocketAddress master=null;
  if (error != null && error instanceof BabuDBException && ((BabuDBException)error).getErrorCode().equals(NO_ACCESS) && dbsReplicationManager != null && (master=dbsReplicationManager.getMaster()) != null) {
    String host=master.getAddress().getHostAddress();
    Integer port=this.master.getConfig().getMirrors().get(host);
    if (port == null) {
      Logging.logMessage(Logging.LEVEL_ERROR,this,"String_Node_Str" + "String_Node_Str",host);
      rq.sendInternalServerError(error);
    }
 else {
      rq.sendRedirectException(host,port);
    }
  }
 else   if (error != null && error instanceof ONCRPCException) {
    Logging.logError(Logging.LEVEL_ERROR,this,error);
    rq.sendException((ONCRPCException)error);
  }
 else   if (error != null && error instanceof BabuDBException && (((BabuDBException)error).getErrorCode().equals(NO_SUCH_DB) || ((BabuDBException)error).getErrorCode().equals(DB_EXISTS) || ((BabuDBException)error).getErrorCode().equals(NO_SUCH_INDEX)|| ((BabuDBException)error).getErrorCode().equals(NO_SUCH_SNAPSHOT)|| ((BabuDBException)error).getErrorCode().equals(SNAP_EXISTS))) {
    Logging.logError(Logging.LEVEL_ERROR,this,error);
    rq.sendException(new InvalidArgumentException(error.getMessage()));
  }
 else {
    if (error != null && !(error instanceof BabuDBException))     Logging.logError(Logging.LEVEL_ERROR,this,error);
    rq.sendInternalServerError(error);
  }
}

Fixed version (ground truth):
/** 
 * Operation to give a failure back to the client. Will decide, if a   {@link RedirectException} should be returned.
 * @param error - Exception thrown.
 * @param rq - original {@link DIRRequest}.
 */
void requestFailed(Exception error,DIRRequest rq){
  if (error != null && error instanceof BabuDBException && ((BabuDBException)error).getErrorCode().equals(NO_ACCESS) && dbsReplicationManager != null) {
    InetSocketAddress altMaster=dbsReplicationManager.getMaster();
    if (altMaster != null) {
      String host=altMaster.getAddress().getHostAddress();
      Integer port=this.master.getConfig().getMirrors().get(host);
      if (port == null) {
        Logging.logMessage(Logging.LEVEL_ERROR,this,"String_Node_Str" + "String_Node_Str",host);
        rq.sendInternalServerError(error);
      }
 else {
        rq.sendRedirectException(host,port);
      }
    }
 else {
      rq.sendRedirectException(this.master.getConfig().getAddress().getHostAddress(),this.master.getConfig().getPort());
    }
  }
 else   if (error != null && error instanceof ONCRPCException) {
    Logging.logError(Logging.LEVEL_ERROR,this,error);
    rq.sendException((ONCRPCException)error);
  }
 else   if (error != null && error instanceof BabuDBException && (((BabuDBException)error).getErrorCode().equals(NO_SUCH_DB) || ((BabuDBException)error).getErrorCode().equals(DB_EXISTS) || ((BabuDBException)error).getErrorCode().equals(NO_SUCH_INDEX)|| ((BabuDBException)error).getErrorCode().equals(NO_SUCH_SNAPSHOT)|| ((BabuDBException)error).getErrorCode().equals(SNAP_EXISTS))) {
    Logging.logError(Logging.LEVEL_ERROR,this,error);
    rq.sendException(new InvalidArgumentException(error.getMessage()));
  }
 else {
    if (error != null && !(error instanceof BabuDBException))     Logging.logError(Logging.LEVEL_ERROR,this,error);
    if (error != null)     Logging.logError(Logging.LEVEL_ERROR,this,error);
    rq.sendInternalServerError(error);
  }
}