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

Watchers added through API (WatcherManager) can't be removed through UI

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • Low
    • None
    • 7.0.10, 7.2.0, 7.3.0, 7.4.0, 7.0.0, 7.8.0, 7.10.2
    • Java API

    Description

      Summary

      If using a post-function that mutates watchers, it can cause the watcher counts to get out of sync. This leads to being unable to remove watchers unless there is more than 1 watcher on the issue.

      Steps to Reproduce

      1. Install the JIRA Workflow Toolbox add-on.
      2. Configure it to add watchers no issue transition.
      3. Add a watcher normally.
      4. Transition an issue and add a watcher during that transition.
      5. Attempt to remove both watchers.

      Expected Results

      Both watchers can be removed.

      Actual Results

      Only one can be (the first one). If there's only one left it can't be.

      Notes

      This is not caused by the plugin as it uses our API - the problem is when the API is called during transition:

      1. In com.atlassian.jira.issue.watchers.DefaultWatcherManager#adjustWatchCount (this is what the API gets into) it creates a cloned issue and updates the watcher count and persists that. This is fine for com.atlassian.jira.web.action.issue.VoteOrWatchIssue#doExecute because nothing happens after that.
      2. However in the workflow transition, com.atlassian.jira.workflow.OSWorkflowManager#doWorkflowActionInsideTxn, it's quite different:
                    try {
                        wf.doAction(wfid, from.getAction(), inputs);
        
                        // save the issue updates - the generate change history function stores the issue as well, but if it has been modified by some post functions
                        // after that we need to store the issue again.
                        issue.store();
        
                        // commit the TX
                        txn.commit();
        
      3. The problem is inside the workflow, we perform the watch update, with the updated issue count on jiraissue, however then we store the issue again inside the transition method and it overwrites the change. Doh.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              799e74df6e6b Fidel Castro
              Votes:
              81 Vote for this issue
              Watchers:
              71 Start watching this issue

              Dates

                Created:
                Updated: