Program: 126660
Project: 126660
Buggy source:
/** 
 * DOC xqliu Comment method "fillDbConnectionInformation".
 * @param dbConn
 * @return
 */
public static DatabaseConnection fillDbConnectionInformation(DatabaseConnection dbConn,IMetadataConnection metadataConnection){
  boolean noStructureExists=ConnectionHelper.getAllCatalogs(dbConn).isEmpty() && ConnectionHelper.getAllSchemas(dbConn).isEmpty();
  java.sql.Connection sqlConn=null;
  try {
    if (noStructureExists) {
      IMetadataConnection metaConnection=metadataConnection;
      if (metadataConnection == null) {
        metaConnection=ConvertionHelper.convert(dbConn);
      }
      SupportDBUrlType currentDBUrlType=SupportDBUrlType.getDBTypeByKey(metaConnection.getDbType());
      MetadataFillFactory.getDBInstance(currentDBUrlType).fillUIConnParams(metaConnection,dbConn);
      sqlConn=MetadataConnectionUtils.createConnection(metaConnection).getObject();
      if (sqlConn != null) {
        DatabaseMetaData databaseMetaData=null;
        if (EDatabaseTypeName.HIVE.getXmlName().equalsIgnoreCase(metaConnection.getDbType())) {
          databaseMetaData=HiveConnectionManager.getInstance().extractDatabaseMetaData(metaConnection);
        }
 else {
          databaseMetaData=ExtractMetaDataUtils.getInstance().getDatabaseMetaData(sqlConn,dbConn,false);
        }
        if (sqlConn != null) {
          MetadataFillFactory.getDBInstance(currentDBUrlType).fillCatalogs(dbConn,databaseMetaData,metaConnection,MetadataConnectionUtils.getPackageFilter(dbConn,databaseMetaData,true));
          MetadataFillFactory.getDBInstance(currentDBUrlType).fillSchemas(dbConn,databaseMetaData,metaConnection,MetadataConnectionUtils.getPackageFilter(dbConn,databaseMetaData,false));
        }
      }
    }
  }
 catch (  Exception e) {
    log.error(e,e);
  }
 finally {
    if (sqlConn != null) {
      ConnectionUtils.closeConnection(sqlConn);
    }
    closeDerbyDriver();
  }
  return dbConn;
}

Fixed version (ground truth):
/** 
 * DOC xqliu Comment method "fillDbConnectionInformation".
 * @param dbConn
 * @return
 */
public static DatabaseConnection fillDbConnectionInformation(DatabaseConnection dbConn,IMetadataConnection metadataConnection){
  boolean noStructureExists=ConnectionHelper.getAllCatalogs(dbConn).isEmpty() && ConnectionHelper.getAllSchemas(dbConn).isEmpty();
  java.sql.Connection sqlConn=null;
  try {
    if (noStructureExists) {
      IMetadataConnection metaConnection=metadataConnection;
      if (metadataConnection == null) {
        metaConnection=ConvertionHelper.convert(dbConn);
      }
      EDatabaseTypeName currentEDatabaseType=EDatabaseTypeName.getTypeFromDbType(metaConnection.getDbType());
      if (currentEDatabaseType != null) {
        MetadataFillFactory dbInstance=MetadataFillFactory.getDBInstance(currentEDatabaseType);
        dbInstance.fillUIConnParams(metaConnection,dbConn);
        sqlConn=MetadataConnectionUtils.createConnection(metaConnection).getObject();
        if (sqlConn != null) {
          DatabaseMetaData databaseMetaData=null;
          if (EDatabaseTypeName.HIVE.getXmlName().equalsIgnoreCase(metaConnection.getDbType())) {
            databaseMetaData=HiveConnectionManager.getInstance().extractDatabaseMetaData(metaConnection);
          }
 else {
            databaseMetaData=ExtractMetaDataUtils.getInstance().getDatabaseMetaData(sqlConn,dbConn,false);
          }
          if (sqlConn != null) {
            MetadataFillFactory.getDBInstance(currentEDatabaseType).fillCatalogs(dbConn,databaseMetaData,metaConnection,MetadataConnectionUtils.getPackageFilter(dbConn,databaseMetaData,true));
            MetadataFillFactory.getDBInstance(currentEDatabaseType).fillSchemas(dbConn,databaseMetaData,metaConnection,MetadataConnectionUtils.getPackageFilter(dbConn,databaseMetaData,false));
          }
        }
      }
    }
  }
 catch (  Exception e) {
    log.error(e,e);
  }
 finally {
    if (sqlConn != null) {
      ConnectionUtils.closeConnection(sqlConn);
    }
    closeDerbyDriver();
  }
  return dbConn;
}