Program: 127142
Project: 127142
Buggy source:
@Override protected void addFieldsListeners(){
  webServiceUrlText.addModifyListener(new ModifyListener(){
    public void modifyText(    ModifyEvent e){
      if (!isContextMode()) {
        loginOk=false;
        checkFieldsValue();
        getConnection().setWebServiceUrl(webServiceUrlText.getText());
        setCheckEnable();
      }
    }
  }
);
  userNameText.addModifyListener(new ModifyListener(){
    public void modifyText(    ModifyEvent e){
      if (!isContextMode()) {
        loginOk=false;
        checkFieldsValue();
        getConnection().setUserName(userNameText.getText());
        setCheckEnable();
      }
    }
  }
);
  passwordText.addModifyListener(new ModifyListener(){
    public void modifyText(    ModifyEvent e){
      if (!isContextMode()) {
        loginOk=false;
        checkFieldsValue();
        getConnection().setPassword(passwordText.getText());
        setCheckEnable();
      }
    }
  }
);
  batchSizeText.addModifyListener(new ModifyListener(){
    public void modifyText(    ModifyEvent e){
      if (!isContextMode()) {
        loginOk=false;
        checkFieldsValue();
        getConnection().setBatchSize(batchSizeText.getText());
        setCheckEnable();
      }
    }
  }
);
  timeOutText.addModifyListener(new ModifyListener(){
    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(){
    public void modifyText(    ModifyEvent e){
      if (!isContextMode()) {
        checkFieldsValue();
        getConnection().setProxyHost(proxyHostText.getText());
      }
    }
  }
);
  proxyPortText.addModifyListener(new ModifyListener(){
    public void modifyText(    ModifyEvent e){
      if (!isContextMode()) {
        checkFieldsValue();
        getConnection().setProxyPort(proxyPortText.getText());
      }
    }
  }
);
  proxyUsernameText.addModifyListener(new ModifyListener(){
    public void modifyText(    ModifyEvent e){
      if (!isContextMode()) {
        checkFieldsValue();
        getConnection().setProxyUsername(proxyUsernameText.getText());
      }
    }
  }
);
  proxyPasswordText.addModifyListener(new ModifyListener(){
    public void modifyText(    ModifyEvent e){
      if (!isContextMode()) {
        checkFieldsValue();
        getConnection().setProxyPassword(proxyPasswordText.getText());
      }
    }
  }
);
  authBtn.addModifyListener(new ModifyListener(){
    public void modifyText(    ModifyEvent e){
      if (!isContextMode()) {
        loginOk=false;
        checkFieldsValue();
        getConnection().setLoginType(authBtn.getItem(authBtn.getSelectionIndex()));
        setCheckEnable();
      }
    }
  }
);
  webServiceUrlTextForOAuth.addModifyListener(new ModifyListener(){
    public void modifyText(    ModifyEvent e){
      if (!isContextMode()) {
        loginOk=false;
        checkFieldsValue();
        getConnection().setWebServiceUrlTextForOAuth(webServiceUrlTextForOAuth.getText());
        setCheckEnable();
      }
    }
  }
);
  consumeKeyText.addModifyListener(new ModifyListener(){
    public void modifyText(    ModifyEvent e){
      if (!isContextMode()) {
        loginOk=false;
        checkFieldsValue();
        getConnection().setConsumeKey(consumeKeyText.getText());
        setCheckEnable();
      }
    }
  }
);
  consumeKeySecretText.addModifyListener(new ModifyListener(){
    public void modifyText(    ModifyEvent e){
      if (!isContextMode()) {
        loginOk=false;
        checkFieldsValue();
        getConnection().setConsumeSecret(consumeKeySecretText.getText());
        setCheckEnable();
      }
    }
  }
);
  callbackHostText.addModifyListener(new ModifyListener(){
    public void modifyText(    ModifyEvent e){
      if (!isContextMode()) {
        loginOk=false;
        checkFieldsValue();
        getConnection().setCallbackHost(callbackHostText.getText());
        setCheckEnable();
      }
    }
  }
);
  callbackPortText.addModifyListener(new ModifyListener(){
    public void modifyText(    ModifyEvent e){
      if (!isContextMode()) {
        loginOk=false;
        checkFieldsValue();
        getConnection().setCallbackPort(callbackPortText.getText());
        setCheckEnable();
      }
    }
  }
);
  apiVersionText.addModifyListener(new ModifyListener(){
    public void modifyText(    ModifyEvent e){
      if (!isContextMode()) {
        loginOk=false;
        checkFieldsValue();
        getConnection().setSalesforceVersion(apiVersionText.getText());
        setCheckEnable();
      }
    }
  }
);
  tokenText.addModifyListener(new ModifyListener(){
    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;
          }
          client.stopServer();
          if (code != null && !code.equals("String_Node_Str")) {
            token=client.getTokenForWizard(code);
            org.talend.salesforce.SforceManagement sfMgr=new org.talend.salesforce.SforceManagementImpl();
            String endpoint=null;
            endpoint=client.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();
              result=sfMgr.login(token.getAccess_token(),endpoint,Integer.parseInt(timeOut),false);
            }
            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(){
    public void modifyText(    ModifyEvent e){
      if (!isContextMode()) {
        loginOk=false;
        checkFieldsValue();
        getConnection().setWebServiceUrl(webServiceUrlText.getText());
        setCheckEnable();
      }
    }
  }
);
  userNameText.addModifyListener(new ModifyListener(){
    public void modifyText(    ModifyEvent e){
      if (!isContextMode()) {
        loginOk=false;
        checkFieldsValue();
        getConnection().setUserName(userNameText.getText());
        setCheckEnable();
      }
    }
  }
);
  passwordText.addModifyListener(new ModifyListener(){
    public void modifyText(    ModifyEvent e){
      if (!isContextMode()) {
        loginOk=false;
        checkFieldsValue();
        getConnection().setPassword(passwordText.getText());
        setCheckEnable();
      }
    }
  }
);
  batchSizeText.addModifyListener(new ModifyListener(){
    public void modifyText(    ModifyEvent e){
      if (!isContextMode()) {
        loginOk=false;
        checkFieldsValue();
        getConnection().setBatchSize(batchSizeText.getText());
        setCheckEnable();
      }
    }
  }
);
  timeOutText.addModifyListener(new ModifyListener(){
    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(){
    public void modifyText(    ModifyEvent e){
      if (!isContextMode()) {
        checkFieldsValue();
        getConnection().setProxyHost(proxyHostText.getText());
      }
    }
  }
);
  proxyPortText.addModifyListener(new ModifyListener(){
    public void modifyText(    ModifyEvent e){
      if (!isContextMode()) {
        checkFieldsValue();
        getConnection().setProxyPort(proxyPortText.getText());
      }
    }
  }
);
  proxyUsernameText.addModifyListener(new ModifyListener(){
    public void modifyText(    ModifyEvent e){
      if (!isContextMode()) {
        checkFieldsValue();
        getConnection().setProxyUsername(proxyUsernameText.getText());
      }
    }
  }
);
  proxyPasswordText.addModifyListener(new ModifyListener(){
    public void modifyText(    ModifyEvent e){
      if (!isContextMode()) {
        checkFieldsValue();
        getConnection().setProxyPassword(proxyPasswordText.getText());
      }
    }
  }
);
  authBtn.addModifyListener(new ModifyListener(){
    public void modifyText(    ModifyEvent e){
      if (!isContextMode()) {
        loginOk=false;
        checkFieldsValue();
        getConnection().setLoginType(authBtn.getItem(authBtn.getSelectionIndex()));
        setCheckEnable();
      }
    }
  }
);
  webServiceUrlTextForOAuth.addModifyListener(new ModifyListener(){
    public void modifyText(    ModifyEvent e){
      if (!isContextMode()) {
        loginOk=false;
        checkFieldsValue();
        getConnection().setWebServiceUrlTextForOAuth(webServiceUrlTextForOAuth.getText());
        setCheckEnable();
      }
    }
  }
);
  consumeKeyText.addModifyListener(new ModifyListener(){
    public void modifyText(    ModifyEvent e){
      if (!isContextMode()) {
        loginOk=false;
        checkFieldsValue();
        getConnection().setConsumeKey(consumeKeyText.getText());
        setCheckEnable();
      }
    }
  }
);
  consumeKeySecretText.addModifyListener(new ModifyListener(){
    public void modifyText(    ModifyEvent e){
      if (!isContextMode()) {
        loginOk=false;
        checkFieldsValue();
        getConnection().setConsumeSecret(consumeKeySecretText.getText());
        setCheckEnable();
      }
    }
  }
);
  callbackHostText.addModifyListener(new ModifyListener(){
    public void modifyText(    ModifyEvent e){
      if (!isContextMode()) {
        loginOk=false;
        checkFieldsValue();
        getConnection().setCallbackHost(callbackHostText.getText());
        setCheckEnable();
      }
    }
  }
);
  callbackPortText.addModifyListener(new ModifyListener(){
    public void modifyText(    ModifyEvent e){
      if (!isContextMode()) {
        loginOk=false;
        checkFieldsValue();
        getConnection().setCallbackPort(callbackPortText.getText());
        setCheckEnable();
      }
    }
  }
);
  apiVersionText.addModifyListener(new ModifyListener(){
    public void modifyText(    ModifyEvent e){
      if (!isContextMode()) {
        loginOk=false;
        checkFieldsValue();
        getConnection().setSalesforceVersion(apiVersionText.getText());
        setCheckEnable();
      }
    }
  }
);
  tokenText.addModifyListener(new ModifyListener(){
    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);
            org.talend.salesforce.SforceManagement sfMgr=new org.talend.salesforce.SforceManagementImpl();
            String endpoint=null;
            endpoint=client.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();
              result=sfMgr.login(token.getAccess_token(),endpoint,Integer.parseInt(timeOut),false);
            }
            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();
        }
      }
    }
  }
);
}