Program: 167431
Project: 167431
Buggy source:
private void write(ISqlTransaction transaction,Message inputMessage,ISendMessageCallback callback,boolean unitOfWorkLastMessage){
  long ts=System.currentTimeMillis();
  int totalStatementCount=0;
  TargetTable modelTable=null;
  Object[] data=null;
  List<Result> results=new ArrayList<Result>();
  List<EntityData> inputRows=inputMessage.getPayload();
  try {
    Map<TargetTableDefintion,WriteStats> statsMap=new HashMap<TargetTableDefintion,WriteStats>();
    for (    TargetTableDefintion targetTableDefinition : targetTables) {
      for (      EntityData inputRow : inputRows) {
        log.info("String_Node_Str" + inputRow);
        inboundEntityDataCount++;
        WriteStats stats=statsMap.get(targetTableDefinition);
        if (stats == null) {
          stats=new WriteStats();
          statsMap.put(targetTableDefinition,stats);
        }
        if (updateFirst || inputRow.getChangeType() == ChangeType.CHG) {
          modelTable=targetTableDefinition.getUpdateTable();
          if (modelTable.shouldProcess(inputRow)) {
            data=getValues(true,modelTable,inputRow);
            int count=execute(transaction,modelTable.getStatement(),new Object(),data,true);
            results.add(new Result(modelTable.getStatement().getSql(),count));
            totalStatementCount++;
            stats.updateCount+=count;
            getComponentStatistics().incrementNumberEntitiesProcessed(count);
            if (insertFallback && count == 0) {
              modelTable=targetTableDefinition.getInsertTable();
              if (modelTable.shouldProcess(inputRow)) {
                log.debug("String_Node_Str");
                data=getValues(false,modelTable,inputRow);
                count=execute(transaction,modelTable.getStatement(),new Object(),data,true);
                results.add(new Result(modelTable.getStatement().getSql(),count));
                totalStatementCount++;
                stats.fallbackInsertCount+=count;
                getComponentStatistics().incrementNumberEntitiesProcessed(count);
              }
            }
 else             if (count == 0 && !continueOnError) {
              throw new SqlException(String.format("String_Node_Str",modelTable.getStatement().getSql(),Arrays.toString(data),Arrays.toString(modelTable.getStatement().getTypes())));
            }
 else             if (count == 0) {
              stats.ignoredCount++;
            }
          }
        }
 else         if (inputRow.getChangeType() == ChangeType.ADD) {
          try {
            modelTable=targetTableDefinition.getInsertTable();
            if (modelTable.shouldProcess(inputRow)) {
              data=getValues(false,modelTable,inputRow);
              int count=execute(transaction,modelTable.getStatement(),new Object(),data,!replaceRows && !continueOnError);
              results.add(new Result(modelTable.getStatement().getSql(),count));
              totalStatementCount++;
              stats.insertCount+=count;
              getComponentStatistics().incrementNumberEntitiesProcessed(count);
            }
          }
 catch (          UniqueKeyException e) {
            if (replaceRows) {
              modelTable=targetTableDefinition.getUpdateTable();
              if (modelTable.shouldProcess(inputRow)) {
                log.debug("String_Node_Str");
                data=getValues(true,modelTable,inputRow);
                int count=execute(transaction,modelTable.getStatement(),new Object(),data,true);
                results.add(new Result(modelTable.getStatement().getSql(),count));
                totalStatementCount++;
                stats.fallbackUpdateCount+=count;
                getComponentStatistics().incrementNumberEntitiesProcessed(count);
              }
            }
 else             if (!continueOnError) {
              throw e;
            }
 else {
              stats.ignoredCount++;
            }
          }
        }
 else         if (inputRow.getChangeType() == ChangeType.DEL) {
          modelTable=targetTableDefinition.getDeleteTable();
          if (modelTable.shouldProcess(inputRow)) {
            data=getValues(false,modelTable,inputRow);
            int count=execute(transaction,modelTable.getStatement(),new Object(),data,!replaceRows && !continueOnError);
            results.add(new Result(modelTable.getStatement().getSql(),count));
            totalStatementCount++;
            stats.deleteCount+=count;
            getComponentStatistics().incrementNumberEntitiesProcessed(count);
          }
        }
      }
    }
    info("String_Node_Str",totalStatementCount,LogUtils.formatDuration(System.currentTimeMillis() - ts));
    for (    TargetTableDefintion table : targetTables) {
      WriteStats stats=statsMap.get(table);
      if (stats != null) {
        StringBuilder msg=new StringBuilder();
        if (stats.insertCount > 0) {
          msg.append("String_Node_Str");
          msg.append(stats.insertCount);
        }
        if (stats.fallbackUpdateCount > 0) {
          if (msg.length() > 0) {
            msg.append("String_Node_Str");
          }
          msg.append("String_Node_Str");
          msg.append(stats.fallbackUpdateCount);
        }
        if (stats.updateCount > 0) {
          if (msg.length() > 0) {
            msg.append("String_Node_Str");
          }
          msg.append("String_Node_Str");
          msg.append(stats.updateCount);
        }
        if (stats.deleteCount > 0) {
          if (msg.length() > 0) {
            msg.append("String_Node_Str");
          }
          msg.append("String_Node_Str");
          msg.append(stats.deleteCount);
        }
        if (stats.fallbackInsertCount > 0) {
          if (msg.length() > 0) {
            msg.append("String_Node_Str");
          }
          msg.append("String_Node_Str");
          msg.append(stats.fallbackInsertCount);
        }
        if (stats.ignoredCount > 0) {
          if (msg.length() > 0) {
            msg.append("String_Node_Str");
          }
          msg.append("String_Node_Str");
          msg.append(stats.ignoredCount);
        }
        if (msg.length() > 0) {
          log(LogLevel.INFO,"String_Node_Str",table.getInsertTable().getTable().getFullyQualifiedTableName(),msg.toString());
        }
      }
    }
  }
 catch (  RuntimeException ex) {
    if (modelTable != null && data != null) {
      log(LogLevel.ERROR,String.format("String_Node_Str",inboundEntityDataCount,modelTable.getStatement().getSql(),Arrays.toString(data),Arrays.toString(modelTable.getStatement().getTypes())));
    }
    throw ex;
  }
}

Fixed version (ground truth):
private void write(ISqlTransaction transaction,Message inputMessage,ISendMessageCallback callback,boolean unitOfWorkLastMessage){
  long ts=System.currentTimeMillis();
  int totalStatementCount=0;
  TargetTable modelTable=null;
  Object[] data=null;
  List<Result> results=new ArrayList<Result>();
  List<EntityData> inputRows=inputMessage.getPayload();
  try {
    Map<TargetTableDefintion,WriteStats> statsMap=new HashMap<TargetTableDefintion,WriteStats>();
    for (    TargetTableDefintion targetTableDefinition : targetTables) {
      for (      EntityData inputRow : inputRows) {
        log.debug("String_Node_Str",inputRow);
        inboundEntityDataCount++;
        WriteStats stats=statsMap.get(targetTableDefinition);
        if (stats == null) {
          stats=new WriteStats();
          statsMap.put(targetTableDefinition,stats);
        }
        if (updateFirst || inputRow.getChangeType() == ChangeType.CHG) {
          modelTable=targetTableDefinition.getUpdateTable();
          if (modelTable.shouldProcess(inputRow)) {
            data=getValues(true,modelTable,inputRow);
            int count=execute(transaction,modelTable.getStatement(),new Object(),data,true);
            results.add(new Result(modelTable.getStatement().getSql(),count));
            totalStatementCount++;
            stats.updateCount+=count;
            getComponentStatistics().incrementNumberEntitiesProcessed(count);
            if (insertFallback && count == 0) {
              modelTable=targetTableDefinition.getInsertTable();
              if (modelTable.shouldProcess(inputRow)) {
                log.debug("String_Node_Str");
                data=getValues(false,modelTable,inputRow);
                count=execute(transaction,modelTable.getStatement(),new Object(),data,true);
                results.add(new Result(modelTable.getStatement().getSql(),count));
                totalStatementCount++;
                stats.fallbackInsertCount+=count;
                getComponentStatistics().incrementNumberEntitiesProcessed(count);
              }
            }
 else             if (count == 0 && !continueOnError) {
              throw new SqlException(String.format("String_Node_Str",modelTable.getStatement().getSql(),Arrays.toString(data),Arrays.toString(modelTable.getStatement().getTypes())));
            }
 else             if (count == 0) {
              stats.ignoredCount++;
            }
          }
        }
 else         if (inputRow.getChangeType() == ChangeType.ADD) {
          try {
            modelTable=targetTableDefinition.getInsertTable();
            if (modelTable.shouldProcess(inputRow)) {
              data=getValues(false,modelTable,inputRow);
              int count=execute(transaction,modelTable.getStatement(),new Object(),data,!replaceRows && !continueOnError);
              results.add(new Result(modelTable.getStatement().getSql(),count));
              totalStatementCount++;
              stats.insertCount+=count;
              getComponentStatistics().incrementNumberEntitiesProcessed(count);
            }
          }
 catch (          UniqueKeyException e) {
            if (replaceRows) {
              modelTable=targetTableDefinition.getUpdateTable();
              if (modelTable.shouldProcess(inputRow)) {
                log.debug("String_Node_Str");
                data=getValues(true,modelTable,inputRow);
                int count=execute(transaction,modelTable.getStatement(),new Object(),data,true);
                results.add(new Result(modelTable.getStatement().getSql(),count));
                totalStatementCount++;
                stats.fallbackUpdateCount+=count;
                getComponentStatistics().incrementNumberEntitiesProcessed(count);
              }
            }
 else             if (!continueOnError) {
              throw e;
            }
 else {
              stats.ignoredCount++;
            }
          }
        }
 else         if (inputRow.getChangeType() == ChangeType.DEL) {
          modelTable=targetTableDefinition.getDeleteTable();
          if (modelTable.shouldProcess(inputRow)) {
            data=getValues(false,modelTable,inputRow);
            int count=execute(transaction,modelTable.getStatement(),new Object(),data,!replaceRows && !continueOnError);
            results.add(new Result(modelTable.getStatement().getSql(),count));
            totalStatementCount++;
            stats.deleteCount+=count;
            getComponentStatistics().incrementNumberEntitiesProcessed(count);
          }
        }
      }
    }
    info("String_Node_Str",totalStatementCount,LogUtils.formatDuration(System.currentTimeMillis() - ts));
    for (    TargetTableDefintion table : targetTables) {
      WriteStats stats=statsMap.get(table);
      if (stats != null) {
        StringBuilder msg=new StringBuilder();
        if (stats.insertCount > 0) {
          msg.append("String_Node_Str");
          msg.append(stats.insertCount);
        }
        if (stats.fallbackUpdateCount > 0) {
          if (msg.length() > 0) {
            msg.append("String_Node_Str");
          }
          msg.append("String_Node_Str");
          msg.append(stats.fallbackUpdateCount);
        }
        if (stats.updateCount > 0) {
          if (msg.length() > 0) {
            msg.append("String_Node_Str");
          }
          msg.append("String_Node_Str");
          msg.append(stats.updateCount);
        }
        if (stats.deleteCount > 0) {
          if (msg.length() > 0) {
            msg.append("String_Node_Str");
          }
          msg.append("String_Node_Str");
          msg.append(stats.deleteCount);
        }
        if (stats.fallbackInsertCount > 0) {
          if (msg.length() > 0) {
            msg.append("String_Node_Str");
          }
          msg.append("String_Node_Str");
          msg.append(stats.fallbackInsertCount);
        }
        if (stats.ignoredCount > 0) {
          if (msg.length() > 0) {
            msg.append("String_Node_Str");
          }
          msg.append("String_Node_Str");
          msg.append(stats.ignoredCount);
        }
        if (msg.length() > 0) {
          log(LogLevel.INFO,"String_Node_Str",table.getInsertTable().getTable().getFullyQualifiedTableName(),msg.toString());
        }
      }
    }
  }
 catch (  RuntimeException ex) {
    if (modelTable != null && data != null) {
      log(LogLevel.ERROR,String.format("String_Node_Str",inboundEntityDataCount,modelTable.getStatement().getSql(),Arrays.toString(data),Arrays.toString(modelTable.getStatement().getTypes())));
    }
    throw ex;
  }
}