Program: 125375
Project: 125375
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;
  ExtractMetaDataUtils extractMeta=ExtractMetaDataUtils.getInstance();
  try {
    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,tableName);
    if (MetadataConnectionUtils.isMysql(dbMetaData)) {
      boolean check=!Pattern.matches("String_Node_Str",tableName);
      if (check && !columns.next()) {
        columns=getColumnsResultSet(dbMetaData,catalogName,schemaName,TalendQuoteUtils.addQuotes(tableName,TalendQuoteUtils.ANTI_QUOTE));
      }
      columns.beforeFirst();
    }
    EDatabaseTypeName eDatabaseType=EDatabaseTypeName.getTypeFromDisplayName(databaseType);
    boolean isOracleProduct=false;
    if (eDatabaseType != null) {
      isOracleProduct="String_Node_Str".equalsIgnoreCase(eDatabaseType.getProduct());
    }
    boolean isUseAllSynonyms=extractMeta.isUseAllSynonyms();
    IRepositoryService repositoryService=CoreRuntimePlugin.getInstance().getRepositoryService();
    while (columns.next()) {
      Boolean b=false;
      String fetchTableName=extractMeta.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=extractMeta.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);
          }
        }
        final ICoreService coreService=getCoreService();
        if (coreService != null && (coreService.isKeyword(label) || coreService.isKeyword(sub) || coreService.isKeyword(sub2))) {
          label="String_Node_Str" + label;
          b=true;
        }
        label=MetadataToolHelper.validateColumnName(label,columnIndex,columnLabels);
        metadataColumn.setLabel(label);
        metadataColumn.setOriginalField(label2);
        columnIndex++;
        if (primaryKeys != null && !primaryKeys.isEmpty() && primaryKeys.get(metadataColumn.getOriginalField()) != null) {
          metadataColumn.setKey(true);
        }
 else {
          metadataColumn.setKey(false);
        }
        String typeName="String_Node_Str";
        if (isUseAllSynonyms) {
          typeName="String_Node_Str";
        }
        String dbType=extractMeta.getStringMetaDataInfo(columns,typeName,null).toUpperCase();
        if (EDatabaseTypeName.INFORMIX.getDisplayName().equals(metadataConnection.getDbType())) {
          String tn=MetadataConnectionUtils.getColumnTypeName(dbMetaData.getConnection(),fetchTableName,columnIndex);
          if (tn != null) {
            dbType=tn;
          }
        }
        dbType=dbType.toUpperCase().trim();
        dbType=ManagementTextUtils.filterSpecialChar(dbType);
        dbType=handleDBtype(dbType);
        metadataColumn.setSourceType(dbType);
        Integer columnSize=new Integer(0);
        Integer intMetaDataInfo=new Integer(0);
        if (isOracleProduct && isUseAllSynonyms) {
          setLengthAndPrecision(metadataColumn,columns,dbType);
          columnSize=(int)metadataColumn.getLength();
          intMetaDataInfo=(int)metadataColumn.getPrecision();
        }
 else {
          columnSize=extractMeta.getIntMetaDataInfo(columns,"String_Node_Str");
          metadataColumn.setLength(columnSize);
          intMetaDataInfo=extractMeta.getIntMetaDataInfo(columns,"String_Node_Str");
        }
        String talendType=null;
        if (metadataConnection.getMapping() != null) {
          mappingTypeRetriever=MetadataTalendType.getMappingTypeRetriever(metadataConnection.getMapping());
        }
        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="String_Node_Str";
        String commentInfo="String_Node_Str";
        if (isOracleProduct && isUseAllSynonyms) {
          metadataColumn.setNullable("String_Node_Str".equals(columns.getString(GetColumn.NULLABLE.name())));
          String defaultSelectedDbType=mappingTypeRetriever.getDefaultSelectedDbType(talendType);
          metadataColumn.setSourceType(defaultSelectedDbType);
        }
 else {
          metadataColumn.setNullable(extractMeta.getBooleanMetaDataInfo(columns,"String_Node_Str"));
          stringMetaDataInfo=extractMeta.getStringMetaDataInfo(columns,"String_Node_Str",dbMetaData);
          commentInfo=extractMeta.getStringMetaDataInfo(columns,ExtractManager.REMARKS,null);
          if (commentInfo != null && commentInfo.length() > 0) {
            commentInfo=ManagementTextUtils.filterSpecialChar(commentInfo);
          }
        }
        metadataColumn.setComment(commentInfo);
        if (isOracleProduct && isUseAllSynonyms) {
          metadataColumn.setName(label2);
        }
 else {
          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);
        extractMeta.handleDefaultValue(metadataColumn,dbMetaData);
        checkTypeForTimestamp(metadataConnection,metadataColumn,dbType);
        metadataColumns.add(metadataColumn);
        columnLabels.add(metadataColumn.getLabel());
      }
    }
    checkComments(metadataConnection,tableName,metadataColumns);
  }
 catch (  Exception e) {
    ExceptionHandler.process(e);
    Status status=new Status(IStatus.ERROR,"String_Node_Str",0,"String_Node_Str",e);
    ErrorDialog errorDialog=new ErrorDialog(null,"String_Node_Str",null,status,IStatus.ERROR);
    errorDialog.open();
    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;
  ExtractMetaDataUtils extractMeta=ExtractMetaDataUtils.getInstance();
  try {
    boolean isAccess=EDatabaseTypeName.ACCESS.getDisplayName().equals(metadataConnection.getDbType());
    if (isAccess) {
      primaryKeys=retrievePrimaryKeys(dbMetaData,null,null,tableName);
    }
 else {
      primaryKeys=retrievePrimaryKeys(dbMetaData,catalogName,schemaName,tableName);
    }
    synchroViewStructure(catalogName,schemaName,tableName);
    columns=getColumnsResultSet(dbMetaData,catalogName,schemaName,tableName);
    if (MetadataConnectionUtils.isMysql(dbMetaData)) {
      boolean check=!Pattern.matches("String_Node_Str",tableName);
      if (check && !columns.next()) {
        columns=getColumnsResultSet(dbMetaData,catalogName,schemaName,TalendQuoteUtils.addQuotes(tableName,TalendQuoteUtils.ANTI_QUOTE));
      }
      columns.beforeFirst();
    }
    EDatabaseTypeName eDatabaseType=EDatabaseTypeName.getTypeFromDisplayName(databaseType);
    boolean isOracleProduct=false;
    if (eDatabaseType != null) {
      isOracleProduct="String_Node_Str".equalsIgnoreCase(eDatabaseType.getProduct());
    }
    boolean isUseAllSynonyms=extractMeta.isUseAllSynonyms();
    IRepositoryService repositoryService=CoreRuntimePlugin.getInstance().getRepositoryService();
    while (columns.next()) {
      Boolean b=false;
      String fetchTableName=extractMeta.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=extractMeta.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);
          }
        }
        final ICoreService coreService=getCoreService();
        if (coreService != null && (coreService.isKeyword(label) || coreService.isKeyword(sub) || coreService.isKeyword(sub2))) {
          label="String_Node_Str" + label;
          b=true;
        }
        label=MetadataToolHelper.validateColumnName(label,columnIndex,columnLabels);
        metadataColumn.setLabel(label);
        metadataColumn.setOriginalField(label2);
        columnIndex++;
        if (primaryKeys != null && !primaryKeys.isEmpty() && primaryKeys.get(metadataColumn.getOriginalField()) != null) {
          metadataColumn.setKey(true);
        }
 else {
          metadataColumn.setKey(false);
        }
        String typeName="String_Node_Str";
        if (isUseAllSynonyms) {
          typeName="String_Node_Str";
        }
        String dbType=extractMeta.getStringMetaDataInfo(columns,typeName,null).toUpperCase();
        if (EDatabaseTypeName.INFORMIX.getDisplayName().equals(metadataConnection.getDbType())) {
          String tn=MetadataConnectionUtils.getColumnTypeName(dbMetaData.getConnection(),fetchTableName,columnIndex);
          if (tn != null) {
            dbType=tn;
          }
        }
        dbType=dbType.toUpperCase().trim();
        dbType=ManagementTextUtils.filterSpecialChar(dbType);
        dbType=handleDBtype(dbType);
        metadataColumn.setSourceType(dbType);
        Integer columnSize=new Integer(0);
        Integer intMetaDataInfo=new Integer(0);
        if (isOracleProduct && isUseAllSynonyms) {
          setLengthAndPrecision(metadataColumn,columns,dbType);
          columnSize=(int)metadataColumn.getLength();
          intMetaDataInfo=(int)metadataColumn.getPrecision();
        }
 else {
          columnSize=extractMeta.getIntMetaDataInfo(columns,"String_Node_Str");
          metadataColumn.setLength(columnSize);
          intMetaDataInfo=extractMeta.getIntMetaDataInfo(columns,"String_Node_Str");
        }
        String talendType=null;
        if (metadataConnection.getMapping() != null) {
          mappingTypeRetriever=MetadataTalendType.getMappingTypeRetriever(metadataConnection.getMapping());
        }
        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="String_Node_Str";
        String commentInfo="String_Node_Str";
        if (isOracleProduct && isUseAllSynonyms) {
          metadataColumn.setNullable("String_Node_Str".equals(columns.getString(GetColumn.NULLABLE.name())));
          String defaultSelectedDbType=mappingTypeRetriever.getDefaultSelectedDbType(talendType);
          metadataColumn.setSourceType(defaultSelectedDbType);
        }
 else {
          metadataColumn.setNullable(extractMeta.getBooleanMetaDataInfo(columns,"String_Node_Str"));
          stringMetaDataInfo=extractMeta.getStringMetaDataInfo(columns,"String_Node_Str",dbMetaData);
          commentInfo=extractMeta.getStringMetaDataInfo(columns,ExtractManager.REMARKS,null);
          if (commentInfo != null && commentInfo.length() > 0) {
            commentInfo=ManagementTextUtils.filterSpecialChar(commentInfo);
          }
        }
        metadataColumn.setComment(commentInfo);
        if (isOracleProduct && isUseAllSynonyms) {
          metadataColumn.setName(label2);
        }
 else {
          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);
        extractMeta.handleDefaultValue(metadataColumn,dbMetaData);
        checkTypeForTimestamp(metadataConnection,metadataColumn,dbType);
        metadataColumns.add(metadataColumn);
        columnLabels.add(metadataColumn.getLabel());
      }
    }
    checkComments(metadataConnection,tableName,metadataColumns);
  }
 catch (  Exception e) {
    ExceptionHandler.process(e);
    Status status=new Status(IStatus.ERROR,"String_Node_Str",0,"String_Node_Str",e);
    ErrorDialog errorDialog=new ErrorDialog(null,"String_Node_Str",null,status,IStatus.ERROR);
    errorDialog.open();
    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;
}