Program: 127637
Project: 127637
Buggy source:
protected List<TdColumn> extractColumns(DatabaseMetaData dbMetaData,IMetadataConnection metadataConnection,String databaseType,String catalogName,String schemaName,String tableName){
  MappingTypeRetriever mappingTypeRetriever=null;
  columnIndex=0;
  List<TdColumn> metadataColumns=new ArrayList<TdColumn>();
  List<String> columnLabels=new ArrayList<String>();
  Map<String,String> primaryKeys=new HashMap<String,String>();
  ResultSet columns=null;
  Statement stmt=null;
  String tablePattern=tableName;
  try {
    if (MetadataConnectionUtils.isMysql(dbMetaData)) {
      tablePattern="String_Node_Str" + tablePattern + "String_Node_Str";
    }
    boolean isAccess=EDatabaseTypeName.ACCESS.getDisplayName().equals(metadataConnection.getDbType());
    if (isAccess) {
      primaryKeys=retrievePrimaryKeys(dbMetaData,null,null,tablePattern);
    }
 else {
      primaryKeys=retrievePrimaryKeys(dbMetaData,catalogName,schemaName,tablePattern);
    }
    columns=getColumnsResultSet(dbMetaData,catalogName,schemaName,tablePattern);
    IRepositoryService repositoryService=CoreRuntimePlugin.getInstance().getRepositoryService();
    while (columns.next()) {
      Boolean b=false;
      String fetchTableName=ExtractMetaDataUtils.getStringMetaDataInfo(columns,ExtractManager.TABLE_NAME,null);
      fetchTableName=ManagementTextUtils.filterSpecialChar(fetchTableName);
      if (fetchTableName.equals(tableName) || databaseType.equals(EDatabaseTypeName.SQLITE.getDisplayName())) {
        TdColumn metadataColumn=RelationalFactory.eINSTANCE.createTdColumn();
        String label=ExtractMetaDataUtils.getStringMetaDataInfo(columns,"String_Node_Str",null);
        label=ManagementTextUtils.filterSpecialChar(label);
        String sub="String_Node_Str";
        String sub2="String_Node_Str";
        String label2=label;
        if (label != null && label.length() > 0 && label.startsWith("String_Node_Str")) {
          sub=label.substring(1);
          if (sub != null && sub.length() > 0) {
            sub2=sub.substring(1);
          }
        }
        if (coreService != null && (coreService.isKeyword(label) || coreService.isKeyword(sub) || coreService.isKeyword(sub2))) {
          label="String_Node_Str" + label;
          b=true;
        }
        metadataColumn.setLabel(label);
        metadataColumn.setOriginalField(label2);
        label=MetadataToolHelper.validateColumnName(label,columnIndex,columnLabels);
        metadataColumn.setLabel(label);
        columnIndex++;
        if (primaryKeys != null && !primaryKeys.isEmpty() && primaryKeys.get(metadataColumn.getOriginalField()) != null) {
          metadataColumn.setKey(true);
        }
 else {
          metadataColumn.setKey(false);
        }
        String typeName="String_Node_Str";
        if (ExtractMetaDataUtils.isUseAllSynonyms()) {
          typeName="String_Node_Str";
        }
        String dbType=ExtractMetaDataUtils.getStringMetaDataInfo(columns,typeName,null).toUpperCase();
        dbType=dbType.trim();
        dbType=ManagementTextUtils.filterSpecialChar(dbType);
        dbType=handleDBtype(dbType);
        metadataColumn.setSourceType(dbType);
        Integer columnSize;
        columnSize=ExtractMetaDataUtils.getIntMetaDataInfo(columns,"String_Node_Str");
        metadataColumn.setLength(columnSize);
        String talendType=null;
        if (metadataConnection.getMapping() != null) {
          mappingTypeRetriever=MetadataTalendType.getMappingTypeRetriever(metadataConnection.getMapping());
        }
        Integer intMetaDataInfo=ExtractMetaDataUtils.getIntMetaDataInfo(columns,"String_Node_Str");
        talendType=mappingTypeRetriever.getDefaultSelectedTalendType(dbType,columnSize,intMetaDataInfo);
        talendType=ManagementTextUtils.filterSpecialChar(talendType);
        if (talendType == null) {
          if (LanguageManager.getCurrentLanguage() == ECodeLanguage.JAVA) {
            talendType=JavaTypesManager.getDefaultJavaType().getId();
            log.warn(Messages.getString("String_Node_Str",dbType));
          }
        }
 else {
        }
        metadataColumn.setTalendType(talendType);
        String stringMetaDataInfo=ExtractMetaDataUtils.getStringMetaDataInfo(columns,"String_Node_Str",dbMetaData);
        boolean isNullable=ExtractMetaDataUtils.getBooleanMetaDataInfo(columns,"String_Node_Str");
        metadataColumn.setNullable(isNullable);
        String commentInfo=ExtractMetaDataUtils.getStringMetaDataInfo(columns,ExtractManager.REMARKS,null);
        if (commentInfo != null && commentInfo.length() > 0) {
          commentInfo=ManagementTextUtils.filterSpecialChar(commentInfo);
        }
        metadataColumn.setComment(commentInfo);
        addColumnAttributes(metadataConnection,columns,metadataColumn,label,label2,dbType,columnSize,intMetaDataInfo,commentInfo);
        checkPrecision(metadataColumn,tableName,dbType,intMetaDataInfo);
        if (stringMetaDataInfo != null && stringMetaDataInfo.length() > 0 && stringMetaDataInfo.charAt(0) == 0x0) {
          stringMetaDataInfo="String_Node_Str";
        }
        stringMetaDataInfo=ManagementTextUtils.filterSpecialChar(stringMetaDataInfo);
        metadataColumn.setDefaultValue(stringMetaDataInfo);
        ExtractMetaDataUtils.handleDefaultValue(metadataColumn,dbMetaData);
        checkTypeForTimestamp(metadataConnection,metadataColumn,dbType);
        metadataColumns.add(metadataColumn);
        columnLabels.add(metadataColumn.getLabel());
      }
    }
    checkComments(metadataConnection,tableName,metadataColumns);
  }
 catch (  SQLException e) {
    ExceptionHandler.process(e);
    log.error(e.toString());
    throw new RuntimeException(e);
  }
catch (  Exception e) {
    ExceptionHandler.process(e);
    log.error(e.toString());
    throw new RuntimeException(e);
  }
 finally {
    try {
      if (columns != null) {
        columns.close();
      }
      if (stmt != null) {
        stmt.close();
      }
    }
 catch (    SQLException e) {
      log.error(e.toString());
    }
  }
  return metadataColumns;
}

Fixed version (ground truth):
protected List<TdColumn> extractColumns(DatabaseMetaData dbMetaData,IMetadataConnection metadataConnection,String databaseType,String catalogName,String schemaName,String tableName){
  MappingTypeRetriever mappingTypeRetriever=null;
  columnIndex=0;
  List<TdColumn> metadataColumns=new ArrayList<TdColumn>();
  List<String> columnLabels=new ArrayList<String>();
  Map<String,String> primaryKeys=new HashMap<String,String>();
  ResultSet columns=null;
  Statement stmt=null;
  String tablePattern=tableName;
  try {
    if (MetadataConnectionUtils.isMysql(dbMetaData)) {
      tablePattern="String_Node_Str" + tablePattern + "String_Node_Str";
    }
    boolean isAccess=EDatabaseTypeName.ACCESS.getDisplayName().equals(metadataConnection.getDbType());
    if (isAccess) {
      primaryKeys=retrievePrimaryKeys(dbMetaData,null,null,tableName);
    }
 else {
      primaryKeys=retrievePrimaryKeys(dbMetaData,catalogName,schemaName,tableName);
    }
    columns=getColumnsResultSet(dbMetaData,catalogName,schemaName,tablePattern);
    IRepositoryService repositoryService=CoreRuntimePlugin.getInstance().getRepositoryService();
    while (columns.next()) {
      Boolean b=false;
      String fetchTableName=ExtractMetaDataUtils.getStringMetaDataInfo(columns,ExtractManager.TABLE_NAME,null);
      fetchTableName=ManagementTextUtils.filterSpecialChar(fetchTableName);
      if (fetchTableName.equals(tableName) || databaseType.equals(EDatabaseTypeName.SQLITE.getDisplayName())) {
        TdColumn metadataColumn=RelationalFactory.eINSTANCE.createTdColumn();
        String label=ExtractMetaDataUtils.getStringMetaDataInfo(columns,"String_Node_Str",null);
        label=ManagementTextUtils.filterSpecialChar(label);
        String sub="String_Node_Str";
        String sub2="String_Node_Str";
        String label2=label;
        if (label != null && label.length() > 0 && label.startsWith("String_Node_Str")) {
          sub=label.substring(1);
          if (sub != null && sub.length() > 0) {
            sub2=sub.substring(1);
          }
        }
        if (coreService != null && (coreService.isKeyword(label) || coreService.isKeyword(sub) || coreService.isKeyword(sub2))) {
          label="String_Node_Str" + label;
          b=true;
        }
        metadataColumn.setLabel(label);
        metadataColumn.setOriginalField(label2);
        label=MetadataToolHelper.validateColumnName(label,columnIndex,columnLabels);
        metadataColumn.setLabel(label);
        columnIndex++;
        if (primaryKeys != null && !primaryKeys.isEmpty() && primaryKeys.get(metadataColumn.getOriginalField()) != null) {
          metadataColumn.setKey(true);
        }
 else {
          metadataColumn.setKey(false);
        }
        String typeName="String_Node_Str";
        if (ExtractMetaDataUtils.isUseAllSynonyms()) {
          typeName="String_Node_Str";
        }
        String dbType=ExtractMetaDataUtils.getStringMetaDataInfo(columns,typeName,null).toUpperCase();
        dbType=dbType.trim();
        dbType=ManagementTextUtils.filterSpecialChar(dbType);
        dbType=handleDBtype(dbType);
        metadataColumn.setSourceType(dbType);
        Integer columnSize;
        columnSize=ExtractMetaDataUtils.getIntMetaDataInfo(columns,"String_Node_Str");
        metadataColumn.setLength(columnSize);
        String talendType=null;
        if (metadataConnection.getMapping() != null) {
          mappingTypeRetriever=MetadataTalendType.getMappingTypeRetriever(metadataConnection.getMapping());
        }
        Integer intMetaDataInfo=ExtractMetaDataUtils.getIntMetaDataInfo(columns,"String_Node_Str");
        talendType=mappingTypeRetriever.getDefaultSelectedTalendType(dbType,columnSize,intMetaDataInfo);
        talendType=ManagementTextUtils.filterSpecialChar(talendType);
        if (talendType == null) {
          if (LanguageManager.getCurrentLanguage() == ECodeLanguage.JAVA) {
            talendType=JavaTypesManager.getDefaultJavaType().getId();
            log.warn(Messages.getString("String_Node_Str",dbType));
          }
        }
 else {
        }
        metadataColumn.setTalendType(talendType);
        String stringMetaDataInfo=ExtractMetaDataUtils.getStringMetaDataInfo(columns,"String_Node_Str",dbMetaData);
        boolean isNullable=ExtractMetaDataUtils.getBooleanMetaDataInfo(columns,"String_Node_Str");
        metadataColumn.setNullable(isNullable);
        String commentInfo=ExtractMetaDataUtils.getStringMetaDataInfo(columns,ExtractManager.REMARKS,null);
        if (commentInfo != null && commentInfo.length() > 0) {
          commentInfo=ManagementTextUtils.filterSpecialChar(commentInfo);
        }
        metadataColumn.setComment(commentInfo);
        addColumnAttributes(metadataConnection,columns,metadataColumn,label,label2,dbType,columnSize,intMetaDataInfo,commentInfo);
        checkPrecision(metadataColumn,tableName,dbType,intMetaDataInfo);
        if (stringMetaDataInfo != null && stringMetaDataInfo.length() > 0 && stringMetaDataInfo.charAt(0) == 0x0) {
          stringMetaDataInfo="String_Node_Str";
        }
        stringMetaDataInfo=ManagementTextUtils.filterSpecialChar(stringMetaDataInfo);
        metadataColumn.setDefaultValue(stringMetaDataInfo);
        ExtractMetaDataUtils.handleDefaultValue(metadataColumn,dbMetaData);
        checkTypeForTimestamp(metadataConnection,metadataColumn,dbType);
        metadataColumns.add(metadataColumn);
        columnLabels.add(metadataColumn.getLabel());
      }
    }
    checkComments(metadataConnection,tableName,metadataColumns);
  }
 catch (  SQLException e) {
    ExceptionHandler.process(e);
    log.error(e.toString());
    throw new RuntimeException(e);
  }
catch (  Exception e) {
    ExceptionHandler.process(e);
    log.error(e.toString());
    throw new RuntimeException(e);
  }
 finally {
    try {
      if (columns != null) {
        columns.close();
      }
      if (stmt != null) {
        stmt.close();
      }
    }
 catch (    SQLException e) {
      log.error(e.toString());
    }
  }
  return metadataColumns;
}