Uploaded image for project: 'Jira Software Data Center'
  1. Jira Software Data Center
  2. JSWSERVER-10781

GHConfiguration#getGrantedProjects not thread safe

    XMLWordPrintable

Details

    • Bug
    • Resolution: Obsolete
    • Low
    • None
    • None
    • None

    Description

      This only affects Classic mode.

      grantedProjects should be replaced with a com.atlassian.util.concurrent.LazyReference, otherwise concurrent calls to getGrantedProjects before the value is cached can create a corrupt HashSet resulting in undefined behaviour when it is accessed.

      This can result in a significant number of long running threads:

      "http-bio-8080-exec-177" daemon prio=3 tid=0x000000000c775000 nid=0x16e runnable [0xfffffd775cf79000]
         java.lang.Thread.State: RUNNABLE
      	at java.util.HashMap.getEntry(HashMap.java:469)
      	at java.util.HashMap.containsKey(HashMap.java:453)
      	at java.util.HashSet.contains(HashSet.java:201)
      	at com.pyxis.greenhopper.jira.configurations.GHConfiguration.getUserAdmissibleProjects(GHConfiguration.java:209)
      	at com.pyxis.greenhopper.jira.conditions.CanAccessClassicBoardsCondition.hasBrowsePermissionForAdmissibleProject(CanAccessClassicBoardsCondition.java:28)
      	at com.pyxis.greenhopper.jira.conditions.CanAccessClassicBoardsCondition.condition(CanAccessClassicBoardsCondition.java:22)
      	at com.pyxis.greenhopper.jira.conditions.AbstractGreenHopperCondition.shouldDisplay(AbstractGreenHopperCondition.java:26)
      	at com.atlassian.jira.plugin.webfragment.conditions.AbstractJiraCondition.shouldDisplay(AbstractJiraCondition.java:40)
      	at com.atlassian.plugin.web.DefaultWebInterfaceManager.filterFragmentsByCondition(DefaultWebInterfaceManager.java:172)
      	at com.atlassian.plugin.web.DefaultWebInterfaceManager.getDisplayableSections(DefaultWebInterfaceManager.java:73)
      	at com.atlassian.jira.plugin.webfragment.JiraWebInterfaceManager.getDisplayableSections(JiraWebInterfaceManager.java:60)
      	at com.atlassian.jira.plugin.webfragment.DefaultSimpleLinkManager.shouldLocationBeLazy(DefaultSimpleLinkManager.java:79)
      	at sun.reflect.GeneratedMethodAccessor635.invoke(Unknown Source)
      

      The code is:

          public TreeSet<Project> getUserAdmissibleProjects(User user)
          {
              TreeSet<Project> userProjects = new TreeSet<Project>(new ProjectNameComparator());
              Collection<Project> browsableProjects = ManagerFactory.getPermissionManager().getProjectObjects(Permissions.BROWSE, user);
              if(isGlobalContext())
              {
              	userProjects.addAll(browsableProjects);
              }
              else
              {
      	        /**
      	         * @TODO This is a workaround since contains does not seem to work on JIRA 4.0
      	         */
      	    	for(Project aProject : browsableProjects)
      	    	{
      	    		if(getGrantedProjects().contains(aProject.getId()))
      	    		{
      	    			userProjects.add(aProject);
      	    		}
      	    	}
              }
              
              return userProjects;
          }
      
      

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              dtang David Tang (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: