Program: 33458
Project: 33458
Buggy source:
@Nullable protected ModelAndView doHandle(HttpServletRequest request,HttpServletResponse response) throws Exception {
  HashMap<String,Object> params=new HashMap<String,Object>();
  SUser myUser=SessionUser.getUser(request);
  SProject myProject=null;
  WebHookProjectSettings projSettings=null;
  if (request.getMethod().equalsIgnoreCase("String_Node_Str")) {
    if ((request.getParameter("String_Node_Str") != null)) {
      myProject=this.myServer.getProjectManager().findProjectById(request.getParameter("String_Node_Str"));
      if (myProject == null) {
        params.put("String_Node_Str","String_Node_Str");
      }
 else {
        projSettings=(WebHookProjectSettings)mySettings.getSettings(request.getParameter("String_Node_Str"),"String_Node_Str");
        if ((projSettings != null) && (myProject != null) && (myUser.isPermissionGrantedForProject(myProject.getProjectId(),Permission.EDIT_PROJECT))) {
          if ((request.getParameter("String_Node_Str") != null) && (request.getParameter("String_Node_Str").equals("String_Node_Str")) && (request.getParameter("String_Node_Str") != null)) {
            projSettings.deleteWebHook(request.getParameter("String_Node_Str"),myProject.getProjectId());
            if (projSettings.updateSuccessful()) {
              myProject.persist();
              params.put("String_Node_Str","String_Node_Str");
            }
 else {
              params.put("String_Node_Str","String_Node_Str");
            }
          }
 else           if ((request.getParameter("String_Node_Str") != null) && (request.getParameter("String_Node_Str").equals("String_Node_Str"))) {
            if ((request.getParameter("String_Node_Str") != null) && (request.getParameter("String_Node_Str").length() > 0) && (request.getParameter("String_Node_Str") != null)&& (request.getParameter("String_Node_Str").length() > 0)) {
              if (request.getParameter("String_Node_Str") != null) {
                Boolean enabled=false;
                Boolean buildTypeAll=false;
                Boolean buildTypeSubProjects=false;
                Set<String> buildTypes=new HashSet<String>();
                if ((request.getParameter("String_Node_Str") != null) && (request.getParameter("String_Node_Str").equalsIgnoreCase("String_Node_Str"))) {
                  enabled=true;
                }
                BuildState states=new BuildState();
                checkAndAddBuildState(request,states,BuildStateEnum.BUILD_SUCCESSFUL,BUILD_SUCCESSFUL);
                checkAndAddBuildState(request,states,BuildStateEnum.BUILD_FAILED,BUILD_FAILED);
                checkAndAddBuildState(request,states,BuildStateEnum.BUILD_FIXED,BUILD_FIXED);
                checkAndAddBuildState(request,states,BuildStateEnum.BUILD_BROKEN,BUILD_BROKEN);
                checkAndAddBuildState(request,states,BuildStateEnum.BUILD_STARTED,BUILD_STARTED);
                checkAndAddBuildState(request,states,BuildStateEnum.BUILD_INTERRUPTED,BUILD_INTERRUPTED);
                checkAndAddBuildState(request,states,BuildStateEnum.BEFORE_BUILD_FINISHED,BEFORE_FINISHED);
                checkAndAddBuildStateIfEitherSet(request,states,BuildStateEnum.BUILD_FINISHED,BUILD_SUCCESSFUL,BUILD_FAILED);
                checkAndAddBuildState(request,states,BuildStateEnum.RESPONSIBILITY_CHANGED,"String_Node_Str");
                if ((request.getParameter("String_Node_Str") != null) && (request.getParameter("String_Node_Str").equalsIgnoreCase("String_Node_Str"))) {
                  buildTypeSubProjects=true;
                }
                if ((request.getParameter("String_Node_Str") != null) && (request.getParameter("String_Node_Str").equalsIgnoreCase("String_Node_Str"))) {
                  buildTypeAll=true;
                }
 else {
                  if (request.getParameterValues("String_Node_Str") != null) {
                    String[] types=request.getParameterValues("String_Node_Str");
                    for (                    String string : types) {
                      buildTypes.add(string);
                    }
                  }
                }
                if (request.getParameter("String_Node_Str").equals("String_Node_Str")) {
                  projSettings.addNewWebHook(myProject.getProjectId(),request.getParameter("String_Node_Str"),enabled,states,request.getParameter("String_Node_Str"),buildTypeAll,buildTypeSubProjects,buildTypes);
                  if (projSettings.updateSuccessful()) {
                    myProject.persist();
                    params.put("String_Node_Str","String_Node_Str");
                  }
 else {
                    params.put("String_Node_Str","String_Node_Str" + projSettings.getUpdateMessage() + "String_Node_Str");
                  }
                }
 else {
                  projSettings.updateWebHook(myProject.getProjectId(),request.getParameter("String_Node_Str"),request.getParameter("String_Node_Str"),enabled,states,request.getParameter("String_Node_Str"),buildTypeAll,buildTypeSubProjects,buildTypes);
                  if (projSettings.updateSuccessful()) {
                    myProject.persist();
                    params.put("String_Node_Str","String_Node_Str");
                  }
 else {
                    params.put("String_Node_Str","String_Node_Str" + projSettings.getUpdateMessage() + "String_Node_Str");
                  }
                }
              }
            }
 else {
              if ((request.getParameter("String_Node_Str") == null) || (request.getParameter("String_Node_Str").length() == 0)) {
                params.put("String_Node_Str","String_Node_Str");
              }
 else               if ((request.getParameter("String_Node_Str") == null) || (request.getParameter("String_Node_Str").length() == 0)) {
                params.put("String_Node_Str","String_Node_Str");
              }
            }
          }
        }
 else {
          params.put("String_Node_Str","String_Node_Str");
        }
      }
    }
  }
  params.put("String_Node_Str",myManager.getRegisteredFormatsAsCollection());
  if (request.getMethod().equalsIgnoreCase("String_Node_Str") && request.getParameter("String_Node_Str") != null) {
    SProject project=TeamCityIdResolver.findProjectById(this.myServer.getProjectManager(),request.getParameter("String_Node_Str"));
    if (project != null) {
      WebHookProjectSettings projSettings1=(WebHookProjectSettings)mySettings.getSettings(request.getParameter("String_Node_Str"),"String_Node_Str");
      String message=projSettings1.getWebHooksAsString();
      params.put("String_Node_Str","String_Node_Str");
      params.put("String_Node_Str",message);
      params.put("String_Node_Str",project.getProjectId());
      params.put("String_Node_Str",TeamCityIdResolver.getExternalProjectId(project));
      params.put("String_Node_Str",project.getName());
      params.put("String_Node_Str",projSettings1.getWebHooksCount());
      if (projSettings1.getWebHooksCount() == 0) {
        params.put("String_Node_Str","String_Node_Str");
        params.put("String_Node_Str","String_Node_Str");
      }
 else {
        params.put("String_Node_Str","String_Node_Str");
        params.put("String_Node_Str","String_Node_Str");
        params.put("String_Node_Str",projSettings.getWebHooksAsList());
        params.put("String_Node_Str",!projSettings.isEnabled());
        params.put("String_Node_Str",projSettings.isEnabledAsChecked());
        params.put("String_Node_Str",ProjectWebHooksBeanJsonSerialiser.serialise(ProjectWebHooksBean.build(projSettings,project,myManager.getRegisteredFormatsAsCollection())));
      }
    }
 else {
      params.put("String_Node_Str","String_Node_Str");
    }
  }
 else {
    params.put("String_Node_Str","String_Node_Str");
  }
  return new ModelAndView(myPluginPath + "String_Node_Str",params);
}

Fixed version (ground truth):
@Nullable protected ModelAndView doHandle(HttpServletRequest request,HttpServletResponse response) throws Exception {
  HashMap<String,Object> params=new HashMap<String,Object>();
  SUser myUser=SessionUser.getUser(request);
  SProject myProject=null;
  WebHookProjectSettings projSettings=null;
  if (request.getMethod().equalsIgnoreCase("String_Node_Str")) {
    if ((request.getParameter("String_Node_Str") != null) && request.getParameter("String_Node_Str").startsWith("String_Node_Str")) {
      projSettings=(WebHookProjectSettings)mySettings.getSettings(request.getParameter("String_Node_Str"),"String_Node_Str");
      myProject=this.myServer.getProjectManager().findProjectById(request.getParameter("String_Node_Str"));
      if ((projSettings != null) && (myProject != null) && (myUser.isPermissionGrantedForProject(myProject.getProjectId(),Permission.EDIT_PROJECT))) {
        if ((request.getParameter("String_Node_Str") != null) && (request.getParameter("String_Node_Str").equals("String_Node_Str")) && (request.getParameter("String_Node_Str") != null)) {
          projSettings.deleteWebHook(request.getParameter("String_Node_Str"),myProject.getProjectId());
          if (projSettings.updateSuccessful()) {
            myProject.persist();
            params.put("String_Node_Str","String_Node_Str");
          }
 else {
            params.put("String_Node_Str","String_Node_Str");
          }
        }
 else         if ((request.getParameter("String_Node_Str") != null) && (request.getParameter("String_Node_Str").equals("String_Node_Str"))) {
          if ((request.getParameter("String_Node_Str") != null) && (request.getParameter("String_Node_Str").length() > 0) && (request.getParameter("String_Node_Str") != null)&& (request.getParameter("String_Node_Str").length() > 0)) {
            if (request.getParameter("String_Node_Str") != null) {
              Boolean enabled=false;
              Boolean buildTypeAll=false;
              Boolean buildTypeSubProjects=false;
              Set<String> buildTypes=new HashSet<String>();
              if ((request.getParameter("String_Node_Str") != null) && (request.getParameter("String_Node_Str").equalsIgnoreCase("String_Node_Str"))) {
                enabled=true;
              }
              BuildState states=new BuildState();
              checkAndAddBuildState(request,states,BuildStateEnum.BUILD_SUCCESSFUL,BUILD_SUCCESSFUL);
              checkAndAddBuildState(request,states,BuildStateEnum.BUILD_FAILED,BUILD_FAILED);
              checkAndAddBuildState(request,states,BuildStateEnum.BUILD_FIXED,BUILD_FIXED);
              checkAndAddBuildState(request,states,BuildStateEnum.BUILD_BROKEN,BUILD_BROKEN);
              checkAndAddBuildState(request,states,BuildStateEnum.BUILD_STARTED,BUILD_STARTED);
              checkAndAddBuildState(request,states,BuildStateEnum.BUILD_INTERRUPTED,BUILD_INTERRUPTED);
              checkAndAddBuildState(request,states,BuildStateEnum.BEFORE_BUILD_FINISHED,BEFORE_FINISHED);
              checkAndAddBuildStateIfEitherSet(request,states,BuildStateEnum.BUILD_FINISHED,BUILD_SUCCESSFUL,BUILD_FAILED);
              checkAndAddBuildState(request,states,BuildStateEnum.RESPONSIBILITY_CHANGED,"String_Node_Str");
              if ((request.getParameter("String_Node_Str") != null) && (request.getParameter("String_Node_Str").equalsIgnoreCase("String_Node_Str"))) {
                buildTypeSubProjects=true;
              }
              if ((request.getParameter("String_Node_Str") != null) && (request.getParameter("String_Node_Str").equalsIgnoreCase("String_Node_Str"))) {
                buildTypeAll=true;
              }
 else {
                if (request.getParameterValues("String_Node_Str") != null) {
                  String[] types=request.getParameterValues("String_Node_Str");
                  for (                  String string : types) {
                    buildTypes.add(string);
                  }
                }
              }
              if (request.getParameter("String_Node_Str").equals("String_Node_Str")) {
                projSettings.addNewWebHook(myProject.getProjectId(),request.getParameter("String_Node_Str"),enabled,states,request.getParameter("String_Node_Str"),buildTypeAll,buildTypeSubProjects,buildTypes);
                if (projSettings.updateSuccessful()) {
                  myProject.persist();
                  params.put("String_Node_Str","String_Node_Str");
                }
 else {
                  params.put("String_Node_Str","String_Node_Str" + projSettings.getUpdateMessage() + "String_Node_Str");
                }
              }
 else {
                projSettings.updateWebHook(myProject.getProjectId(),request.getParameter("String_Node_Str"),request.getParameter("String_Node_Str"),enabled,states,request.getParameter("String_Node_Str"),buildTypeAll,buildTypeSubProjects,buildTypes);
                if (projSettings.updateSuccessful()) {
                  myProject.persist();
                  params.put("String_Node_Str","String_Node_Str");
                }
 else {
                  params.put("String_Node_Str","String_Node_Str" + projSettings.getUpdateMessage() + "String_Node_Str");
                }
              }
            }
          }
 else {
            if ((request.getParameter("String_Node_Str") == null) || (request.getParameter("String_Node_Str").length() == 0)) {
              params.put("String_Node_Str","String_Node_Str");
            }
 else             if ((request.getParameter("String_Node_Str") == null) || (request.getParameter("String_Node_Str").length() == 0)) {
              params.put("String_Node_Str","String_Node_Str");
            }
          }
        }
      }
 else {
        params.put("String_Node_Str","String_Node_Str");
      }
    }
  }
  params.put("String_Node_Str",myManager.getRegisteredFormatsAsCollection());
  if (request.getMethod().equalsIgnoreCase("String_Node_Str") && request.getParameter("String_Node_Str") != null && request.getParameter("String_Node_Str").startsWith("String_Node_Str")) {
    WebHookProjectSettings projSettings1=(WebHookProjectSettings)mySettings.getSettings(request.getParameter("String_Node_Str"),"String_Node_Str");
    SProject project=this.myServer.getProjectManager().findProjectById(request.getParameter("String_Node_Str"));
    String message=projSettings1.getWebHooksAsString();
    params.put("String_Node_Str","String_Node_Str");
    params.put("String_Node_Str",message);
    params.put("String_Node_Str",project.getProjectId());
    params.put("String_Node_Str",TeamCityIdResolver.getExternalProjectId(project));
    params.put("String_Node_Str",project.getName());
    params.put("String_Node_Str",projSettings1.getWebHooksCount());
    if (projSettings1.getWebHooksCount() == 0) {
      params.put("String_Node_Str","String_Node_Str");
      params.put("String_Node_Str","String_Node_Str");
    }
 else {
      params.put("String_Node_Str","String_Node_Str");
      params.put("String_Node_Str","String_Node_Str");
      params.put("String_Node_Str",projSettings.getWebHooksAsList());
      params.put("String_Node_Str",!projSettings.isEnabled());
      params.put("String_Node_Str",projSettings.isEnabledAsChecked());
      params.put("String_Node_Str",ProjectWebHooksBeanJsonSerialiser.serialise(ProjectWebHooksBean.build(projSettings,project,myManager.getRegisteredFormatsAsCollection())));
    }
  }
 else {
    params.put("String_Node_Str","String_Node_Str");
  }
  return new ModelAndView(myPluginPath + "String_Node_Str",params);
}