Program: 126457
Project: 126457
Buggy source:
/** 
 * DOC cantoine. Method to test DataBaseConnection.
 * @param dbVersionString
 * @param String driverClass
 * @param String urlString pwd
 * @param String username
 * @param String pwd
 * @return ConnectionStatus : the result of connection(boolean Result, String messageException)
 */
public static ConnectionStatus testConnection(String dbType,String url,String username,String pwd,String schema,final String driverClassName,final String driverJarPath,String dbVersionString,String additionalParam){
  Connection connection=null;
  ConnectionStatus connectionStatus=new ConnectionStatus();
  connectionStatus.setResult(false);
  DriverShim wapperDriver=null;
  try {
    List list=new ArrayList();
    list=ExtractMetaDataUtils.getInstance().connect(dbType,url,username,pwd,driverClassName,driverJarPath,dbVersionString,additionalParam);
    if (list != null && list.size() > 0) {
      for (int i=0; i < list.size(); i++) {
        if (list.get(i) instanceof Connection) {
          connection=(Connection)list.get(i);
        }
        if (list.get(i) instanceof DriverShim) {
          wapperDriver=(DriverShim)list.get(i);
        }
      }
    }
    if ((schema != null) && (schema.compareTo("String_Node_Str") != 0)) {
      final String product=EDatabaseTypeName.getTypeFromDisplayName(dbType).getProduct();
      final boolean equals=EDatabaseTypeName.ORACLEFORSID.getProduct().equals(product) || EDatabaseTypeName.TERADATA.getProduct().equals(product);
      if (!checkSchemaConnection(schema,connection,equals,dbType)) {
        connectionStatus.setMessageException(Messages.getString("String_Node_Str"));
        return connectionStatus;
      }
    }
    connectionStatus.setResult(true);
    connectionStatus.setMessageException(Messages.getString("String_Node_Str"));
  }
 catch (  SQLException e) {
    ExceptionHandler.process(e);
    connectionStatus.setMessageException(ExceptionUtils.getFullStackTrace(e));
  }
catch (  Exception e) {
    connectionStatus.setMessageException(ExceptionUtils.getFullStackTrace(e));
  }
 finally {
    if (connection != null) {
      ConnectionUtils.closeConnection(connection);
    }
    ExtractManager extractManager=ExtractManagerFactory.createByDisplayName(dbType);
    if (extractManager != null) {
      extractManager.closeConnection(null,wapperDriver);
      if (driverClassName.equals(EDatabase4DriverClassName.JAVADB_EMBEDED.getDriverClass())) {
        extractManager.closeConnectionForDerby(wapperDriver);
      }
    }
  }
  return connectionStatus;
}

Fixed version (ground truth):
/** 
 * DOC cantoine. Method to test DataBaseConnection.
 * @param dbVersionString
 * @param String driverClass
 * @param String urlString pwd
 * @param String username
 * @param String pwd
 * @return ConnectionStatus : the result of connection(boolean Result, String messageException)
 */
public static ConnectionStatus testConnection(String dbType,String url,String username,String pwd,String schema,final String driverClassName,final String driverJarPath,String dbVersionString,String additionalParam){
  Connection connection=null;
  ConnectionStatus connectionStatus=new ConnectionStatus();
  connectionStatus.setResult(false);
  DriverShim wapperDriver=null;
  try {
    List list=new ArrayList();
    list=ExtractMetaDataUtils.getInstance().connect(dbType,url,username,pwd,driverClassName,driverJarPath,dbVersionString,additionalParam);
    if (list != null && list.size() > 0) {
      for (int i=0; i < list.size(); i++) {
        if (list.get(i) instanceof Connection) {
          connection=(Connection)list.get(i);
        }
        if (list.get(i) instanceof DriverShim) {
          wapperDriver=(DriverShim)list.get(i);
        }
      }
    }
    if ((schema != null) && (schema.compareTo("String_Node_Str") != 0)) {
      final String product=EDatabaseTypeName.getTypeFromDisplayName(dbType).getProduct();
      final boolean equals=EDatabaseTypeName.ORACLEFORSID.getProduct().equals(product) || EDatabaseTypeName.TERADATA.getProduct().equals(product) || EDatabaseTypeName.VERTICA.getProduct().equals(product);
      if (!checkSchemaConnection(schema,connection,equals,dbType)) {
        connectionStatus.setMessageException(Messages.getString("String_Node_Str"));
        return connectionStatus;
      }
    }
    connectionStatus.setResult(true);
    connectionStatus.setMessageException(Messages.getString("String_Node_Str"));
  }
 catch (  SQLException e) {
    ExceptionHandler.process(e);
    connectionStatus.setMessageException(ExceptionUtils.getFullStackTrace(e));
  }
catch (  Exception e) {
    connectionStatus.setMessageException(ExceptionUtils.getFullStackTrace(e));
  }
 finally {
    if (connection != null) {
      ConnectionUtils.closeConnection(connection);
    }
    ExtractManager extractManager=ExtractManagerFactory.createByDisplayName(dbType);
    if (extractManager != null) {
      extractManager.closeConnection(null,wapperDriver);
      if (driverClassName.equals(EDatabase4DriverClassName.JAVADB_EMBEDED.getDriverClass())) {
        extractManager.closeConnectionForDerby(wapperDriver);
      }
    }
  }
  return connectionStatus;
}