Program: 127353
Project: 127353
Buggy source:
public static void fillCatalogAndSchemas(IMetadataConnection iMetadataConnection,DatabaseConnection temConnection) throws ClassNotFoundException, InstantiationException, IllegalAccessException, SQLException {
  java.sql.Connection sqlConn=null;
  temConnection=(DatabaseConnection)MetadataFillFactory.getDBInstance().fillUIConnParams(iMetadataConnection,temConnection);
  sqlConn=MetadataConnectionUtils.checkConnection(iMetadataConnection).getObject();
  if (((DatabaseConnection)iMetadataConnection.getCurrentConnection()).getUiSchema() != null) {
    temConnection.setUiSchema(((DatabaseConnection)iMetadataConnection.getCurrentConnection()).getUiSchema());
  }
  if (((DatabaseConnection)iMetadataConnection.getCurrentConnection()).getSID() != null) {
    temConnection.setSID(((DatabaseConnection)iMetadataConnection.getCurrentConnection()).getSID());
  }
  String dbType=iMetadataConnection.getDbType();
  if (sqlConn != null) {
    DatabaseMetaData dbMetaData=null;
    if (EDatabaseTypeName.HIVE.getXmlName().equalsIgnoreCase(dbType)) {
      dbMetaData=HiveConnectionManager.getInstance().extractDatabaseMetaData(iMetadataConnection);
    }
 else {
      dbMetaData=ExtractMetaDataUtils.getDatabaseMetaData(sqlConn,dbType,false,iMetadataConnection.getDatabase());
    }
    MetadataFillFactory.getDBInstance().fillCatalogs(temConnection,dbMetaData,iMetadataConnection,MetadataConnectionUtils.getPackageFilter(temConnection,dbMetaData,true));
    MetadataFillFactory.getDBInstance().fillSchemas(temConnection,dbMetaData,iMetadataConnection,MetadataConnectionUtils.getPackageFilter(temConnection,dbMetaData,false));
  }
}

Fixed version (ground truth):
public static void fillCatalogAndSchemas(IMetadataConnection iMetadataConnection,DatabaseConnection temConnection) throws ClassNotFoundException, InstantiationException, IllegalAccessException, SQLException {
  java.sql.Connection sqlConn=null;
  temConnection=(DatabaseConnection)MetadataFillFactory.getDBInstance().fillUIConnParams(iMetadataConnection,temConnection);
  sqlConn=MetadataConnectionUtils.checkConnection(iMetadataConnection).getObject();
  if (((DatabaseConnection)iMetadataConnection.getCurrentConnection()).getUiSchema() != null) {
    temConnection.setUiSchema(((DatabaseConnection)iMetadataConnection.getCurrentConnection()).getUiSchema());
  }
  if (((DatabaseConnection)iMetadataConnection.getCurrentConnection()).getSID() != null) {
    temConnection.setSID(((DatabaseConnection)iMetadataConnection.getCurrentConnection()).getSID());
  }
  String dbType=iMetadataConnection.getDbType();
  if (sqlConn != null) {
    DatabaseMetaData dbMetaData=null;
    if (EDatabaseTypeName.HIVE.getXmlName().equalsIgnoreCase(dbType)) {
      dbMetaData=HiveConnectionManager.getInstance().extractDatabaseMetaData(iMetadataConnection);
    }
 else {
      dbMetaData=ExtractMetaDataUtils.getInstance().getDatabaseMetaData(sqlConn,dbType,false,iMetadataConnection.getDatabase());
    }
    MetadataFillFactory.getDBInstance().fillCatalogs(temConnection,dbMetaData,iMetadataConnection,MetadataConnectionUtils.getPackageFilter(temConnection,dbMetaData,true));
    MetadataFillFactory.getDBInstance().fillSchemas(temConnection,dbMetaData,iMetadataConnection,MetadataConnectionUtils.getPackageFilter(temConnection,dbMetaData,false));
  }
}