Program: 118504
Project: 118504
Buggy source:
public static void updateRejectMetatable(INode node,INode refNode){
  if (!isHasValidationRule(node)) {
    return;
  }
  List<IMetadataTable> metadatas=node.getMetadataList();
  if (metadatas != null && metadatas.size() > 0) {
    IMetadataTable table=null;
    boolean isHasRejectTable=false;
    for (    IMetadataTable metadataTable : metadatas) {
      if ("String_Node_Str".equals(metadataTable.getTableName())) {
        isHasRejectTable=true;
        table=metadataTable;
        break;
      }
    }
    if (!isHasRejectTable) {
      table=new MetadataTable();
    }
    table.setAttachedConnector("String_Node_Str");
    table.setTableName("String_Node_Str");
    table.setReadOnly(true);
    List<? extends IConnection> mainConnection=null;
    if (refNode != null) {
      mainConnection=refNode.getIncomingConnections(EConnectionType.FLOW_MAIN);
    }
 else {
      mainConnection=node.getIncomingConnections(EConnectionType.FLOW_MAIN);
    }
    IConnection connection=null;
    if (mainConnection != null && mainConnection.size() > 0) {
      table.getListColumns().clear();
      connection=mainConnection.get(0);
    }
 else {
      List<? extends IConnection> outgoingConnections;
      if (refNode != null) {
        outgoingConnections=refNode.getOutgoingConnections("String_Node_Str");
      }
 else {
        outgoingConnections=node.getOutgoingConnections("String_Node_Str");
      }
      if (outgoingConnections != null && outgoingConnections.size() > 0) {
        connection=outgoingConnections.get(0);
      }
    }
    if (connection != null) {
      IMetadataTable inputTable=connection.getMetadataTable();
      MetadataToolHelper.copyTable(null,inputTable,table);
    }
    List<IMetadataColumn> listColumns=table.getListColumns();
    boolean isHasErrorMsgCol=false;
    for (    IMetadataColumn metadataColumn : listColumns) {
      if ("String_Node_Str".equals(metadataColumn.getLabel())) {
        isHasErrorMsgCol=true;
        break;
      }
    }
    if (!isHasErrorMsgCol) {
      MetadataColumn column=new MetadataColumn();
      column.setId("String_Node_Str");
      column.setKey(false);
      column.setLabel("String_Node_Str");
      column.setLength(255);
      column.setOriginalDbColumnName("String_Node_Str");
      column.setPrecision(0);
      column.setCustom(true);
      column.setReadOnly(true);
      column.setNullable(true);
      column.setTalendType("String_Node_Str");
      table.getListColumns().add(column);
      if (!isHasRejectTable) {
        node.getMetadataList().add(table);
      }
    }
  }
}

Fixed version (ground truth):
public static void updateRejectMetatable(INode node,INode refNode){
  if (!isHasValidationRule(node)) {
    return;
  }
  List<IMetadataTable> metadatas=node.getMetadataList();
  if (metadatas != null && metadatas.size() > 0) {
    IMetadataTable table=null;
    boolean isHasRejectTable=false;
    for (    IMetadataTable metadataTable : metadatas) {
      if ("String_Node_Str".equals(metadataTable.getTableName())) {
        isHasRejectTable=true;
        table=metadataTable;
        break;
      }
    }
    if (!isHasRejectTable) {
      table=new MetadataTable();
    }
    table.setAttachedConnector("String_Node_Str");
    table.setTableName("String_Node_Str");
    table.setReadOnly(true);
    List<? extends IConnection> mainConnection=null;
    if (refNode != null) {
      mainConnection=refNode.getIncomingConnections(EConnectionType.FLOW_MAIN);
    }
 else {
      mainConnection=node.getIncomingConnections(EConnectionType.FLOW_MAIN);
    }
    IConnection connection=null;
    if (mainConnection != null && mainConnection.size() > 0) {
      table.getListColumns().clear();
      connection=mainConnection.get(0);
    }
 else {
      List<? extends IConnection> outgoingConnections;
      if (refNode != null) {
        outgoingConnections=refNode.getOutgoingConnections("String_Node_Str");
      }
 else {
        outgoingConnections=node.getOutgoingConnections("String_Node_Str");
      }
      if (outgoingConnections != null && outgoingConnections.size() > 0) {
        connection=outgoingConnections.get(0);
      }
    }
    if (connection != null) {
      IMetadataTable inputTable=connection.getMetadataTable();
      if (inputTable != null) {
        MetadataToolHelper.copyTable(null,inputTable,table);
      }
    }
    List<IMetadataColumn> listColumns=table.getListColumns();
    boolean isHasErrorMsgCol=false;
    for (    IMetadataColumn metadataColumn : listColumns) {
      if ("String_Node_Str".equals(metadataColumn.getLabel())) {
        isHasErrorMsgCol=true;
        break;
      }
    }
    if (!isHasErrorMsgCol) {
      MetadataColumn column=new MetadataColumn();
      column.setId("String_Node_Str");
      column.setKey(false);
      column.setLabel("String_Node_Str");
      column.setLength(255);
      column.setOriginalDbColumnName("String_Node_Str");
      column.setPrecision(0);
      column.setCustom(true);
      column.setReadOnly(true);
      column.setNullable(true);
      column.setTalendType("String_Node_Str");
      table.getListColumns().add(column);
      if (!isHasRejectTable) {
        node.getMetadataList().add(table);
      }
    }
  }
}