Program: 113511
Project: 113511
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){
  if (error != null && dbsReplicationManager != null && ((error instanceof BabuDBException && ((BabuDBException)error).getErrorCode().equals(NO_ACCESS)) || (error instanceof ConcurrentModificationException && dbsReplicationManager.isMaster()))) {
    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 {
      InetAddress host=this.master.getConfig().getAddress();
      int port=this.master.getConfig().getPort();
      InetSocketAddress address=(host == null) ? new InetSocketAddress(port) : new InetSocketAddress(host,port);
      rq.sendRedirectException(address.getAddress().getHostAddress(),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);
    if (error != null)     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 && dbsReplicationManager != null && ((error instanceof BabuDBException && ((BabuDBException)error).getErrorCode().equals(NO_ACCESS)) || (error instanceof ConcurrentModificationException && !dbsReplicationManager.isMaster()))) {
    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 {
      InetAddress host=this.master.getConfig().getAddress();
      int port=this.master.getConfig().getPort();
      InetSocketAddress address=(host == null) ? new InetSocketAddress(port) : new InetSocketAddress(host,port);
      rq.sendRedirectException(address.getAddress().getHostAddress(),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);
    if (error != null)     Logging.logError(Logging.LEVEL_ERROR,this,error);
    rq.sendInternalServerError(error);
  }
}