Program: 126343
Project: 126343
Buggy source:
private void checkConnection(StringBuffer retProposedSchema){
  if (isSqliteFileFieldInvalidate()) {
    return;
  }
  checkButton.setEnabled(false);
  if (connectionItem.getConnection() instanceof DatabaseConnection) {
    DatabaseConnection c=(DatabaseConnection)connectionItem.getConnection();
    if (EDatabaseTypeName.ORACLEFORSID.getProduct().equals(c.getProductId())) {
      if (!isContextMode()) {
        schemaText.setText(schemaText.getText().toUpperCase());
      }
    }
  }
  ManagerConnection managerConnection=new ManagerConnection();
  if (isContextMode()) {
    selectedContextType=ConnectionContextHelper.getContextTypeForContextMode(connectionItem.getConnection());
    String urlStr=DBConnectionContextUtils.setManagerConnectionValues(managerConnection,connectionItem,selectedContextType,dbTypeCombo.getItem(dbTypeCombo.getSelectionIndex()),dbTypeCombo.getSelectionIndex());
    if (urlStr == null || isHiveDBConnSelected()) {
      if (dbTypeCombo.getText().equals(EDatabaseConnTemplate.GENERAL_JDBC.getDBDisplayName())) {
        DatabaseConnection dbConn=(DatabaseConnection)connectionItem.getConnection();
        ContextType contextType=ConnectionContextHelper.getContextTypeForContextMode(dbConn);
        urlStr=ConnectionContextHelper.getOriginalValue(contextType,dbConn.getURL());
      }
 else {
        urlStr=getStringConnection();
      }
    }
    urlConnectionStringText.setText(urlStr);
  }
 else {
    String versionStr=dbVersionCombo.getText();
    if (EDatabaseTypeName.HIVE.getDisplayName().equals(dbTypeCombo.getText())) {
      EDatabaseVersion4Drivers driver=EDatabaseVersion4Drivers.indexOfByVersionDisplay(hiveModeCombo.getText());
      versionStr=driver.getVersionValue();
    }
 else     if (EDatabaseTypeName.IMPALA.getDisplayName().equals(dbTypeCombo.getText())) {
      urlConnectionStringText.setText(getStringConnection());
    }
 else {
      EDatabaseVersion4Drivers version=EDatabaseVersion4Drivers.indexOfByVersionDisplay(versionStr);
      if (version != null) {
        versionStr=version.getVersionValue();
      }
    }
    managerConnection.setValue(0,dbTypeCombo.getItem(dbTypeCombo.getSelectionIndex()),isGeneralJDBC() ? generalJdbcUrlText.getText() : urlConnectionStringText.getText(),serverText.getText(),isGeneralJDBC() ? generalJdbcUserText.getText() : usernameText.getText(),isGeneralJDBC() ? generalJdbcPasswordText.getText() : passwordText.getText(),sidOrDatabaseText.getText(),portText.getText(),fileField.getText(),datasourceText.getText(),isGeneralJDBC() ? jDBCschemaText.getText() : schemaText.getText(),additionParamText.getText(),generalJdbcClassNameText.getText(),generalJdbcDriverjarText.getText(),enableDbVersion() ? versionStr : null,metadataconnection.getOtherParameters());
    managerConnection.setDbRootPath(directoryField.getText());
  }
  managerConnection.setValueProperties(sqlSyntaxCombo.getItem(sqlSyntaxCombo.getSelectionIndex()),stringQuoteText.getText(),nullCharText.getText());
  EDatabaseTypeName dbType=EDatabaseTypeName.getTypeFromDbType(dbTypeCombo.getItem(dbTypeCombo.getSelectionIndex()));
  if (dbType.isUseProvider()) {
    IMetadataConnection metadataConn=ConvertionHelper.convert(connectionItem.getConnection(),true);
    databaseSettingIsValide=managerConnection.check(metadataConn,retProposedSchema);
  }
 else   if (isHiveDBConnSelected()) {
    IMetadataConnection metadataConn=ConvertionHelper.convert(connectionItem.getConnection(),true);
    if (isHiveEmbeddedMode()) {
      doHivePreSetup((DatabaseConnection)metadataConn.getCurrentConnection());
    }
    databaseSettingIsValide=managerConnection.checkHiveConnection(metadataConn);
  }
 else {
    databaseSettingIsValide=managerConnection.check(retProposedSchema);
  }
  checkButton.setEnabled(true);
  if (databaseSettingIsValide) {
    if (!isReadOnly()) {
      updateStatus(IStatus.OK,null);
    }
    MessageDialog.openInformation(getShell(),Messages.getString("String_Node_Str"),"String_Node_Str" + connectionItem.getProperty().getDisplayName() + "String_Node_Str"+ Messages.getString("String_Node_Str"));
    if (!isReadOnly()) {
      if (isContextMode()) {
        adaptFormToEditable();
      }
 else {
        setPropertiesFormEditable(true);
      }
    }
    String msg=checkDBVersion();
    if (msg != null) {
      updateStatus(IStatus.WARNING,msg);
    }
  }
 else {
    String mainMsg=Messages.getString("String_Node_Str") + "String_Node_Str" + Messages.getString("String_Node_Str");
    if (!isReadOnly()) {
      updateStatus(IStatus.WARNING,mainMsg);
    }
    new ErrorDialogWidthDetailArea(getShell(),PID,mainMsg,managerConnection.getMessageException());
  }
}

Fixed version (ground truth):
private void checkConnection(StringBuffer retProposedSchema){
  if (isSqliteFileFieldInvalidate()) {
    return;
  }
  checkButton.setEnabled(false);
  if (connectionItem.getConnection() instanceof DatabaseConnection) {
    DatabaseConnection c=(DatabaseConnection)connectionItem.getConnection();
    if (EDatabaseTypeName.ORACLEFORSID.getProduct().equals(c.getProductId())) {
      if (!isContextMode()) {
        schemaText.setText(schemaText.getText().toUpperCase());
      }
    }
  }
  ManagerConnection managerConnection=new ManagerConnection();
  if (isContextMode()) {
    selectedContextType=ConnectionContextHelper.getContextTypeForContextMode(connectionItem.getConnection());
    String urlStr=DBConnectionContextUtils.setManagerConnectionValues(managerConnection,connectionItem,selectedContextType,dbTypeCombo.getItem(dbTypeCombo.getSelectionIndex()),dbTypeCombo.getSelectionIndex());
    if (urlStr == null || isHiveDBConnSelected()) {
      if (dbTypeCombo.getText().equals(EDatabaseConnTemplate.GENERAL_JDBC.getDBDisplayName())) {
        DatabaseConnection dbConn=(DatabaseConnection)connectionItem.getConnection();
        ContextType contextType=ConnectionContextHelper.getContextTypeForContextMode(dbConn);
        urlStr=ConnectionContextHelper.getOriginalValue(contextType,dbConn.getURL());
      }
 else {
        urlStr=getStringConnection();
      }
    }
    urlConnectionStringText.setText(urlStr);
  }
 else {
    String versionStr=dbVersionCombo.getText();
    if (EDatabaseTypeName.HIVE.getDisplayName().equals(dbTypeCombo.getText())) {
      EDatabaseVersion4Drivers driver=EDatabaseVersion4Drivers.indexOfByVersionDisplay(hiveModeCombo.getText());
      versionStr=driver.getVersionValue();
    }
 else     if (EDatabaseTypeName.IMPALA.getDisplayName().equals(dbTypeCombo.getText())) {
      urlConnectionStringText.setText(getStringConnection());
      if (EImpalaDistributions.CUSTOM != EImpalaDistributions.getDistributionByName(impalaDistributionCombo.getText(),true)) {
        versionStr=EImpalaDistribution4Versions.indexOfByVersionDisplay(impalaVersionCombo.getText()).getVersionValue();
      }
    }
 else {
      EDatabaseVersion4Drivers version=EDatabaseVersion4Drivers.indexOfByVersionDisplay(versionStr);
      if (version != null) {
        versionStr=version.getVersionValue();
      }
    }
    managerConnection.setValue(0,dbTypeCombo.getItem(dbTypeCombo.getSelectionIndex()),isGeneralJDBC() ? generalJdbcUrlText.getText() : urlConnectionStringText.getText(),serverText.getText(),isGeneralJDBC() ? generalJdbcUserText.getText() : usernameText.getText(),isGeneralJDBC() ? generalJdbcPasswordText.getText() : passwordText.getText(),sidOrDatabaseText.getText(),portText.getText(),fileField.getText(),datasourceText.getText(),isGeneralJDBC() ? jDBCschemaText.getText() : schemaText.getText(),additionParamText.getText(),generalJdbcClassNameText.getText(),generalJdbcDriverjarText.getText(),enableDbVersion() ? versionStr : null,metadataconnection.getOtherParameters());
    managerConnection.setDbRootPath(directoryField.getText());
  }
  managerConnection.setValueProperties(sqlSyntaxCombo.getItem(sqlSyntaxCombo.getSelectionIndex()),stringQuoteText.getText(),nullCharText.getText());
  EDatabaseTypeName dbType=EDatabaseTypeName.getTypeFromDbType(dbTypeCombo.getItem(dbTypeCombo.getSelectionIndex()));
  if (dbType.isUseProvider()) {
    IMetadataConnection metadataConn=ConvertionHelper.convert(connectionItem.getConnection(),true);
    databaseSettingIsValide=managerConnection.check(metadataConn,retProposedSchema);
  }
 else   if (isHiveDBConnSelected()) {
    IMetadataConnection metadataConn=ConvertionHelper.convert(connectionItem.getConnection(),true);
    if (isHiveEmbeddedMode()) {
      doHivePreSetup((DatabaseConnection)metadataConn.getCurrentConnection());
    }
    databaseSettingIsValide=managerConnection.checkHiveConnection(metadataConn);
  }
 else {
    databaseSettingIsValide=managerConnection.check(retProposedSchema);
  }
  checkButton.setEnabled(true);
  if (databaseSettingIsValide) {
    if (!isReadOnly()) {
      updateStatus(IStatus.OK,null);
    }
    MessageDialog.openInformation(getShell(),Messages.getString("String_Node_Str"),"String_Node_Str" + connectionItem.getProperty().getDisplayName() + "String_Node_Str"+ Messages.getString("String_Node_Str"));
    if (!isReadOnly()) {
      if (isContextMode()) {
        adaptFormToEditable();
      }
 else {
        setPropertiesFormEditable(true);
      }
    }
    String msg=checkDBVersion();
    if (msg != null) {
      updateStatus(IStatus.WARNING,msg);
    }
  }
 else {
    String mainMsg=Messages.getString("String_Node_Str") + "String_Node_Str" + Messages.getString("String_Node_Str");
    if (!isReadOnly()) {
      updateStatus(IStatus.WARNING,mainMsg);
    }
    new ErrorDialogWidthDetailArea(getShell(),PID,mainMsg,managerConnection.getMessageException());
  }
}