Program: 127345
Project: 127345
Buggy source:
private void updatePackage(IMetadataConnection metadataConnection){
  if (metadataConnection == null) {
    return;
  }
  Driver derbyDriver=null;
  Connection sqlConn=null;
  String dbType=metadataconnection.getDbType();
  DatabaseConnection dbConn=(DatabaseConnection)metadataconnection.getCurrentConnection();
  if (EDatabaseTypeName.HIVE.getXmlName().equalsIgnoreCase(dbType)) {
    DatabaseMetaData dm=null;
    try {
      dm=HiveConnectionManager.getInstance().extractDatabaseMetaData(metadataConnection);
      MetadataFillFactory.getDBInstance().fillCatalogs(dbConn,dm,metadataConnection,MetadataConnectionUtils.getPackageFilter(dbConn,dm,true));
      MetadataFillFactory.getDBInstance().fillSchemas(dbConn,dm,metadataConnection,MetadataConnectionUtils.getPackageFilter(dbConn,dm,false));
    }
 catch (    ClassNotFoundException e) {
      e.printStackTrace();
    }
catch (    InstantiationException e) {
      e.printStackTrace();
    }
catch (    IllegalAccessException e) {
      e.printStackTrace();
    }
catch (    SQLException e) {
      e.printStackTrace();
    }
  }
 else {
    List list=MetadataConnectionUtils.getConnection(metadataconnection);
    for (int i=0; i < list.size(); i++) {
      if (list.get(i) instanceof Driver) {
        String driverClass=metadataconnection.getDriverClass();
        if (MetadataConnectionUtils.isDerbyRelatedDb(driverClass,dbType)) {
          derbyDriver=(Driver)list.get(i);
        }
      }
      if (list.get(i) instanceof java.sql.Connection) {
        sqlConn=(java.sql.Connection)list.get(i);
      }
    }
    try {
      if (sqlConn != null) {
        DatabaseMetaData dm=ExtractMetaDataUtils.getDatabaseMetaData(sqlConn,dbType,false,metadataconnection.getDatabase());
        MetadataFillFactory.getDBInstance().fillCatalogs(dbConn,dm,MetadataConnectionUtils.getPackageFilter(dbConn,dm,true));
        MetadataFillFactory.getDBInstance().fillSchemas(dbConn,dm,MetadataConnectionUtils.getPackageFilter(dbConn,dm,false));
      }
    }
 catch (    Exception e) {
      ExceptionHandler.process(e);
    }
 finally {
      if (dbType != null && (dbType.equals(EDatabaseTypeName.HSQLDB.getDisplayName()) || dbType.equals(EDatabaseTypeName.HSQLDB_SERVER.getDisplayName()) || dbType.equals(EDatabaseTypeName.HSQLDB_WEBSERVER.getDisplayName())|| dbType.equals(EDatabaseTypeName.HSQLDB_IN_PROGRESS.getDisplayName())) || EDatabaseTypeName.HIVE.getDisplayName().equalsIgnoreCase(dbType)) {
        ExtractMetaDataUtils.closeConnection();
      }
      if (derbyDriver != null) {
        try {
          derbyDriver.connect("String_Node_Str",null);
        }
 catch (        SQLException e) {
        }
      }
    }
  }
}

Fixed version (ground truth):
private void updatePackage(IMetadataConnection metadataConnection){
  if (metadataConnection == null) {
    return;
  }
  Driver derbyDriver=null;
  Connection sqlConn=null;
  ExtractMetaDataUtils extractMeta=ExtractMetaDataUtils.getInstance();
  String dbType=metadataconnection.getDbType();
  DatabaseConnection dbConn=(DatabaseConnection)metadataconnection.getCurrentConnection();
  if (EDatabaseTypeName.HIVE.getXmlName().equalsIgnoreCase(dbType)) {
    DatabaseMetaData dm=null;
    try {
      dm=HiveConnectionManager.getInstance().extractDatabaseMetaData(metadataConnection);
      MetadataFillFactory.getDBInstance().fillCatalogs(dbConn,dm,metadataConnection,MetadataConnectionUtils.getPackageFilter(dbConn,dm,true));
      MetadataFillFactory.getDBInstance().fillSchemas(dbConn,dm,metadataConnection,MetadataConnectionUtils.getPackageFilter(dbConn,dm,false));
    }
 catch (    ClassNotFoundException e) {
      e.printStackTrace();
    }
catch (    InstantiationException e) {
      e.printStackTrace();
    }
catch (    IllegalAccessException e) {
      e.printStackTrace();
    }
catch (    SQLException e) {
      e.printStackTrace();
    }
  }
 else {
    List list=MetadataConnectionUtils.getConnection(metadataconnection);
    for (int i=0; i < list.size(); i++) {
      if (list.get(i) instanceof Driver) {
        String driverClass=metadataconnection.getDriverClass();
        if (MetadataConnectionUtils.isDerbyRelatedDb(driverClass,dbType)) {
          derbyDriver=(Driver)list.get(i);
        }
      }
      if (list.get(i) instanceof java.sql.Connection) {
        sqlConn=(java.sql.Connection)list.get(i);
      }
    }
    try {
      if (sqlConn != null) {
        DatabaseMetaData dm=extractMeta.getDatabaseMetaData(sqlConn,dbType,false,metadataconnection.getDatabase());
        MetadataFillFactory.getDBInstance().fillCatalogs(dbConn,dm,MetadataConnectionUtils.getPackageFilter(dbConn,dm,true));
        MetadataFillFactory.getDBInstance().fillSchemas(dbConn,dm,MetadataConnectionUtils.getPackageFilter(dbConn,dm,false));
      }
    }
 catch (    Exception e) {
      ExceptionHandler.process(e);
    }
 finally {
      if (dbType != null && (dbType.equals(EDatabaseTypeName.HSQLDB.getDisplayName()) || dbType.equals(EDatabaseTypeName.HSQLDB_SERVER.getDisplayName()) || dbType.equals(EDatabaseTypeName.HSQLDB_WEBSERVER.getDisplayName())|| dbType.equals(EDatabaseTypeName.HSQLDB_IN_PROGRESS.getDisplayName())) || EDatabaseTypeName.HIVE.getDisplayName().equalsIgnoreCase(dbType)) {
        extractMeta.closeConnection();
      }
      if (derbyDriver != null) {
        try {
          derbyDriver.connect("String_Node_Str",null);
        }
 catch (        SQLException e) {
        }
      }
    }
  }
}