Program: 125538
Project: 125538
Buggy source:
@Override public List<TdColumn> fillColumns(ColumnSet colSet,DatabaseMetaData dbJDBCMetadata,List<String> columnFilter,String columnPattern){
  if (colSet == null || dbJDBCMetadata == null) {
    return null;
  }
  List<TdColumn> returnColumns=new ArrayList<TdColumn>();
  Map<String,TdColumn> columnMap=new HashMap<String,TdColumn>();
  String typeName=null;
  ExtractMetaDataUtils extractMeta=ExtractMetaDataUtils.getInstance();
  try {
    String catalogName=getName(CatalogHelper.getParentCatalog(colSet));
    Schema schema=SchemaHelper.getParentSchema(colSet);
    if (catalogName == null && schema != null) {
      catalogName=getName(CatalogHelper.getParentCatalog(schema));
    }
    String schemaPattern=getName(schema);
    schemaPattern="String_Node_Str".equals(schemaPattern) ? null : schemaPattern;
    String tablePattern=getName(colSet);
    boolean isOracle=MetadataConnectionUtils.isOracle(dbJDBCMetadata);
    if (isOracle && tablePattern.contains("String_Node_Str")) {
      tablePattern=tablePattern.replaceAll("String_Node_Str","String_Node_Str");
    }
    ResultSet columns=dbJDBCMetadata.getColumns(catalogName,schemaPattern,tablePattern,columnPattern);
    boolean isOdbcTeradata=ConnectionUtils.isOdbcTeradata(dbJDBCMetadata);
    MappingTypeRetriever mappingTypeRetriever=null;
    DatabaseConnection dbConnection=(DatabaseConnection)ConnectionHelper.getConnection(colSet);
    String dbmsId=JavaSqlFactory.getDbmsId(dbConnection);
    if (StringUtils.isBlank(dbmsId)) {
      log.error(Messages.getString("String_Node_Str"));
    }
 else {
      mappingTypeRetriever=MetadataTalendType.getMappingTypeRetriever(dbmsId);
    }
    if (mappingTypeRetriever == null) {
      EDatabaseTypeName dbType=EDatabaseTypeName.getTypeFromDbType(dbConnection.getDatabaseType(),false);
      if (dbType != null) {
        mappingTypeRetriever=MetadataTalendType.getMappingTypeRetrieverByProduct(dbType.getProduct());
      }
    }
    while (columns.next()) {
      int decimalDigits=0;
      int numPrecRadix=0;
      String fetchTableName=extractMeta.getStringMetaDataInfo(columns,ExtractManager.TABLE_NAME,null);
      fetchTableName=ManagementTextUtils.filterSpecialChar(fetchTableName);
      if (fetchTableName.equals(tablePattern)) {
        String columnName=getStringFromResultSet(columns,GetColumn.COLUMN_NAME.name());
        TdColumn column=ColumnHelper.createTdColumn(columnName);
        int dataType=0;
        try {
          typeName=getStringFromResultSet(columns,GetColumn.TYPE_NAME.name());
          typeName=typeName.toUpperCase().trim();
          typeName=ManagementTextUtils.filterSpecialChar(typeName);
          if (typeName.startsWith("String_Node_Str")) {
            typeName="String_Node_Str";
          }
          typeName=MetadataToolHelper.validateValueForDBType(typeName);
          if (dbJDBCMetadata instanceof DB2ForZosDataBaseMetadata) {
            dataType=Java2SqlType.getJavaTypeBySqlType(typeName);
            decimalDigits=getIntFromResultSet(columns,GetColumn.DECIMAL_DIGITS.name());
          }
 else           if (dbJDBCMetadata instanceof TeradataDataBaseMetadata) {
            dataType=Java2SqlType.getTeradataJavaTypeBySqlTypeAsInt(typeName);
            typeName=Java2SqlType.getTeradataJavaTypeBySqlTypeAsString(typeName);
          }
 else {
            dataType=getIntFromResultSet(columns,GetColumn.DATA_TYPE.name());
            if (!isOdbcTeradata) {
              numPrecRadix=getIntFromResultSet(columns,GetColumn.NUM_PREC_RADIX.name());
              decimalDigits=getIntFromResultSet(columns,GetColumn.DECIMAL_DIGITS.name());
            }
          }
          if (MetadataConnectionUtils.isMssql(dbJDBCMetadata)) {
            if (typeName.toLowerCase().equals("String_Node_Str")) {
              dataType=91;
            }
 else             if (typeName.toLowerCase().equals("String_Node_Str")) {
              dataType=92;
            }
          }
          if (!isOdbcTeradata) {
            int column_size=getIntFromResultSet(columns,GetColumn.COLUMN_SIZE.name());
            column.setLength(column_size);
          }
        }
 catch (        Exception e1) {
          log.warn(e1,e1);
        }
        TdSqlDataType sqlDataType=MetadataConnectionUtils.createDataType(dataType,typeName,decimalDigits,numPrecRadix);
        column.setSqlDataType(sqlDataType);
        int nullable=0;
        if (dbJDBCMetadata instanceof DB2ForZosDataBaseMetadata || dbJDBCMetadata instanceof TeradataDataBaseMetadata || dbJDBCMetadata instanceof EmbeddedHiveDataBaseMetadata) {
          String isNullable=getStringFromResultSet(columns,"String_Node_Str");
          if (!isNullable.equals("String_Node_Str")) {
            nullable=1;
          }
        }
 else {
          nullable=getIntFromResultSet(columns,GetColumn.NULLABLE.name());
        }
        column.getSqlDataType().setNullable(NullableType.get(nullable));
        Object defaultvalue=null;
        try {
          if (!isOdbcTeradata) {
            defaultvalue=columns.getObject(GetColumn.COLUMN_DEF.name());
          }
        }
 catch (        Exception e1) {
          log.warn(e1,e1);
        }
        String defaultStr=(defaultvalue != null) ? String.valueOf(defaultvalue) : null;
        TdExpression defExpression=createTdExpression(GetColumn.COLUMN_DEF.name(),defaultStr);
        column.setInitialValue(defExpression);
        extractMeta.handleDefaultValue(column,dbJDBCMetadata);
        if (mappingTypeRetriever != null) {
          String talendType=mappingTypeRetriever.getDefaultSelectedTalendType(typeName,extractMeta.getIntMetaDataInfo(columns,"String_Node_Str"),(dbJDBCMetadata instanceof TeradataDataBaseMetadata) ? 0 : extractMeta.getIntMetaDataInfo(columns,"String_Node_Str"));
          column.setTalendType(talendType);
          String defaultSelectedDbType=mappingTypeRetriever.getDefaultSelectedDbType(talendType);
          column.setSourceType(defaultSelectedDbType);
        }
        String colComment=getColumnComment(dbJDBCMetadata,columns,tablePattern,column.getName(),schemaPattern);
        ColumnHelper.setComment(colComment,column);
        try {
          column.setNullable(nullable == 1);
        }
 catch (        Exception e) {
        }
        returnColumns.add(column);
        columnMap.put(columnName,column);
      }
    }
    columns.close();
    if (isLinked()) {
      ColumnSetHelper.addColumns(colSet,returnColumns);
    }
    fillPkandFk(colSet,columnMap,dbJDBCMetadata,catalogName,schemaPattern,tablePattern);
  }
 catch (  Exception e) {
    log.error(e,e);
  }
  return returnColumns;
}

Fixed version (ground truth):
@Override public List<TdColumn> fillColumns(ColumnSet colSet,DatabaseMetaData dbJDBCMetadata,List<String> columnFilter,String columnPattern){
  if (colSet == null || dbJDBCMetadata == null) {
    return null;
  }
  List<TdColumn> returnColumns=new ArrayList<TdColumn>();
  Map<String,TdColumn> columnMap=new HashMap<String,TdColumn>();
  String typeName=null;
  ExtractMetaDataUtils extractMeta=ExtractMetaDataUtils.getInstance();
  try {
    String catalogName=getName(CatalogHelper.getParentCatalog(colSet));
    Schema schema=SchemaHelper.getParentSchema(colSet);
    if (catalogName == null && schema != null) {
      catalogName=getName(CatalogHelper.getParentCatalog(schema));
    }
    String schemaPattern=getName(schema);
    schemaPattern="String_Node_Str".equals(schemaPattern) ? null : schemaPattern;
    String tablePattern=getName(colSet);
    boolean isOracle=MetadataConnectionUtils.isOracle(dbJDBCMetadata);
    if (isOracle && tablePattern.contains("String_Node_Str")) {
      tablePattern=tablePattern.replaceAll("String_Node_Str","String_Node_Str");
    }
    ResultSet columns=dbJDBCMetadata.getColumns(catalogName,schemaPattern,tablePattern,columnPattern);
    boolean isOdbcTeradata=ConnectionUtils.isOdbcTeradata(dbJDBCMetadata);
    MappingTypeRetriever mappingTypeRetriever=null;
    DatabaseConnection dbConnection=(DatabaseConnection)ConnectionHelper.getConnection(colSet);
    String dbmsId=JavaSqlFactory.getDbmsId(dbConnection);
    if (StringUtils.isBlank(dbmsId)) {
      log.error(Messages.getString("String_Node_Str"));
    }
 else {
      mappingTypeRetriever=MetadataTalendType.getMappingTypeRetriever(dbmsId);
    }
    if (mappingTypeRetriever == null) {
      EDatabaseTypeName dbType=EDatabaseTypeName.getTypeFromDbType(dbConnection.getDatabaseType(),false);
      if (dbType != null) {
        mappingTypeRetriever=MetadataTalendType.getMappingTypeRetrieverByProduct(dbType.getProduct());
      }
    }
    while (columns.next()) {
      int decimalDigits=0;
      int numPrecRadix=0;
      String fetchTableName=extractMeta.getStringMetaDataInfo(columns,ExtractManager.TABLE_NAME,null);
      fetchTableName=ManagementTextUtils.filterSpecialChar(fetchTableName);
      String databaseType=dbConnection.getDatabaseType();
      if (fetchTableName.equals(tablePattern) || databaseType.equals(EDatabaseTypeName.SQLITE.getDisplayName())) {
        String columnName=getStringFromResultSet(columns,GetColumn.COLUMN_NAME.name());
        TdColumn column=ColumnHelper.createTdColumn(columnName);
        int dataType=0;
        try {
          typeName=getStringFromResultSet(columns,GetColumn.TYPE_NAME.name());
          typeName=typeName.toUpperCase().trim();
          typeName=ManagementTextUtils.filterSpecialChar(typeName);
          if (typeName.startsWith("String_Node_Str")) {
            typeName="String_Node_Str";
          }
          typeName=MetadataToolHelper.validateValueForDBType(typeName);
          if (dbJDBCMetadata instanceof DB2ForZosDataBaseMetadata) {
            dataType=Java2SqlType.getJavaTypeBySqlType(typeName);
            decimalDigits=getIntFromResultSet(columns,GetColumn.DECIMAL_DIGITS.name());
          }
 else           if (dbJDBCMetadata instanceof TeradataDataBaseMetadata) {
            dataType=Java2SqlType.getTeradataJavaTypeBySqlTypeAsInt(typeName);
            typeName=Java2SqlType.getTeradataJavaTypeBySqlTypeAsString(typeName);
          }
 else {
            dataType=getIntFromResultSet(columns,GetColumn.DATA_TYPE.name());
            if (!isOdbcTeradata) {
              numPrecRadix=getIntFromResultSet(columns,GetColumn.NUM_PREC_RADIX.name());
              decimalDigits=getIntFromResultSet(columns,GetColumn.DECIMAL_DIGITS.name());
            }
          }
          if (MetadataConnectionUtils.isMssql(dbJDBCMetadata)) {
            if (typeName.toLowerCase().equals("String_Node_Str")) {
              dataType=91;
            }
 else             if (typeName.toLowerCase().equals("String_Node_Str")) {
              dataType=92;
            }
          }
          if (!isOdbcTeradata) {
            int column_size=getIntFromResultSet(columns,GetColumn.COLUMN_SIZE.name());
            column.setLength(column_size);
          }
        }
 catch (        Exception e1) {
          log.warn(e1,e1);
        }
        TdSqlDataType sqlDataType=MetadataConnectionUtils.createDataType(dataType,typeName,decimalDigits,numPrecRadix);
        column.setSqlDataType(sqlDataType);
        int nullable=0;
        if (dbJDBCMetadata instanceof DB2ForZosDataBaseMetadata || dbJDBCMetadata instanceof TeradataDataBaseMetadata || dbJDBCMetadata instanceof EmbeddedHiveDataBaseMetadata) {
          String isNullable=getStringFromResultSet(columns,"String_Node_Str");
          if (!isNullable.equals("String_Node_Str")) {
            nullable=1;
          }
        }
 else {
          nullable=getIntFromResultSet(columns,GetColumn.NULLABLE.name());
        }
        column.getSqlDataType().setNullable(NullableType.get(nullable));
        Object defaultvalue=null;
        try {
          if (!isOdbcTeradata) {
            defaultvalue=columns.getObject(GetColumn.COLUMN_DEF.name());
          }
        }
 catch (        Exception e1) {
          log.warn(e1,e1);
        }
        String defaultStr=(defaultvalue != null) ? String.valueOf(defaultvalue) : null;
        TdExpression defExpression=createTdExpression(GetColumn.COLUMN_DEF.name(),defaultStr);
        column.setInitialValue(defExpression);
        extractMeta.handleDefaultValue(column,dbJDBCMetadata);
        if (mappingTypeRetriever != null) {
          String talendType=mappingTypeRetriever.getDefaultSelectedTalendType(typeName,extractMeta.getIntMetaDataInfo(columns,"String_Node_Str"),(dbJDBCMetadata instanceof TeradataDataBaseMetadata) ? 0 : extractMeta.getIntMetaDataInfo(columns,"String_Node_Str"));
          column.setTalendType(talendType);
          String defaultSelectedDbType=mappingTypeRetriever.getDefaultSelectedDbType(talendType);
          column.setSourceType(defaultSelectedDbType);
        }
        String colComment=getColumnComment(dbJDBCMetadata,columns,tablePattern,column.getName(),schemaPattern);
        ColumnHelper.setComment(colComment,column);
        try {
          column.setNullable(nullable == 1);
        }
 catch (        Exception e) {
        }
        returnColumns.add(column);
        columnMap.put(columnName,column);
      }
    }
    columns.close();
    if (isLinked()) {
      ColumnSetHelper.addColumns(colSet,returnColumns);
    }
    fillPkandFk(colSet,columnMap,dbJDBCMetadata,catalogName,schemaPattern,tablePattern);
  }
 catch (  Exception e) {
    log.error(e,e);
  }
  return returnColumns;
}