Program: 120020
Project: 120020
Buggy source:
private void updatePackage(IMetadataConnection metadataConnectionTemp){
  if (metadataConnectionTemp == null) {
    return;
  }
  Driver derbyDriver=null;
  java.sql.Connection sqlConn=null;
  ExtractMetaDataUtils extractMeta=ExtractMetaDataUtils.getInstance();
  String dbType=metadataConnectionTemp.getDbType();
  DatabaseConnection dbConn=(DatabaseConnection)metadataConnectionTemp.getCurrentConnection();
  List list=MetadataConnectionUtils.getConnection(metadataConnectionTemp);
  for (int i=0; i < list.size(); i++) {
    if (list.get(i) instanceof Driver) {
      String driverClass=metadataConnectionTemp.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=null;
      if (EDatabaseTypeName.HIVE.getXmlName().equalsIgnoreCase(dbType)) {
        dm=HiveConnectionManager.getInstance().extractDatabaseMetaData(metadataConnectionTemp);
      }
 else {
        dm=extractMeta.getDatabaseMetaData(sqlConn,dbType,false,metadataConnectionTemp.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 {
    ConnectionUtils.closeConnection(sqlConn);
    if (derbyDriver != null) {
      try {
        derbyDriver.connect("String_Node_Str",null);
      }
 catch (      SQLException e) {
      }
    }
  }
}

Fixed version (ground truth):
private void updatePackage(IMetadataConnection metadataConnectionTemp){
  if (metadataConnectionTemp == null) {
    return;
  }
  Driver derbyDriver=null;
  java.sql.Connection sqlConn=null;
  ExtractMetaDataUtils extractMeta=ExtractMetaDataUtils.getInstance();
  String dbType=metadataConnectionTemp.getDbType();
  DatabaseConnection dbConn=(DatabaseConnection)metadataConnectionTemp.getCurrentConnection();
  List list=MetadataConnectionUtils.getConnection(metadataConnectionTemp);
  for (int i=0; i < list.size(); i++) {
    if (list.get(i) instanceof Driver) {
      String driverClass=metadataConnectionTemp.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=null;
      if (EDatabaseTypeName.HIVE.getXmlName().equalsIgnoreCase(dbType)) {
        dm=HiveConnectionManager.getInstance().extractDatabaseMetaData(metadataConnectionTemp);
      }
 else {
        dm=extractMeta.getDatabaseMetaData(sqlConn,dbType,false,metadataConnectionTemp.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 (sqlConn != null) {
      ConnectionUtils.closeConnection(sqlConn);
    }
    if (derbyDriver != null) {
      try {
        derbyDriver.connect("String_Node_Str",null);
      }
 catch (      SQLException e) {
      }
    }
  }
}