Uploaded image for project: 'Jira Data Center'
  1. Jira Data Center
  2. JRASERVER-43069

Jira activity stream not available anymore due to a problem in issue category filter

    XMLWordPrintable

Details

    Description

      NOTE: This bug report is for JIRA Server. Using JIRA Cloud? See the corresponding bug report.

      After upgrading to jira 6.4 the "JIRA" activity stream is not available anymore for new activity stream gadgets or when trying to configure existing gadgets.

      Jira stream is shown successfully in existing gadgets until someone tries to configured them: the configuration panel doesn't list the "JIRA" checkbox anymore so saving the configuration disables the jira stream completely.

      The only entry in the logs is the following, shown any time that someone tries to open the activity streams gadget configuration:

      /rest/activity-stream/1.0/config [com.atlassian.streams.internal.StreamsCompletionService] Registering failure for stream provider JIRA due to error other
      

      After some debugging we figured out the real cause by enabling logging with debug level for com.atlassian.streams.internal.StreamsCompletionService:

      Caused by: java.lang.IllegalArgumentException: duplicate key: 10001
      	at com.google.common.base.Preconditions.checkArgument(Preconditions.java:115)
      	at com.google.common.collect.RegularImmutableMap.<init>(RegularImmutableMap.java:72)
      	at com.google.common.collect.ImmutableMap$Builder.fromEntryList(ImmutableMap.java:245)
      	at com.google.common.collect.ImmutableMap$Builder.build(ImmutableMap.java:231)
      	at com.google.common.collect.Maps.uniqueIndex(Maps.java:681)
      	at com.google.common.collect.Maps.uniqueIndex(Maps.java:637)
      	at com.atlassian.streams.jira.JiraFilterOptionProvider.getProjectCategories(JiraFilterOptionProvider.java:119)
      	at com.atlassian.streams.jira.JiraFilterOptionProvider.getProjectCategoryFilter(JiraFilterOptionProvider.java:108)
      

      As you can see the original error is reported by getProjectCategoryFilter, apparently due to a project category with a duplicated id (10001 is the id for an existing project category in our instance, but obviously the id isn't actually duplicated).

      The problem looks connected to STRM-2175 and with the following commit on the streams-jira-plugin:
      https://bitbucket.org/atlassian/atlassian-streams/diff/streams-jira-plugin/src/main/java/com/atlassian/streams/jira/JiraFilterOptionProvider.java?diff2=99c5f5ff6fdb&at=activity-stream-5.4.x

      +    private Map<String, String> getProjectCategories()
      +    {
      +        return transformValues(uniqueIndex(newHashSet(transform(filter(getAllProjects(), PROJECT_HAS_CATEGORY), TO_PROJECT_CATEGORY)), TO_PROJECT_CATEGORY_KEY), TO_PROJECT_CATEGORY_LABEL);
      +    }
      

      The getProjectCategories() methods filter out all the projects with a category set, builds a set and then creates a Map with id/labels.

      There is anyway a problem in how builds the unique list of categories, since it does it building a set of ProjectCategory objects, while ProjectCategoryImpl doesn't have a proper implementation of equals/hashcode... it ends up having more objects with the same id, Maps.uniqueIndex blows up and the JIRA stream is gone forever...

      I quickly fixed it on my instance by adding an equals/hashcode implementation to com.atlassian.jira.project.ProjectCategoryImpl and I can confirm this has definitively brought the jira stream back (it could be fixed more locally by changing the implementation in JiraFilterOptionProvider)

          @Override
          public boolean equals(Object object)
          {
              if (!(object instanceof ProjectCategoryImpl))
              {
                  return false;
              }
              ProjectCategoryImpl rhs = (ProjectCategoryImpl) object;
              return new EqualsBuilder()
                  .append(this.id, rhs.id)
                  .isEquals();
          }
      
          @Override
          public int hashCode()
          {
              return new HashCodeBuilder(-156666327, -644744671).append(this.id).toHashCode();
          }
      

      I suppose this may be the cause for the problem reported by other users on 6.4.x upgrades, e.g. https://answers.atlassian.com/questions/291549/jira-activity-stream-gone-from-available-streams-section-in-activity-stream-gadget

      Attachments

        Issue Links

          Activity

            People

              pklimkowski@atlassian.com Piotr Klimkowski (Inactive)
              77d41c2ce926 Fabrizio Giustina
              Votes:
              16 Vote for this issue
              Watchers:
              34 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: