Hi Everybody,
I have a problem with a quite simple groovy script. The script shall remove all watchers from an issue after issue creation. I want to implement it as a post-function after the creation. The script runs fine from the Script Runner Console (with the commented line uncommented and the next one commented instead) but if I save it and append it to the create transission, I get a null pointer.
Here is the code:
import com.atlassian.jira.ComponentManager;
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.issue.MutableIssue;
import java.util.Locale;
def watcherManager = ComponentManager.getInstance().getWatcherManager();
//MutableIssue issue = componentManager.getIssueManager().getIssueObject("UMWCC-2");
Issue issue = issue;
List<ApplicationUser> watchers = watcherManager.getWatchers(issue,Locale.getDefault());
for (ApplicationUser user:watchers){
watcherManager.stopWatching(user,issue);
}There is not even a StackTrace in the log. All there is is:
2014-10-23 19:23:42,898 http-bio-8080-exec-18 ERROR chris 1163x12866x1 135bdgr 192.168.195.54 /secure/QuickCreateIssue.jspa [groovy.canned.utils.ConditionUtils] javax.script.ScriptException: java.lang.NullPointerException: Cannot invoke method contains() on null object
I tried a bit of debugging, using the
import org.apache.log4j.Category
def Category log = Category.getInstance("com.onresolve.jira.groovy.PostFunction")
log.setLevel(org.apache.log4j.Level.DEBUG)
log.debug "debug statements"routine with some calls before and after the
watcherManager.stopWatching(user,issue);
But the loop seems to work well...
Can somebody help me here?
Thanks,
Chris