Program: 121856
Project: 121856
Buggy source:
private void addListeners(){
  if (connectionsViewer != null) {
    connectionsViewer.addSelectionChangedListener(new ISelectionChangedListener(){
      public void selectionChanged(      SelectionChangedEvent event){
        try {
          final ConnectionBean connection=getConnection();
          if (connection == null) {
            return;
          }
          if (beforeConnBean != null && connection.equals(beforeConnBean)) {
            return;
          }
          beforeConnBean=connection;
          user.setText(connection.getUser() == null ? "String_Node_Str" : connection.getUser());
          passwordText.setText(connection.getPassword() == null ? "String_Node_Str" : connection.getPassword());
          updateServerFields();
          updateVisible();
          if (validateFields()) {
            populateProjectList();
            validateProject();
          }
          setStatusArea();
          validateUpdate();
        }
 catch (        PersistenceException e) {
          ExceptionHandler.process(e);
        }
catch (        JSONException e) {
          ExceptionHandler.process(e);
        }
        displayPasswordComposite();
      }
    }
);
  }
  if (PluginChecker.isSVNProviderPluginLoaded()) {
    ModifyListener modifyListener=new ModifyListener(){
      public void modifyText(      ModifyEvent e){
        unpopulateProjectList();
        dialog.updateButtons();
        setRepositoryContextInContext();
      }
    }
;
    passwordText.addModifyListener(modifyListener);
    fillProjectsBtn.addSelectionListener(new SelectionAdapter(){
      @Override public void widgetSelected(      SelectionEvent e){
        if (validateFields()) {
          populateProjectList();
          validateProject();
        }
        try {
          setStatusArea();
        }
 catch (        PersistenceException e1) {
          ExceptionHandler.process(e1);
        }
        setRepositoryContextInContext();
      }
    }
);
    branchesViewer.addSelectionChangedListener(new ISelectionChangedListener(){
      public void selectionChanged(      SelectionChangedEvent event){
        PreferenceManipulator prefManipulator=new PreferenceManipulator(CorePlugin.getDefault().getPreferenceStore());
        String branch=getBranch();
        if (branch == null) {
          branch=SVNConstant.EMPTY;
        }
        prefManipulator.setLastSVNBranch(branch);
      }
    }
);
  }
  if (projectViewer != null) {
    projectViewer.addSelectionChangedListener(new ISelectionChangedListener(){
      public void selectionChanged(      SelectionChangedEvent event){
        PreferenceManipulator prefManipulator=new PreferenceManipulator(CorePlugin.getDefault().getPreferenceStore());
        Project project=getProject();
        prefManipulator.setLastProject(project.getLabel());
        setBranchesSetting(project,false);
        dialog.updateButtons();
        setRepositoryContextInContext();
      }
    }
);
  }
  manageConnectionsButton.addSelectionListener(new SelectionAdapter(){
    @Override public void widgetSelected(    SelectionEvent e){
      try {
        ConnectionsDialog connectionsDialog=new ConnectionsDialog(getShell());
        int open=connectionsDialog.open();
        if (open == Window.OK) {
          PreferenceManipulator prefManipulator=new PreferenceManipulator(CorePlugin.getDefault().getPreferenceStore());
          prefManipulator.saveConnections(connectionsDialog.getConnections());
          LoginComposite.this.storedConnections=connectionsDialog.getConnections();
          perReader.saveConnections(LoginComposite.this.storedConnections);
          fillContents();
          final ConnectionBean connection=getConnection();
          if (connection == null) {
            return;
          }
          beforeConnBean=connection;
          user.setText(connection.getUser() == null ? "String_Node_Str" : connection.getUser());
          passwordText.setText(connection.getPassword() == null ? "String_Node_Str" : connection.getPassword());
          updateServerFields();
          updateVisible();
          if (validateFields()) {
            populateProjectList();
            validateProject();
          }
          setStatusArea();
          validateUpdate();
          displayPasswordComposite();
        }
      }
 catch (      PersistenceException e1) {
        ExceptionHandler.process(e1);
      }
catch (      JSONException e2) {
        ExceptionHandler.process(e2);
      }
    }
  }
);
  manageProjectsButton.addSelectionListener(new SelectionAdapter(){
    @Override public void widgetSelected(    SelectionEvent e){
      ManageItem item=null;
      if (!manageViewer.getSelection().isEmpty()) {
        IStructuredSelection sel=(IStructuredSelection)manageViewer.getSelection();
        item=(ManageItem)sel.getFirstElement();
      }
      item.run();
      try {
        setStatusArea();
      }
 catch (      PersistenceException e1) {
        ExceptionHandler.process(e1);
      }
    }
  }
);
  openProjectBtn.addSelectionListener(new SelectionAdapter(){
    @Override public void widgetSelected(    SelectionEvent e){
      setRepositoryContextInContext();
      dialog.okPressed();
    }
  }
);
  restartBut.addSelectionListener(new SelectionAdapter(){
    @Override public void widgetSelected(    SelectionEvent e){
      isRestart=true;
      perReader.saveLastConnectionBean(getConnection());
      dialog.okPressed();
    }
  }
);
  updateBtn.addSelectionListener(new SelectionAdapter(){
    @Override public void widgetSelected(    SelectionEvent e){
      try {
        ICoreTisService tisService=(ICoreTisService)GlobalServiceRegister.getDefault().getService(ICoreTisService.class);
        afterUpdate=false;
        if (tisService != null) {
          JSONObject archivaProperties=getArchivaServicesProperties(getAdminURL());
          String archivaServicesURL=archivaProperties.getString(ARCHIVA_SERVICES_URL_KEY) + ARCHIVA_SERVICES_SEGMENT;
          String repository=archivaProperties.getString(ARCHIVA_REPOSITORY_KEY);
          String username=archivaProperties.getString(ARCHIVA_USER);
          String password=archivaProperties.getString(ARCHIVA_USER_PWD);
          List<String> repositories=new ArrayList<String>();
          if (repository != null) {
            repositories.add(repository);
          }
          tisService.downLoadAndInstallUpdateSites(archivaServicesURL,username,password,updateSiteToInstall,repositories);
          afterUpdate=true;
          tisService.setNeedResartAfterUpdate(afterUpdate);
          updateSiteToInstall.clear();
        }
        isRestart=true;
        perReader.saveLastConnectionBean(getConnection());
        dialog.okPressed();
      }
 catch (      Exception e1) {
        ExceptionHandler.process(e1);
      }
    }
  }
);
}

Fixed version (ground truth):
private void addListeners(){
  if (connectionsViewer != null) {
    connectionsViewer.addSelectionChangedListener(new ISelectionChangedListener(){
      public void selectionChanged(      SelectionChangedEvent event){
        try {
          final ConnectionBean connection=getConnection();
          if (connection == null) {
            return;
          }
          if (beforeConnBean != null && connection.equals(beforeConnBean)) {
            return;
          }
          beforeConnBean=connection;
          user.setText(connection.getUser() == null ? "String_Node_Str" : connection.getUser());
          passwordText.setText(connection.getPassword() == null ? "String_Node_Str" : connection.getPassword());
          updateServerFields();
          updateVisible();
          if (validateFields()) {
            populateProjectList();
            validateProject();
          }
          setStatusArea();
          validateUpdate();
        }
 catch (        PersistenceException e) {
          ExceptionHandler.process(e);
        }
catch (        JSONException e) {
          ExceptionHandler.process(e);
        }
        displayPasswordComposite();
      }
    }
);
  }
  if (PluginChecker.isSVNProviderPluginLoaded()) {
    ModifyListener modifyListener=new ModifyListener(){
      public void modifyText(      ModifyEvent e){
        unpopulateProjectList();
        dialog.updateButtons();
        setRepositoryContextInContext();
      }
    }
;
    passwordText.addModifyListener(modifyListener);
    fillProjectsBtn.addSelectionListener(new SelectionAdapter(){
      @Override public void widgetSelected(      SelectionEvent e){
        if (validateFields()) {
          populateProjectList();
          validateProject();
        }
        try {
          setStatusArea();
        }
 catch (        PersistenceException e1) {
          ExceptionHandler.process(e1);
        }
        setRepositoryContextInContext();
      }
    }
);
    branchesViewer.addSelectionChangedListener(new ISelectionChangedListener(){
      public void selectionChanged(      SelectionChangedEvent event){
        PreferenceManipulator prefManipulator=new PreferenceManipulator(CorePlugin.getDefault().getPreferenceStore());
        String branch=getBranch();
        if (branch == null) {
          branch=SVNConstant.EMPTY;
        }
        prefManipulator.setLastSVNBranch(branch);
      }
    }
);
  }
  if (projectViewer != null) {
    projectViewer.addSelectionChangedListener(new ISelectionChangedListener(){
      public void selectionChanged(      SelectionChangedEvent event){
        PreferenceManipulator prefManipulator=new PreferenceManipulator(CorePlugin.getDefault().getPreferenceStore());
        Project project=getProject();
        prefManipulator.setLastProject(project.getLabel());
        setBranchesSetting(project,false);
        dialog.updateButtons();
        setRepositoryContextInContext();
      }
    }
);
  }
  manageConnectionsButton.addSelectionListener(new SelectionAdapter(){
    @Override public void widgetSelected(    SelectionEvent e){
      try {
        ConnectionsDialog connectionsDialog=new ConnectionsDialog(getShell());
        int open=connectionsDialog.open();
        if (open == Window.OK) {
          LoginComposite.this.storedConnections=connectionsDialog.getConnections();
          perReader.saveConnections(LoginComposite.this.storedConnections);
          fillContents();
          final ConnectionBean connection=getConnection();
          if (connection == null) {
            return;
          }
          beforeConnBean=connection;
          user.setText(connection.getUser() == null ? "String_Node_Str" : connection.getUser());
          passwordText.setText(connection.getPassword() == null ? "String_Node_Str" : connection.getPassword());
          updateServerFields();
          updateVisible();
          if (validateFields()) {
            populateProjectList();
            validateProject();
          }
          setStatusArea();
          validateUpdate();
          displayPasswordComposite();
        }
      }
 catch (      PersistenceException e1) {
        ExceptionHandler.process(e1);
      }
catch (      JSONException e2) {
        ExceptionHandler.process(e2);
      }
    }
  }
);
  manageProjectsButton.addSelectionListener(new SelectionAdapter(){
    @Override public void widgetSelected(    SelectionEvent e){
      ManageItem item=null;
      if (!manageViewer.getSelection().isEmpty()) {
        IStructuredSelection sel=(IStructuredSelection)manageViewer.getSelection();
        item=(ManageItem)sel.getFirstElement();
      }
      item.run();
      try {
        setStatusArea();
      }
 catch (      PersistenceException e1) {
        ExceptionHandler.process(e1);
      }
    }
  }
);
  openProjectBtn.addSelectionListener(new SelectionAdapter(){
    @Override public void widgetSelected(    SelectionEvent e){
      setRepositoryContextInContext();
      dialog.okPressed();
    }
  }
);
  restartBut.addSelectionListener(new SelectionAdapter(){
    @Override public void widgetSelected(    SelectionEvent e){
      isRestart=true;
      perReader.saveLastConnectionBean(getConnection());
      dialog.okPressed();
    }
  }
);
  updateBtn.addSelectionListener(new SelectionAdapter(){
    @Override public void widgetSelected(    SelectionEvent e){
      try {
        ICoreTisService tisService=(ICoreTisService)GlobalServiceRegister.getDefault().getService(ICoreTisService.class);
        afterUpdate=false;
        if (tisService != null) {
          JSONObject archivaProperties=getArchivaServicesProperties(getAdminURL());
          String archivaServicesURL=archivaProperties.getString(ARCHIVA_SERVICES_URL_KEY) + ARCHIVA_SERVICES_SEGMENT;
          String repository=archivaProperties.getString(ARCHIVA_REPOSITORY_KEY);
          String username=archivaProperties.getString(ARCHIVA_USER);
          String password=archivaProperties.getString(ARCHIVA_USER_PWD);
          List<String> repositories=new ArrayList<String>();
          if (repository != null) {
            repositories.add(repository);
          }
          tisService.downLoadAndInstallUpdateSites(archivaServicesURL,username,password,updateSiteToInstall,repositories);
          afterUpdate=true;
          tisService.setNeedResartAfterUpdate(afterUpdate);
          updateSiteToInstall.clear();
        }
        isRestart=true;
        perReader.saveLastConnectionBean(getConnection());
        dialog.okPressed();
      }
 catch (      Exception e1) {
        ExceptionHandler.process(e1);
      }
    }
  }
);
}