Program: 125689
Project: 125689
Buggy source:
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();
  MetadataFillFactory dbInstance=MetadataFillFactory.getDBInstance(metadataconnection);
  if (EDatabaseTypeName.HIVE.getXmlName().equalsIgnoreCase(dbType)) {
    DatabaseMetaData dm=null;
    try {
      dm=HiveConnectionManager.getInstance().extractDatabaseMetaData(metadataConnection);
      dbInstance.fillCatalogs(dbConn,dm,metadataConnection,MetadataConnectionUtils.getPackageFilter(dbConn,dm,true));
      dbInstance.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());
        dbInstance.fillCatalogs(dbConn,dm,MetadataConnectionUtils.getPackageFilter(dbConn,dm,true));
        dbInstance.fillSchemas(dbConn,dm,MetadataConnectionUtils.getPackageFilter(dbConn,dm,false));
      }
    }
 catch (    Exception e) {
      ExceptionHandler.process(e);
    }
 finally {
      if (sqlConn != null) {
        ConnectionUtils.closeConnection(sqlConn);
      }
      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();
  MetadataFillFactory dbInstance=MetadataFillFactory.getDBInstance(metadataconnection);
  if (EDatabaseTypeName.HIVE.getXmlName().equalsIgnoreCase(dbType)) {
    DatabaseMetaData dm=null;
    try {
      dm=HiveConnectionManager.getInstance().extractDatabaseMetaData(metadataConnection);
      dbInstance.fillCatalogs(dbConn,dm,metadataConnection,MetadataConnectionUtils.getPackageFilter(dbConn,dm,true));
      dbInstance.fillSchemas(dbConn,dm,metadataConnection,MetadataConnectionUtils.getPackageFilter(dbConn,dm,false));
    }
 catch (    Exception e) {
      ExceptionHandler.process(e);
    }
  }
 else   if (EDatabaseTypeName.IMPALA.getDisplayName().equals(dbType)) {
    Connection conn=null;
    try {
      conn=ImpalaConnectionManager.getInstance().createConnection(metadataConnection);
      DatabaseMetaData dm=conn.getMetaData();
      dbInstance.fillCatalogs(dbConn,dm,metadataConnection,MetadataConnectionUtils.getPackageFilter(dbConn,dm,true));
      dbInstance.fillSchemas(dbConn,dm,metadataConnection,MetadataConnectionUtils.getPackageFilter(dbConn,dm,false));
    }
 catch (    Exception e) {
      ExceptionHandler.process(e);
    }
 finally {
      if (sqlConn != null) {
        ConnectionUtils.closeConnection(sqlConn);
      }
    }
  }
 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());
        dbInstance.fillCatalogs(dbConn,dm,MetadataConnectionUtils.getPackageFilter(dbConn,dm,true));
        dbInstance.fillSchemas(dbConn,dm,MetadataConnectionUtils.getPackageFilter(dbConn,dm,false));
      }
    }
 catch (    Exception e) {
      ExceptionHandler.process(e);
    }
 finally {
      if (sqlConn != null) {
        ConnectionUtils.closeConnection(sqlConn);
      }
      if (derbyDriver != null) {
        try {
          derbyDriver.connect("String_Node_Str",null);
        }
 catch (        SQLException e) {
        }
      }
    }
  }
}