Program: 126198
Project: 126198
Buggy source:
@Override protected void addFieldsListeners(){
  webServiceUrlText.addModifyListener(new ModifyListener(){
    @Override public void modifyText(    ModifyEvent e){
      if (!isContextMode()) {
        loginOk=false;
        checkFieldsValue();
        getConnection().setWebServiceUrl(webServiceUrlText.getText());
        setCheckEnable();
      }
    }
  }
);
  userNameText.addModifyListener(new ModifyListener(){
    @Override public void modifyText(    ModifyEvent e){
      if (!isContextMode()) {
        loginOk=false;
        checkFieldsValue();
        getConnection().setUserName(userNameText.getText());
        setCheckEnable();
      }
    }
  }
);
  passwordText.addModifyListener(new ModifyListener(){
    @Override public void modifyText(    ModifyEvent e){
      if (!isContextMode()) {
        loginOk=false;
        checkFieldsValue();
        SalesforceSchemaConnection connection2=getConnection();
        connection2.setPassword(connection2.getValue(passwordText.getText(),true));
        setCheckEnable();
      }
    }
  }
);
  batchSizeText.addModifyListener(new ModifyListener(){
    @Override public void modifyText(    ModifyEvent e){
      if (!isContextMode()) {
        loginOk=false;
        checkFieldsValue();
        getConnection().setBatchSize(batchSizeText.getText());
        setCheckEnable();
      }
    }
  }
);
  timeOutText.addModifyListener(new ModifyListener(){
    @Override public void modifyText(    ModifyEvent e){
      if (!isContextMode()) {
        loginOk=false;
        checkFieldsValue();
        String timeOutStr=timeOutText.getText();
        if (!"String_Node_Str".equals(timeOutStr)) {
          try {
            Integer.parseInt(timeOutStr);
            getConnection().setTimeOut(timeOutStr);
          }
 catch (          NumberFormatException e1) {
            updateStatus(IStatus.ERROR,Messages.getString("String_Node_Str"));
          }
        }
        setCheckEnable();
      }
    }
  }
);
  useProxyBtn.addSelectionListener(new SelectionAdapter(){
    @Override public void widgetSelected(    SelectionEvent e){
      boolean selection=useProxyBtn.getSelection();
      checkFieldsValue();
      enableProxyParameters(selection);
      getConnection().setUseProxy(selection);
      if (selection && useHttpBtn.getSelection()) {
        getConnection().setUseHttpProxy(false);
        useHttpBtn.setSelection(false);
      }
    }
  }
);
  useHttpBtn.addSelectionListener(new SelectionAdapter(){
    @Override public void widgetSelected(    SelectionEvent e){
      boolean selection=useHttpBtn.getSelection();
      checkFieldsValue();
      enableProxyParameters(selection);
      getConnection().setUseHttpProxy(selection);
      if (selection && useProxyBtn.getSelection()) {
        getConnection().setUseProxy(false);
        useProxyBtn.setSelection(false);
      }
    }
  }
);
  proxyHostText.addModifyListener(new ModifyListener(){
    @Override public void modifyText(    ModifyEvent e){
      if (!isContextMode()) {
        checkFieldsValue();
        getConnection().setProxyHost(proxyHostText.getText());
      }
    }
  }
);
  proxyPortText.addModifyListener(new ModifyListener(){
    @Override public void modifyText(    ModifyEvent e){
      if (!isContextMode()) {
        checkFieldsValue();
        getConnection().setProxyPort(proxyPortText.getText());
      }
    }
  }
);
  proxyUsernameText.addModifyListener(new ModifyListener(){
    @Override public void modifyText(    ModifyEvent e){
      if (!isContextMode()) {
        checkFieldsValue();
        getConnection().setProxyUsername(proxyUsernameText.getText());
      }
    }
  }
);
  proxyPasswordText.addModifyListener(new ModifyListener(){
    @Override public void modifyText(    ModifyEvent e){
      if (!isContextMode()) {
        checkFieldsValue();
        SalesforceSchemaConnection connection2=getConnection();
        connection2.setProxyPassword(connection2.getValue(proxyPasswordText.getText(),true));
      }
    }
  }
);
  authBtn.addModifyListener(new ModifyListener(){
    @Override public void modifyText(    ModifyEvent e){
      if (!isContextMode()) {
        loginOk=false;
        checkFieldsValue();
        getConnection().setLoginType(authBtn.getItem(authBtn.getSelectionIndex()));
        setCheckEnable();
        collectContextParams(true);
      }
    }
  }
);
  webServiceUrlTextForOAuth.addModifyListener(new ModifyListener(){
    @Override public void modifyText(    ModifyEvent e){
      if (!isContextMode()) {
        loginOk=false;
        checkFieldsValue();
        getConnection().setWebServiceUrlTextForOAuth(webServiceUrlTextForOAuth.getText());
        setCheckEnable();
      }
    }
  }
);
  consumeKeyText.addModifyListener(new ModifyListener(){
    @Override public void modifyText(    ModifyEvent e){
      if (!isContextMode()) {
        loginOk=false;
        checkFieldsValue();
        getConnection().setConsumeKey(consumeKeyText.getText());
        setCheckEnable();
      }
    }
  }
);
  consumeKeySecretText.addModifyListener(new ModifyListener(){
    @Override public void modifyText(    ModifyEvent e){
      if (!isContextMode()) {
        loginOk=false;
        checkFieldsValue();
        SalesforceSchemaConnection connection2=getConnection();
        connection2.setConsumeSecret(connection2.getValue(consumeKeySecretText.getText(),true));
        setCheckEnable();
      }
    }
  }
);
  callbackHostText.addModifyListener(new ModifyListener(){
    @Override public void modifyText(    ModifyEvent e){
      if (!isContextMode()) {
        loginOk=false;
        checkFieldsValue();
        getConnection().setCallbackHost(callbackHostText.getText());
        setCheckEnable();
      }
    }
  }
);
  callbackPortText.addModifyListener(new ModifyListener(){
    @Override public void modifyText(    ModifyEvent e){
      if (!isContextMode()) {
        loginOk=false;
        checkFieldsValue();
        getConnection().setCallbackPort(callbackPortText.getText());
        setCheckEnable();
      }
    }
  }
);
  apiVersionText.addModifyListener(new ModifyListener(){
    @Override public void modifyText(    ModifyEvent e){
      if (!isContextMode()) {
        loginOk=false;
        checkFieldsValue();
        getConnection().setSalesforceVersion(apiVersionText.getText());
        setCheckEnable();
      }
    }
  }
);
  tokenText.addModifyListener(new ModifyListener(){
    @Override public void modifyText(    ModifyEvent e){
      if (!isContextMode()) {
        loginOk=false;
        checkFieldsValue();
        getConnection().setToken(tokenText.getText());
        setCheckEnable();
      }
    }
  }
);
  checkButton.addSelectionListener(new SelectionAdapter(){
    @Override public void widgetSelected(    SelectionEvent e){
      if (!isContextMode()) {
        checkFieldsValue();
      }
      testSalesforceLogin();
      if (authBtn.getSelectionIndex() == 0) {
        String proxy=null;
        if (useProxyBtn.getSelection()) {
          proxy=SalesforceModuleParseAPI.USE_SOCKS_PROXY;
        }
 else         if (useHttpBtn.getSelection()) {
          proxy=SalesforceModuleParseAPI.USE_HTTP_PROXY;
        }
        SalesforceModuleParseAPI checkSalesfoceLogin=checkSalesfoceLogin(proxy,endPoint,username,pwd,timeOut,proxyHostText.getText(),proxyPortText.getText(),proxyUsernameText.getText(),proxyPasswordText.getText());
        if (checkSalesfoceLogin != null) {
          setSalesforceModuleParseAPI(checkSalesfoceLogin);
          loginOk=checkSalesfoceLogin.getCurrentAPI().isLogin();
        }
        if (loginOk) {
          checkFieldsValue();
        }
      }
 else {
        String errors=null;
        final OAuthClient client=new OAuthClient();
        client.setBaseOAuthURL(endPointForOAuth);
        client.setCallbackHost(callbackHost);
        client.setCallbackPort(Integer.parseInt(callbackPort));
        client.setClientID(consumeKey);
        client.setClientSecret(consumeKeySrcret);
        boolean result=false;
        try {
          client.startServer();
          Token token=null;
          if (TalendPropertiesUtil.isEnabledUseBrowser()) {
            Display.getDefault().syncExec(new Runnable(){
              @Override public void run(){
                BrowerDialog brower;
                try {
                  Shell shell=new Shell(Display.getDefault(),SWT.ON_TOP);
                  brower=new BrowerDialog(shell,client.getUrl());
                  if (Window.OK == brower.open()) {
                    code=client.getServer().getCode();
                  }
 else {
                    return;
                  }
                }
 catch (                Exception e2) {
                  ExceptionHandler.process(e2);
                }
              }
            }
);
          }
 else {
            MessageDialog.openError(getShell(),Messages.getString("String_Node_Str"),Messages.getString("String_Node_Str"));
            return;
          }
          Thread.sleep(100);
          client.stopServer();
          if (code != null && !code.equals("String_Node_Str")) {
            token=client.getTokenForWizard(code);
            String endpoint=null;
            endpoint=OAuthClient.getSOAPEndpoint(token,apiVersion);
            if (token != null) {
              java.util.Properties properties=new java.util.Properties();
              FileOutputStream outputStream=new FileOutputStream(tokenText.getText());
              properties.setProperty("String_Node_Str",token.getRefresh_token());
              FileWriter w=new FileWriter(tokenText.getText());
              properties.store(w,"String_Node_Str");
              w.close();
              try {
                SforceConnection sforceConn=new SforceSessionConnection.Builder(endpoint,token.getAccess_token()).setTimeout(timeOut).needCompression(false).build();
                result=true;
              }
 catch (              Exception ex) {
              }
            }
            if (!result) {
              String mainMsg=Messages.getString("String_Node_Str") + "String_Node_Str" + Messages.getString("String_Node_Str");
              new ErrorDialogWidthDetailArea(getShell(),PID,mainMsg,errors);
            }
 else {
              loginOk=true;
              MessageDialog.openInformation(getShell(),Messages.getString("String_Node_Str"),Messages.getString("String_Node_Str"));
            }
          }
 else {
            MessageDialog.openError(getShell(),Messages.getString("String_Node_Str"),Messages.getString("String_Node_Str"));
          }
        }
 catch (        Exception e1) {
          errors=e1.getMessage();
        }
        if (loginOk) {
          checkFieldsValue();
        }
      }
    }
  }
);
}

Fixed version (ground truth):
@Override protected void addFieldsListeners(){
  webServiceUrlText.addModifyListener(new ModifyListener(){
    @Override public void modifyText(    ModifyEvent e){
      if (!isContextMode()) {
        loginOk=false;
        checkFieldsValue();
        getConnection().setWebServiceUrl(webServiceUrlText.getText());
        setCheckEnable();
      }
    }
  }
);
  userNameText.addModifyListener(new ModifyListener(){
    @Override public void modifyText(    ModifyEvent e){
      if (!isContextMode()) {
        loginOk=false;
        checkFieldsValue();
        getConnection().setUserName(userNameText.getText());
        setCheckEnable();
      }
    }
  }
);
  passwordText.addModifyListener(new ModifyListener(){
    @Override public void modifyText(    ModifyEvent e){
      if (!isContextMode()) {
        loginOk=false;
        checkFieldsValue();
        SalesforceSchemaConnection connection2=getConnection();
        connection2.setPassword(connection2.getValue(passwordText.getText(),true));
        setCheckEnable();
      }
    }
  }
);
  batchSizeText.addModifyListener(new ModifyListener(){
    @Override public void modifyText(    ModifyEvent e){
      if (!isContextMode()) {
        loginOk=false;
        checkFieldsValue();
        getConnection().setBatchSize(batchSizeText.getText());
        setCheckEnable();
      }
    }
  }
);
  timeOutText.addModifyListener(new ModifyListener(){
    @Override public void modifyText(    ModifyEvent e){
      if (!isContextMode()) {
        loginOk=false;
        checkFieldsValue();
        String timeOutStr=timeOutText.getText();
        if (!"String_Node_Str".equals(timeOutStr)) {
          try {
            Integer.parseInt(timeOutStr);
            getConnection().setTimeOut(timeOutStr);
          }
 catch (          NumberFormatException e1) {
            updateStatus(IStatus.ERROR,Messages.getString("String_Node_Str"));
          }
        }
        setCheckEnable();
      }
    }
  }
);
  useProxyBtn.addSelectionListener(new SelectionAdapter(){
    @Override public void widgetSelected(    SelectionEvent e){
      boolean selection=useProxyBtn.getSelection();
      checkFieldsValue();
      enableProxyParameters(selection);
      getConnection().setUseProxy(selection);
      if (selection && useHttpBtn.getSelection()) {
        getConnection().setUseHttpProxy(false);
        useHttpBtn.setSelection(false);
      }
    }
  }
);
  useHttpBtn.addSelectionListener(new SelectionAdapter(){
    @Override public void widgetSelected(    SelectionEvent e){
      boolean selection=useHttpBtn.getSelection();
      checkFieldsValue();
      enableProxyParameters(selection);
      getConnection().setUseHttpProxy(selection);
      if (selection && useProxyBtn.getSelection()) {
        getConnection().setUseProxy(false);
        useProxyBtn.setSelection(false);
      }
    }
  }
);
  proxyHostText.addModifyListener(new ModifyListener(){
    @Override public void modifyText(    ModifyEvent e){
      if (!isContextMode()) {
        checkFieldsValue();
        getConnection().setProxyHost(proxyHostText.getText());
      }
    }
  }
);
  proxyPortText.addModifyListener(new ModifyListener(){
    @Override public void modifyText(    ModifyEvent e){
      if (!isContextMode()) {
        checkFieldsValue();
        getConnection().setProxyPort(proxyPortText.getText());
      }
    }
  }
);
  proxyUsernameText.addModifyListener(new ModifyListener(){
    @Override public void modifyText(    ModifyEvent e){
      if (!isContextMode()) {
        checkFieldsValue();
        getConnection().setProxyUsername(proxyUsernameText.getText());
      }
    }
  }
);
  proxyPasswordText.addModifyListener(new ModifyListener(){
    @Override public void modifyText(    ModifyEvent e){
      if (!isContextMode()) {
        checkFieldsValue();
        SalesforceSchemaConnection connection2=getConnection();
        connection2.setProxyPassword(connection2.getValue(proxyPasswordText.getText(),true));
      }
    }
  }
);
  authBtn.addModifyListener(new ModifyListener(){
    @Override public void modifyText(    ModifyEvent e){
      if (!isContextMode()) {
        loginOk=false;
        checkFieldsValue();
        getConnection().setLoginType(authBtn.getItem(authBtn.getSelectionIndex()));
        setCheckEnable();
        collectContextParams(true);
      }
    }
  }
);
  webServiceUrlTextForOAuth.addModifyListener(new ModifyListener(){
    @Override public void modifyText(    ModifyEvent e){
      if (!isContextMode()) {
        loginOk=false;
        checkFieldsValue();
        getConnection().setWebServiceUrlTextForOAuth(webServiceUrlTextForOAuth.getText());
        setCheckEnable();
      }
    }
  }
);
  consumeKeyText.addModifyListener(new ModifyListener(){
    @Override public void modifyText(    ModifyEvent e){
      if (!isContextMode()) {
        loginOk=false;
        checkFieldsValue();
        getConnection().setConsumeKey(consumeKeyText.getText());
        setCheckEnable();
      }
    }
  }
);
  consumeKeySecretText.addModifyListener(new ModifyListener(){
    @Override public void modifyText(    ModifyEvent e){
      if (!isContextMode()) {
        loginOk=false;
        checkFieldsValue();
        SalesforceSchemaConnection connection2=getConnection();
        connection2.setConsumeSecret(connection2.getValue(consumeKeySecretText.getText(),true));
        setCheckEnable();
      }
    }
  }
);
  callbackHostText.addModifyListener(new ModifyListener(){
    @Override public void modifyText(    ModifyEvent e){
      if (!isContextMode()) {
        loginOk=false;
        checkFieldsValue();
        getConnection().setCallbackHost(callbackHostText.getText());
        setCheckEnable();
      }
    }
  }
);
  callbackPortText.addModifyListener(new ModifyListener(){
    @Override public void modifyText(    ModifyEvent e){
      if (!isContextMode()) {
        loginOk=false;
        checkFieldsValue();
        getConnection().setCallbackPort(callbackPortText.getText());
        setCheckEnable();
      }
    }
  }
);
  apiVersionText.addModifyListener(new ModifyListener(){
    @Override public void modifyText(    ModifyEvent e){
      if (!isContextMode()) {
        loginOk=false;
        checkFieldsValue();
        getConnection().setSalesforceVersion(apiVersionText.getText());
        setCheckEnable();
      }
    }
  }
);
  tokenText.addModifyListener(new ModifyListener(){
    @Override public void modifyText(    ModifyEvent e){
      if (!isContextMode()) {
        loginOk=false;
        checkFieldsValue();
        getConnection().setToken(tokenText.getText());
        setCheckEnable();
      }
    }
  }
);
  checkButton.addSelectionListener(new SelectionAdapter(){
    @Override public void widgetSelected(    SelectionEvent e){
      if (!isContextMode()) {
        checkFieldsValue();
      }
      testSalesforceLogin();
      if (authBtn.getSelectionIndex() == 0) {
        String proxy=null;
        if (useProxyBtn.getSelection()) {
          proxy=SalesforceModuleParseAPI.USE_SOCKS_PROXY;
        }
 else         if (useHttpBtn.getSelection()) {
          proxy=SalesforceModuleParseAPI.USE_HTTP_PROXY;
        }
        SalesforceModuleParseAPI checkSalesfoceLogin=checkSalesfoceLogin(proxy,endPoint,username,pwd,timeOut,proxyHost,proxyPort,proxyUsername,proxyPassword);
        if (checkSalesfoceLogin != null) {
          setSalesforceModuleParseAPI(checkSalesfoceLogin);
          loginOk=checkSalesfoceLogin.getCurrentAPI().isLogin();
        }
        if (loginOk) {
          checkFieldsValue();
        }
      }
 else {
        String errors=null;
        final OAuthClient client=new OAuthClient();
        client.setBaseOAuthURL(endPointForOAuth);
        client.setCallbackHost(callbackHost);
        client.setCallbackPort(Integer.parseInt(callbackPort));
        client.setClientID(consumeKey);
        client.setClientSecret(consumeKeySrcret);
        boolean result=false;
        try {
          client.startServer();
          Token token=null;
          if (TalendPropertiesUtil.isEnabledUseBrowser()) {
            Display.getDefault().syncExec(new Runnable(){
              @Override public void run(){
                BrowerDialog brower;
                try {
                  Shell shell=new Shell(Display.getDefault(),SWT.ON_TOP);
                  brower=new BrowerDialog(shell,client.getUrl());
                  if (Window.OK == brower.open()) {
                    code=client.getServer().getCode();
                  }
 else {
                    return;
                  }
                }
 catch (                Exception e2) {
                  ExceptionHandler.process(e2);
                }
              }
            }
);
          }
 else {
            MessageDialog.openError(getShell(),Messages.getString("String_Node_Str"),Messages.getString("String_Node_Str"));
            return;
          }
          Thread.sleep(100);
          client.stopServer();
          if (code != null && !code.equals("String_Node_Str")) {
            token=client.getTokenForWizard(code);
            String endpoint=null;
            endpoint=OAuthClient.getSOAPEndpoint(token,apiVersion);
            if (token != null) {
              java.util.Properties properties=new java.util.Properties();
              FileOutputStream outputStream=new FileOutputStream(tokenText.getText());
              properties.setProperty("String_Node_Str",token.getRefresh_token());
              FileWriter w=new FileWriter(tokenText.getText());
              properties.store(w,"String_Node_Str");
              w.close();
              try {
                SforceConnection sforceConn=new SforceSessionConnection.Builder(endpoint,token.getAccess_token()).setTimeout(timeOut).needCompression(false).build();
                result=true;
              }
 catch (              Exception ex) {
              }
            }
            if (!result) {
              String mainMsg=Messages.getString("String_Node_Str") + "String_Node_Str" + Messages.getString("String_Node_Str");
              new ErrorDialogWidthDetailArea(getShell(),PID,mainMsg,errors);
            }
 else {
              loginOk=true;
              MessageDialog.openInformation(getShell(),Messages.getString("String_Node_Str"),Messages.getString("String_Node_Str"));
            }
          }
 else {
            MessageDialog.openError(getShell(),Messages.getString("String_Node_Str"),Messages.getString("String_Node_Str"));
          }
        }
 catch (        Exception e1) {
          errors=e1.getMessage();
        }
        if (loginOk) {
          checkFieldsValue();
        }
      }
    }
  }
);
}