Program: 130171
Project: 130171
Buggy source:
private void checkConnection(final StringBuffer retProposedSchema){
  if (isSqliteFileFieldInvalidate()) {
    return;
  }
  checkButton.setEnabled(false);
  if (connectionItem.getConnection() instanceof DatabaseConnection) {
    DatabaseConnection c=(DatabaseConnection)connectionItem.getConnection();
    if (!isContextMode()) {
      if (EDatabaseTypeName.ORACLEFORSID.getProduct().equals(c.getProductId())) {
        schemaText.setText(schemaText.getText().toUpperCase());
      }
 else       if (EDatabaseTypeName.NETEZZA.getProduct().equals(c.getProductId()) || MetadataFillFactory.isJdbcNetezza(c.getDatabaseType(),c.getDriverClass())) {
        if (sidOrDatabaseText != null) {
          sidOrDatabaseText.setText(sidOrDatabaseText.getText().toUpperCase());
        }
        if (urlConnectionStringText != null) {
          urlConnectionStringText.setText(getUppercaseNetezzaUrl(urlConnectionStringText.getText()));
        }
        if (generalJdbcUrlText != null) {
          generalJdbcUrlText.setText(getUppercaseNetezzaUrl(generalJdbcUrlText.getText()));
        }
      }
    }
  }
  final 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()));
  AProgressMonitorDialogWithCancel<Boolean> checkingDialog;
  if (dbType.isUseProvider()) {
    final IMetadataConnection metadataConn=ConvertionHelper.convert(connectionItem.getConnection(),true);
    checkingDialog=new AProgressMonitorDialogWithCancel<Boolean>(getShell()){
      @Override protected Boolean runWithCancel(      IProgressMonitor monitor) throws Exception {
        return managerConnection.check(metadataConn,retProposedSchema);
      }
    }
;
  }
 else   if (isHiveDBConnSelected()) {
    final IMetadataConnection metadataConn=ConvertionHelper.convert(connectionItem.getConnection(),true);
    if (isHiveEmbeddedMode()) {
      doHivePreSetup((DatabaseConnection)metadataConn.getCurrentConnection());
    }
    checkingDialog=new AProgressMonitorDialogWithCancel<Boolean>(getShell()){
      @Override protected Boolean runWithCancel(      IProgressMonitor monitor) throws Exception {
        return managerConnection.checkHiveConnection(metadataConn);
      }
    }
;
  }
 else {
    checkingDialog=new AProgressMonitorDialogWithCancel<Boolean>(getShell()){
      @Override protected Boolean runWithCancel(      IProgressMonitor monitor) throws Exception {
        return managerConnection.check(retProposedSchema);
      }
    }
;
  }
  String executeMessage=Messages.getString("String_Node_Str");
  Exception executeException=null;
  int timeout=DatabaseConnectionParameterUtil.getDefaultDBConnectionTimeout();
  if (0 < timeout) {
    timeout+=5;
  }
  try {
    checkingDialog.run(executeMessage,null,true,timeout);
  }
 catch (  Exception e) {
    executeException=e;
  }
  checkButton.setEnabled(true);
  if (checkingDialog.isUserCanncelled()) {
    return;
  }
  if (checkingDialog.getExecuteException() != null) {
    executeException=checkingDialog.getExecuteException();
  }
  if (executeException != null) {
    if (executeException instanceof InterruptedException) {
      CommonExceptionHandler.process(executeException,Priority.WARN);
      return;
    }
    databaseSettingIsValide=false;
  }
 else {
    databaseSettingIsValide=checkingDialog.getExecuteResult();
  }
  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=null;
    Exception exception=managerConnection.getException();
    if (exception instanceof WarningSQLException) {
      mainMsg=exception.getMessage();
      MessageDialog.openWarning(getShell(),Messages.getString("String_Node_Str"),mainMsg);
    }
 else     if (exception == null && executeException != null) {
      mainMsg=executeException.getMessage();
      MessageDialog.openWarning(getShell(),Messages.getString("String_Node_Str"),mainMsg);
    }
 else {
      mainMsg=Messages.getString("String_Node_Str") + "String_Node_Str" + Messages.getString("String_Node_Str");
      new ErrorDialogWidthDetailArea(getShell(),PID,mainMsg,managerConnection.getMessageException());
    }
    if (!isReadOnly()) {
      updateStatus(IStatus.WARNING,mainMsg);
    }
  }
}

Fixed version (ground truth):
private void checkConnection(final StringBuffer retProposedSchema){
  if (isSqliteFileFieldInvalidate()) {
    return;
  }
  checkButton.setEnabled(false);
  if (connectionItem.getConnection() instanceof DatabaseConnection) {
    DatabaseConnection c=(DatabaseConnection)connectionItem.getConnection();
    if (!isContextMode()) {
      if (EDatabaseTypeName.ORACLEFORSID.getProduct().equals(c.getProductId())) {
        schemaText.setText(schemaText.getText().toUpperCase());
      }
 else       if (EDatabaseTypeName.NETEZZA.getProduct().equals(c.getProductId()) || MetadataFillFactory.isJdbcNetezza(c.getDatabaseType(),c.getDriverClass())) {
        if (sidOrDatabaseText != null) {
          sidOrDatabaseText.setText(sidOrDatabaseText.getText().toUpperCase());
        }
        if (urlConnectionStringText != null) {
          urlConnectionStringText.setText(getUppercaseNetezzaUrl(urlConnectionStringText.getText()));
        }
        if (generalJdbcUrlText != null) {
          generalJdbcUrlText.setText(getUppercaseNetezzaUrl(generalJdbcUrlText.getText()));
        }
      }
    }
  }
  final 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()));
  AProgressMonitorDialogWithCancel<Boolean> checkingDialog;
  if (dbType.isUseProvider()) {
    final IMetadataConnection metadataConn=ConvertionHelper.convert(connectionItem.getConnection(),true);
    checkingDialog=new AProgressMonitorDialogWithCancel<Boolean>(getShell()){
      @Override protected Boolean runWithCancel(      IProgressMonitor monitor) throws Exception {
        return managerConnection.check(metadataConn,retProposedSchema);
      }
    }
;
  }
 else   if (isHiveDBConnSelected()) {
    final IMetadataConnection metadataConn=ConvertionHelper.convert(connectionItem.getConnection(),true);
    if (isHiveEmbeddedMode()) {
      doHivePreSetup((DatabaseConnection)metadataConn.getCurrentConnection());
    }
    checkingDialog=new AProgressMonitorDialogWithCancel<Boolean>(getShell()){
      @Override protected Boolean runWithCancel(      IProgressMonitor monitor) throws Exception {
        return managerConnection.checkHiveConnection(metadataConn);
      }
    }
;
  }
 else {
    checkingDialog=new AProgressMonitorDialogWithCancel<Boolean>(getShell()){
      @Override protected Boolean runWithCancel(      IProgressMonitor monitor) throws Exception {
        return managerConnection.check(retProposedSchema);
      }
    }
;
  }
  String executeMessage=Messages.getString("String_Node_Str");
  Exception executeException=null;
  try {
    checkingDialog.run(executeMessage,null,true,AProgressMonitorDialogWithCancel.ENDLESS_WAIT_TIME);
  }
 catch (  Exception e) {
    executeException=e;
  }
  checkButton.setEnabled(true);
  if (checkingDialog.isUserCanncelled()) {
    return;
  }
  if (checkingDialog.getExecuteException() != null) {
    executeException=checkingDialog.getExecuteException();
  }
  if (executeException != null) {
    if (executeException instanceof InterruptedException) {
      CommonExceptionHandler.process(executeException,Priority.WARN);
      return;
    }
    databaseSettingIsValide=false;
  }
 else {
    databaseSettingIsValide=checkingDialog.getExecuteResult();
  }
  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=null;
    Exception exception=managerConnection.getException();
    if (exception instanceof WarningSQLException) {
      mainMsg=exception.getMessage();
      MessageDialog.openWarning(getShell(),Messages.getString("String_Node_Str"),mainMsg);
    }
 else     if (exception == null && executeException != null) {
      mainMsg=executeException.getMessage();
      MessageDialog.openWarning(getShell(),Messages.getString("String_Node_Str"),mainMsg);
    }
 else {
      mainMsg=Messages.getString("String_Node_Str") + "String_Node_Str" + Messages.getString("String_Node_Str");
      new ErrorDialogWidthDetailArea(getShell(),PID,mainMsg,managerConnection.getMessageException());
    }
    if (!isReadOnly()) {
      updateStatus(IStatus.WARNING,mainMsg);
    }
  }
}