Program: 125688
Project: 125688
Buggy source:
/** 
 * DOC cantoine : Check connexion from IMetadataConnection comment. Detailled comment.
 * @return isValide
 */
public boolean check(IMetadataConnection metadataConnection,StringBuffer retProposedSchema,boolean... onlyIfNeeded){
  messageException=null;
  ConnectionStatus testConnection=null;
  if (metadataConnection == null) {
    return false;
  }
  if (onlyIfNeeded != null && onlyIfNeeded.length > 0 && onlyIfNeeded[0] == true) {
    if (metadataConnection.equals(oldConnection)) {
      return true;
    }
  }
  if (metadataConnection.getDbRootPath() != null && !metadataConnection.getDbRootPath().equals("String_Node_Str")) {
    setDbRootPath(metadataConnection.getDbRootPath());
  }
  try {
    EDatabaseTypeName type=EDatabaseTypeName.getTypeFromDbType(metadataConnection.getDbType());
    if (type.isUseProvider()) {
      IDBMetadataProvider extractorToUse=ExtractMetaDataFromDataBase.getProviderByDbType(metadataConnection.getDbType());
      if (extractorToUse != null) {
        testConnection=extractorToUse.testConnection(metadataConnection);
      }
    }
 else     if (EDatabaseTypeName.HIVE.getDisplayName().equals(metadataConnection.getDbType())) {
      String key=(String)metadataConnection.getParameter(ConnParameterKeys.CONN_PARA_KEY_HIVE_MODE);
      testConnection=new ConnectionStatus();
      testConnection.setResult(false);
      try {
        if (HiveModeInfo.get(key) == HiveModeInfo.EMBEDDED) {
          JavaSqlFactory.doHivePreSetup((DatabaseConnection)metadataConnection.getCurrentConnection());
        }
        HiveConnectionManager.getInstance().checkConnection(metadataConnection);
        testConnection.setResult(true);
      }
 catch (      Exception e) {
        testConnection.setResult(false);
        log.error(Messages.getString("String_Node_Str") + "String_Node_Str" + e.toString());
      }
    }
 else {
      testConnection=ExtractMetaDataFromDataBase.testConnection(metadataConnection.getDbType(),metadataConnection.getUrl(),metadataConnection.getUsername(),metadataConnection.getPassword(),metadataConnection.getSchema(),metadataConnection.getDriverClass(),metadataConnection.getDriverJarPath(),metadataConnection.getDbVersionString(),metadataConnection.getAdditionalParams(),retProposedSchema);
    }
    oldConnection=metadataConnection;
    isValide=testConnection.getResult();
    messageException=testConnection.getMessageException();
  }
 catch (  Exception e) {
    log.error(Messages.getString("String_Node_Str") + "String_Node_Str" + e.toString());
  }
  return isValide;
}

Fixed version (ground truth):
/** 
 * DOC cantoine : Check connexion from IMetadataConnection comment. Detailled comment.
 * @return isValide
 */
public boolean check(IMetadataConnection metadataConnection,StringBuffer retProposedSchema,boolean... onlyIfNeeded){
  messageException=null;
  ConnectionStatus testConnection=null;
  if (metadataConnection == null) {
    return false;
  }
  if (onlyIfNeeded != null && onlyIfNeeded.length > 0 && onlyIfNeeded[0] == true) {
    if (metadataConnection.equals(oldConnection)) {
      return true;
    }
  }
  if (metadataConnection.getDbRootPath() != null && !metadataConnection.getDbRootPath().equals("String_Node_Str")) {
    setDbRootPath(metadataConnection.getDbRootPath());
  }
  try {
    EDatabaseTypeName type=EDatabaseTypeName.getTypeFromDbType(metadataConnection.getDbType());
    if (type.isUseProvider()) {
      IDBMetadataProvider extractorToUse=ExtractMetaDataFromDataBase.getProviderByDbType(metadataConnection.getDbType());
      if (extractorToUse != null) {
        testConnection=extractorToUse.testConnection(metadataConnection);
      }
    }
 else     if (EDatabaseTypeName.HIVE.getDisplayName().equals(metadataConnection.getDbType())) {
      String key=(String)metadataConnection.getParameter(ConnParameterKeys.CONN_PARA_KEY_HIVE_MODE);
      testConnection=new ConnectionStatus();
      testConnection.setResult(false);
      try {
        if (HiveModeInfo.get(key) == HiveModeInfo.EMBEDDED) {
          JavaSqlFactory.doHivePreSetup((DatabaseConnection)metadataConnection.getCurrentConnection());
        }
        HiveConnectionManager.getInstance().checkConnection(metadataConnection);
        testConnection.setResult(true);
      }
 catch (      Exception e) {
        testConnection.setResult(false);
        log.error(Messages.getString("String_Node_Str") + "String_Node_Str" + e.toString());
      }
    }
 else     if (EDatabaseTypeName.IMPALA.getDisplayName().equals(metadataConnection.getDbType())) {
      testConnection=new ConnectionStatus();
      testConnection.setResult(false);
      try {
        ImpalaConnectionManager.getInstance().checkConnection(metadataConnection);
        testConnection.setResult(true);
      }
 catch (      Exception e) {
        testConnection.setResult(false);
        log.error(Messages.getString("String_Node_Str") + "String_Node_Str" + e.toString());
      }
    }
 else {
      testConnection=ExtractMetaDataFromDataBase.testConnection(metadataConnection.getDbType(),metadataConnection.getUrl(),metadataConnection.getUsername(),metadataConnection.getPassword(),metadataConnection.getSchema(),metadataConnection.getDriverClass(),metadataConnection.getDriverJarPath(),metadataConnection.getDbVersionString(),metadataConnection.getAdditionalParams(),retProposedSchema);
    }
    oldConnection=metadataConnection;
    isValide=testConnection.getResult();
    messageException=testConnection.getMessageException();
  }
 catch (  Exception e) {
    log.error(Messages.getString("String_Node_Str") + "String_Node_Str" + e.toString());
  }
  return isValide;
}