public void execute(Map transientVars, Map args, PropertySet ps) { MutableIssue issue = (MutableIssue) transientVars.get("issue"); issue.setAssignee(issue.getReporter()); // JRA-15120: issue.store() should never have been called in this function, as it can cause the Issue object // to be persisted to the database prematurely. However, since it has been here for a while, removing it could // break existing functionality for lots of users. But, because an NPE is only thrown when this function is used // in the Create step, all we have to do to prevent this error from occuring is check if the issue has already // been stored before. If it has, we can call store() to update the issue, which maintains working (albeit // incorrect) behaviour. If it hasn't, we defer the store() call, as it should have been implemented initially. if (issue.isCreated()) { issue.store(); } } }
@Override public void execute(Map transientVars, Map args, PropertySet ps) throws WorkflowException { final String webHookId = (String) args.get(TriggerWebHookFunctionPluginFactory.TARGET_FIELD_ID); final Option<PersistentWebHookListener> webHookOption = webHookListenerService.getWebHookListener(Integer.parseInt(webHookId)); if (webHookOption.isEmpty()) { logger.error(i18n.getText("webhooks.postfunction.deleted")); return; } final PersistentWebHookListener listener = webHookOption.get(); final MutableIssue issue = getIssue(transientVars); if (issue == null || !issue.isCreated()) { logger.error("Transition cannot be sent to webhook as an issue has not been created yet."); return; } final Optional<String> filter = Optional.fromNullable(JqlFilterStoreUtils.getJqlFilter(listener)); if (listener.isEnabled() && jqlEventMatcher.matchJql(filter.orNull(), issue)) { final Map<String, Object> data = transitionMapper.toMap(transientVars, getCaller(transientVars, args), issue); try { boolean excludeIssueDetails = listener.isExcludeBody(); final String message = excludeIssueDetails ? "" : new TransitionSerializer(data).getJson(); eventPublisher.publish(new WebHookPostFunctionEvent(listener.getId().get(), message, issue)); } catch (IOException e) { logger.error("Error serializing post-function context", e); } } }
if (issue.isCreated())