Program: 87307
Project: 87307
Buggy source:
public void flush(){
  final BufferedExecute buffersToFlush=this.bufferedExecute;
  if (!buffersToFlush.isEmpty()) {
    final int rowsToFlush=this.totalQueuedRows;
    this.pendingFlush=this.bufferedExecute;
    this.bufferedExecute=new BufferedExecute();
    this.totalQueuedRows=0;
    this.totalQueuedBytes=0;
    if (rowsToFlush > 0) {
      this.pendingStatementCount.incrementAndGet();
      int bufferedRowCount=buffersToFlush.size();
      final int flushTupleCount=Math.min(bufferedRowCount,maximumRowsToBuffer);
      if (flushTupleCount != bufferedRowCount) {
        throw new PECodingException(String.format("String_Node_Str",bufferedRowCount,flushTupleCount));
      }
      if (this.pstmtId >= 0 && flushTupleCount != this.pstmtTupleCount) {
        this.closeActivePreparedStatement();
      }
      if (RedistTargetSite.this.pstmtId < 0) {
        SQLCommand insertCommand=null;
        try {
          insertCommand=policy.buildInsertStatement(flushTupleCount);
        }
 catch (        PEException e) {
          throw new RuntimeException(e);
        }
        MysqlPrepareStatementCollector prepareCollector1=new MysqlPrepareStatementCollector(){
          long stmtID;
          int paramCount;
          int columnCount;
          @Override void consumeHeader(          MyPrepareOKResponse prepareOK){
            this.stmtID=prepareOK.getStmtId();
            this.paramCount=prepareOK.getNumParams();
            this.columnCount=prepareOK.getNumColumns();
            super.consumeHeader(prepareOK);
            if (this.paramCount == 0 && this.columnCount == 0) {
              prepareFinished(stmtID,flushTupleCount);
              executePendingInsert();
            }
          }
          @Override void consumeParamDefEOF(          MyEOFPktResponse myEof){
            super.consumeParamDefEOF(myEof);
            if (this.columnCount == 0) {
              prepareFinished(stmtID,flushTupleCount);
              executePendingInsert();
            }
          }
          @Override void consumeColDefEOF(          MyEOFPktResponse colEof){
            super.consumeColDefEOF(colEof);
            prepareFinished(stmtID,flushTupleCount);
            executePendingInsert();
          }
          @Override void consumeError(          MyErrorResponse error) throws PESQLStateException {
            prepareFailed(error);
          }
        }
;
        MysqlMessage message=MSPComPrepareStmtRequestMessage.newMessage(insertCommand.getSQL(),this.channel.lookupCurrentConnectionCharset());
        MysqlStmtPrepareCommand prepareCmd=new MysqlStmtPrepareCommand(this.channel,insertCommand.getSQL(),prepareCollector1,new PEDefaultPromise<Boolean>());
        this.waitingForPrepare=true;
        this.channel.writeAndFlush(message,prepareCmd);
      }
 else {
        executePendingInsert();
      }
    }
 else {
      this.queuedRowSetCount.addAndGet(-1 * buffersToFlush.size());
    }
  }
}

Fixed version (ground truth):
public void flush(){
  final BufferedExecute buffersToFlush=this.bufferedExecute;
  if (!buffersToFlush.isEmpty()) {
    final int rowsToFlush=this.totalQueuedRows;
    this.pendingFlush=this.bufferedExecute;
    this.bufferedExecute=new BufferedExecute();
    this.totalQueuedRows=0;
    this.totalQueuedBytes=0;
    if (rowsToFlush > 0) {
      this.pendingStatementCount.incrementAndGet();
      int bufferedRowCount=buffersToFlush.size();
      final int flushTupleCount=Math.min(bufferedRowCount,maximumRowsToBuffer);
      if (flushTupleCount != bufferedRowCount) {
        throw new PECodingException(String.format("String_Node_Str",bufferedRowCount,flushTupleCount));
      }
      if (this.pstmtId >= 0 && flushTupleCount != this.pstmtTupleCount) {
        this.closeActivePreparedStatement();
      }
      if (RedistTargetSite.this.pstmtId < 0) {
        SQLCommand insertCommand=null;
        try {
          insertCommand=policy.buildInsertStatement(flushTupleCount);
        }
 catch (        PEException e) {
          throw new RuntimeException(e);
        }
        MysqlPrepareStatementCollector prepareCollector1=new MysqlPrepareStatementCollector(){
          long stmtID;
          int paramCount;
          int columnCount;
          @Override void consumeHeader(          MyPrepareOKResponse prepareOK){
            this.stmtID=prepareOK.getStmtId();
            this.paramCount=prepareOK.getNumParams();
            this.columnCount=prepareOK.getNumColumns();
            super.consumeHeader(prepareOK);
            if (this.paramCount == 0 && this.columnCount == 0) {
              prepareFinished(stmtID,flushTupleCount);
              executePendingInsert();
            }
          }
          @Override void consumeParamDefEOF(          MyEOFPktResponse myEof){
            super.consumeParamDefEOF(myEof);
            if (this.columnCount == 0) {
              prepareFinished(stmtID,flushTupleCount);
              executePendingInsert();
            }
          }
          @Override void consumeColDefEOF(          MyEOFPktResponse colEof){
            super.consumeColDefEOF(colEof);
            prepareFinished(stmtID,flushTupleCount);
            executePendingInsert();
          }
          @Override void consumeError(          MyErrorResponse error) throws PESQLStateException {
            prepareFailed(error);
          }
        }
;
        MysqlMessage message=MSPComPrepareStmtRequestMessage.newMessage(insertCommand.getSQL(),this.channel.lookupCurrentConnectionCharset());
        MysqlStmtPrepareCommand prepareCmd=new MysqlStmtPrepareCommand(this.channel,insertCommand.getSQL(),prepareCollector1,new PEDefaultPromise<Boolean>());
        shouldPauseInput();
        this.channel.writeAndFlush(message,prepareCmd);
      }
 else {
        executePendingInsert();
      }
    }
 else {
      this.queuedRowSetCount.addAndGet(-1 * buffersToFlush.size());
    }
  }
}