Program: 123279
Project: 123279
Buggy source:
/** 
 * DOC amaumont Comment method "buildFromTableDeclaration".
 * @param sb
 * @param inputTable
 * @param commaCouldBeAdded
 * @param crCouldBeAdded TODO
 * @param writingInJoin TODO
 */
private void buildTableDeclaration(DbMapComponent component,StringBuilder sb,ExternalDbMapTable inputTable,boolean commaCouldBeAdded,boolean crCouldBeAdded,boolean writingInJoin){
  sb.append(DbMapSqlConstants.SPACE);
  String alias=inputTable.getAlias();
  if (alias != null) {
    if (!aliasAlreadyDeclared.contains(inputTable.getName())) {
      if (crCouldBeAdded) {
        sb.append(DbMapSqlConstants.NEW_LINE);
      }
      if (commaCouldBeAdded) {
        sb.append(DbMapSqlConstants.COMMA);
        sb.append(DbMapSqlConstants.SPACE);
      }
      sb.append(addQuit(inputTable.getTableName()));
      sb.append(DbMapSqlConstants.SPACE);
      sb.append(addQuit(alias));
      aliasAlreadyDeclared.add(alias);
    }
 else {
      if (writingInJoin) {
        sb.append(addQuit(inputTable.getName()));
      }
    }
  }
 else {
    if (crCouldBeAdded) {
      sb.append(DbMapSqlConstants.NEW_LINE);
    }
    if (commaCouldBeAdded) {
      sb.append(DbMapSqlConstants.COMMA);
      sb.append(DbMapSqlConstants.SPACE);
    }
    String inputTableName=inputTable.getName();
    List<IConnection> inputConnections=(List<IConnection>)component.getIncomingConnections();
    boolean replace=false;
    if (inputConnections != null) {
      for (      IConnection iconn : inputConnections) {
        IMetadataTable metadataTable=iconn.getMetadataTable();
        String tName=iconn.getName();
        if (tName.equals(inputTableName) && metadataTable != null) {
          String tableName=metadataTable.getTableName();
          String tableColneName=tableName;
          tableColneName=MetadataToolHelper.validateTableName(tableColneName);
          if (inputTableName.contains("String_Node_Str") && tableName != null) {
            MapExpressionParser mapParser2=new MapExpressionParser("String_Node_Str");
            List<Map<String,String>> tableNameList=mapParser2.parseInTableEntryLocations(inputTableName);
            for (            Map<String,String> tableNameMap : tableNameList) {
              Set<Entry<String,String>> setTable=tableNameMap.entrySet();
              Iterator<Entry<String,String>> iteTable=setTable.iterator();
              while (iteTable.hasNext()) {
                Entry<String,String> tableEntry=iteTable.next();
                String tableLabel=tableEntry.getKey();
                String schemaValue=tableEntry.getValue();
                if (tableLabel.equals(metadataTable.getLabel()) && tableColneName.equals(tableLabel)) {
                  sb.append(schemaValue);
                  sb.append("String_Node_Str");
                  sb.append(tableName);
                  replace=true;
                }
              }
            }
          }
 else           if (tableName != null) {
            if (inputTableName.equals(metadataTable.getLabel()) && tableColneName.equals(inputTableName)) {
              sb.append(tableName);
              replace=true;
            }
          }
        }
      }
    }
    if (!replace) {
      sb.append(addQuit(inputTable.getName()));
    }
  }
}

Fixed version (ground truth):
protected void buildTableDeclaration(DbMapComponent component,StringBuilder sb,ExternalDbMapTable inputTable){
  String inputTableName=inputTable.getName();
  List<IConnection> inputConnections=(List<IConnection>)component.getIncomingConnections();
  boolean replace=false;
  if (inputConnections != null) {
    for (    IConnection iconn : inputConnections) {
      IMetadataTable metadataTable=iconn.getMetadataTable();
      String tName=iconn.getName();
      if (tName.equals(inputTableName) && metadataTable != null) {
        String tableName=metadataTable.getTableName();
        String tableColneName=tableName;
        tableColneName=MetadataToolHelper.validateTableName(tableColneName);
        if (inputTableName.contains("String_Node_Str") && tableName != null) {
          MapExpressionParser mapParser2=new MapExpressionParser("String_Node_Str");
          List<Map<String,String>> tableNameList=mapParser2.parseInTableEntryLocations(inputTableName);
          for (          Map<String,String> tableNameMap : tableNameList) {
            Set<Entry<String,String>> setTable=tableNameMap.entrySet();
            Iterator<Entry<String,String>> iteTable=setTable.iterator();
            while (iteTable.hasNext()) {
              Entry<String,String> tableEntry=iteTable.next();
              String tableLabel=tableEntry.getKey();
              String schemaValue=tableEntry.getValue();
              if (tableLabel.equals(metadataTable.getLabel()) && tableColneName.equals(tableLabel)) {
                sb.append(schemaValue);
                sb.append("String_Node_Str");
                sb.append(tableName);
                replace=true;
              }
            }
          }
        }
 else         if (tableName != null) {
          if (inputTableName.equals(metadataTable.getLabel()) && tableColneName.equals(inputTableName)) {
            sb.append(tableName);
            replace=true;
          }
        }
      }
    }
  }
  if (!replace) {
    sb.append(inputTable.getName());
  }
}