Uploaded image for project: 'Jira Service Management Data Center'
  1. Jira Service Management Data Center
  2. JSDSERVER-2383

NullPointerException when retrieving automation rule prevents automation rules from running

    XMLWordPrintable

Details

    Description

      Problem:

      While retrieving an automation rule a NullPointerException is encountered. This stops automation and prevents subsequent automation rules from running.

      • Automation retrieves each rule when running so that automation may determine if the rule should run.
      • The automation rule that throws the NullPointerException could be from any Service Desk, the offending rule does not have to be in the same desk as the event triggering automation to run.
      Expected Behavior:
      • A problem with one automation rule does not prevent other rules from running
      • A problem, such as NullPointerException, in one Service Desk project does not affect other Service Desk projects.
      Steps to reproduce:
      • Create two Service Desk projects
      • In each project, create two rules that run when the issue is commented. The rules should run as current user.
      • Set up a regular JIRA create or comment mail handler pointing to one of the Service Desk projects.
      • Create issue from email in one of these projects, then comment on the issue from email.

      The following will appear in the atlassian-jira.log file:

      2015-10-01 00:19:17,134 atlassian-scheduler-quartz1.clustered_Worker-3 WARN ServiceRunner    TechOps [com.atlassian.ozymandias.SafePluginPointAccess] Unable to run plugin code because of 'java.lang.NullPointerException - null'.
      

      When automation is retrieving the rules it will run any that are set to run as a specified user, up until the point where automation encounters the rule running as current user. At this point the NullPointerException will be thrown and no subsequent automation rules will be retrieved.

      No stacktrace appears in the JIRA logs with standard logging settings. The stacktrace from debugging is as follows:

      2015-10-01 15:48:28,105 atlassian-scheduler-quartz1.clustered_Worker-4 DEBUG ServiceRunner    TechOps [com.atlassian.ozymandias.SafePluginPointAccess] Unable to run plugin code because of 'java.lang.NullPointerException - null'.
      java.lang.NullPointerException
      	at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:187)
      	at com.atlassian.fugue.Either.right(Either.java:76)
      	at com.atlassian.pocketknife.api.commons.result.ServiceResult.ok(ServiceResult.java:25)
      	at com.atlassian.servicedesk.plugins.automation.internal.execution.context.user.JiraAuthenticationContextCurrentUserProvider.getCurrentUser(JiraAuthenticationContextCurrentUserProvider.java:29)
      	at com.atlassian.servicedesk.plugins.automation.internal.execution.context.user.RunAsUserContextManagerImpl.getUserFromContext(RunAsUserContextManagerImpl.java:208)
      	at com.atlassian.servicedesk.plugins.automation.internal.execution.whenhandler.WhenHandlerServiceImpl.getContextsForWhenHandlerKey(WhenHandlerServiceImpl.java:68)
      	at com.atlassian.servicedesk.plugins.automation.internal.execution.whenhandler.event.AllEventListenerEventWhenHandlerVisitor.visit(AllEventListenerEventWhenHandlerVisitor.java:49)
      	at com.atlassian.servicedesk.plugins.automation.internal.module.EventWhenHandlerManagerImpl$1.visit(EventWhenHandlerManagerImpl.java:36)
      	at com.atlassian.servicedesk.plugins.automation.internal.module.EventWhenHandlerManagerImpl$1.visit(EventWhenHandlerManagerImpl.java:32)
      	at com.atlassian.ozymandias.SafePluginPointAccess.invokeModule(SafePluginPointAccess.java:528)
      	at com.atlassian.ozymandias.SafePluginPointAccess.descriptors(SafePluginPointAccess.java:206)
      	at com.atlassian.ozymandias.SafePluginPointAccess.forType(SafePluginPointAccess.java:106)
      	at com.atlassian.servicedesk.plugins.automation.internal.module.EventWhenHandlerManagerImpl.visitAll(EventWhenHandlerManagerImpl.java:42)
      	at com.atlassian.servicedesk.plugins.automation.internal.execution.whenhandler.event.AllEventsListener.invokeHandlers(AllEventsListener.java:94)
      	at com.atlassian.servicedesk.plugins.automation.internal.execution.whenhandler.event.AllEventsListener.access$000(AllEventsListener.java:22)
      	at com.atlassian.servicedesk.plugins.automation.internal.execution.whenhandler.event.AllEventsListener$1.call(AllEventsListener.java:64)
      	at com.atlassian.servicedesk.plugins.automation.internal.execution.whenhandler.event.AllEventsListener$1.call(AllEventsListener.java:60)
      	at com.atlassian.ozymandias.SafePluginPointAccess.call(SafePluginPointAccess.java:263)
      	at com.atlassian.servicedesk.plugins.automation.internal.execution.whenhandler.event.AllEventsListener.onAllEvents(AllEventsListener.java:59)
      	at sun.reflect.GeneratedMethodAccessor102.invoke(Unknown Source)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      	at java.lang.reflect.Method.invoke(Unknown Source)
      	at com.atlassian.event.internal.SingleParameterMethodListenerInvoker.invoke(SingleParameterMethodListenerInvoker.java:36)
      	at com.atlassian.event.internal.AsynchronousAbleEventDispatcher$1$1.run(AsynchronousAbleEventDispatcher.java:48)
      	at com.google.common.util.concurrent.MoreExecutors$SameThreadExecutorService.execute(MoreExecutors.java:253)
      	at com.atlassian.event.internal.AsynchronousAbleEventDispatcher.dispatch(AsynchronousAbleEventDispatcher.java:107)
      	at com.atlassian.event.internal.EventPublisherImpl.invokeListeners(EventPublisherImpl.java:160)
      	at com.atlassian.event.internal.EventPublisherImpl.publish(EventPublisherImpl.java:79)
      	at sun.reflect.GeneratedMethodAccessor154.invoke(Unknown Source)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      	at java.lang.reflect.Method.invoke(Unknown Source)
      	at com.atlassian.plugin.osgi.hostcomponents.impl.DefaultComponentRegistrar$ContextClassLoaderSettingInvocationHandler.invoke(DefaultComponentRegistrar.java:134)
      	at com.sun.proxy.$Proxy333.publish(Unknown Source)
      	at sun.reflect.GeneratedMethodAccessor154.invoke(Unknown Source)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      	at java.lang.reflect.Method.invoke(Unknown Source)
      	at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
      	at org.springframework.osgi.service.importer.support.internal.aop.ServiceInvoker.doInvoke(ServiceInvoker.java:58)
      	at org.springframework.osgi.service.importer.support.internal.aop.ServiceInvoker.invoke(ServiceInvoker.java:62)
      	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
      	at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)
      	at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119)
      	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
      	at org.springframework.osgi.service.util.internal.aop.ServiceTCCLInterceptor.invokeUnprivileged(ServiceTCCLInterceptor.java:56)
      	at org.springframework.osgi.service.util.internal.aop.ServiceTCCLInterceptor.invoke(ServiceTCCLInterceptor.java:39)
      	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
      	at org.springframework.osgi.service.importer.support.LocalBundleContextAdvice.invoke(LocalBundleContextAdvice.java:59)
      	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
      	at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)
      	at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119)
      	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
      	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
      	at com.sun.proxy.$Proxy4303.publish(Unknown Source)
      	at com.atlassian.servicedesk.internal.listener.ServiceDeskCommentEventPublisher$$anon$1$$anonfun$run$1$$anonfun$apply$1$$anonfun$apply$2$$anonfun$apply$4.apply(ServiceDeskCommentEventPublisher.scala:47)
      	at com.atlassian.servicedesk.internal.listener.ServiceDeskCommentEventPublisher$$anon$1$$anonfun$run$1$$anonfun$apply$1$$anonfun$apply$2$$anonfun$apply$4.apply(ServiceDeskCommentEventPublisher.scala:43)
      	at scala.Option$WithFilter.map(Option.scala:206)
      	at com.atlassian.servicedesk.internal.listener.ServiceDeskCommentEventPublisher$$anon$1$$anonfun$run$1$$anonfun$apply$1$$anonfun$apply$2.apply(ServiceDeskCommentEventPublisher.scala:43)
      	at com.atlassian.servicedesk.internal.listener.ServiceDeskCommentEventPublisher$$anon$1$$anonfun$run$1$$anonfun$apply$1$$anonfun$apply$2.apply(ServiceDeskCommentEventPublisher.scala:42)
      	at scala.Option.flatMap(Option.scala:170)
      	at com.atlassian.servicedesk.internal.listener.ServiceDeskCommentEventPublisher$$anon$1$$anonfun$run$1$$anonfun$apply$1.apply(ServiceDeskCommentEventPublisher.scala:42)
      	at com.atlassian.servicedesk.internal.listener.ServiceDeskCommentEventPublisher$$anon$1$$anonfun$run$1$$anonfun$apply$1.apply(ServiceDeskCommentEventPublisher.scala:41)
      	at scala.Option.flatMap(Option.scala:170)
      	at com.atlassian.servicedesk.internal.listener.ServiceDeskCommentEventPublisher$$anon$1$$anonfun$run$1.apply(ServiceDeskCommentEventPublisher.scala:41)
      	at com.atlassian.servicedesk.internal.listener.ServiceDeskCommentEventPublisher$$anon$1$$anonfun$run$1.apply(ServiceDeskCommentEventPublisher.scala:40)
      	at scala.Option.flatMap(Option.scala:170)
      	at com.atlassian.servicedesk.internal.listener.ServiceDeskCommentEventPublisher$$anon$1.run(ServiceDeskCommentEventPublisher.scala:40)
      	at com.atlassian.servicedesk.internal.util.SafeRunner$1.call(SafeRunner.java:39)
      	at com.atlassian.servicedesk.internal.util.SafeRunner$1.call(SafeRunner.java:35)
      	at com.atlassian.servicedesk.bootstrap.lifecycle.LifecycleLock$1.call(LifecycleLock.java:60)
      	at com.atlassian.servicedesk.bootstrap.lifecycle.LifecycleLock$1.call(LifecycleLock.java:47)
      	at com.atlassian.ozymandias.SafePluginPointAccess.call(SafePluginPointAccess.java:263)
      	at com.atlassian.servicedesk.internal.util.SafeRunner.run(SafeRunner.java:44)
      	at com.atlassian.servicedesk.internal.listener.ServiceDeskCommentEventPublisher.onCommentEvent(ServiceDeskCommentEventPublisher.scala:36)
      	at com.atlassian.servicedesk.bootstrap.listener.EventListenerLauncher.onIssueEvent(EventListenerLauncher.java:90)
      	at sun.reflect.GeneratedMethodAccessor840.invoke(Unknown Source)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      	at java.lang.reflect.Method.invoke(Unknown Source)
      	at com.atlassian.event.internal.SingleParameterMethodListenerInvoker.invoke(SingleParameterMethodListenerInvoker.java:36)
      	at com.atlassian.event.internal.AsynchronousAbleEventDispatcher$1$1.run(AsynchronousAbleEventDispatcher.java:48)
      	at com.google.common.util.concurrent.MoreExecutors$SameThreadExecutorService.execute(MoreExecutors.java:253)
      	at com.atlassian.event.internal.AsynchronousAbleEventDispatcher.dispatch(AsynchronousAbleEventDispatcher.java:107)
      	at com.atlassian.event.internal.EventPublisherImpl.invokeListeners(EventPublisherImpl.java:160)
      	at com.atlassian.event.internal.EventPublisherImpl.publish(EventPublisherImpl.java:79)
      	at com.atlassian.jira.event.issue.DefaultIssueEventManager.publishEvent(DefaultIssueEventManager.java:145)
      	at com.atlassian.jira.event.issue.DefaultIssueEventManager.publishAsRedundant(DefaultIssueEventManager.java:159)
      	at com.atlassian.jira.event.issue.DefaultIssueEventManager.dispatchRedundantEvent(DefaultIssueEventManager.java:123)
      	at com.atlassian.jira.issue.util.DefaultIssueUpdater.storeModifiedFields(DefaultIssueUpdater.java:112)
      	at com.atlassian.jira.issue.util.DefaultIssueUpdater.doUpdate(DefaultIssueUpdater.java:59)
      	at com.atlassian.jira.plugins.mail.handlers.AbstractCommentHandler.update(AbstractCommentHandler.java:232)
      	at com.atlassian.jira.plugins.mail.handlers.AbstractCommentHandler.handleMessage(AbstractCommentHandler.java:167)
      	at com.atlassian.jira.plugins.mail.handlers.CreateOrCommentHandler.handleMessage(CreateOrCommentHandler.java:98)
      	at com.atlassian.jira.service.services.mail.MailFetcherService$1.process(MailFetcherService.java:438)
      	at com.atlassian.jira.service.services.mail.MailFetcherService$MessageProviderImpl.getAndProcessMail(MailFetcherService.java:304)
      	at com.atlassian.jira.service.services.mail.MailFetcherService.runImpl(MailFetcherService.java:426)
      	at com.atlassian.jira.service.services.file.AbstractMessageHandlingService.run(AbstractMessageHandlingService.java:263)
      	at com.atlassian.jira.service.JiraServiceContainerImpl.run(JiraServiceContainerImpl.java:66)
      	at com.atlassian.jira.service.ServiceRunner.runService(ServiceRunner.java:76)
      	at com.atlassian.jira.service.ServiceRunner.runServiceId(ServiceRunner.java:54)
      	at com.atlassian.jira.service.ServiceRunner.runJob(ServiceRunner.java:37)
      	at com.atlassian.scheduler.core.JobLauncher.runJob(JobLauncher.java:136)
      	at com.atlassian.scheduler.core.JobLauncher.launchAndBuildResponse(JobLauncher.java:101)
      	at com.atlassian.scheduler.core.JobLauncher.launch(JobLauncher.java:80)
      	at com.atlassian.scheduler.quartz1.Quartz1Job.execute(Quartz1Job.java:32)
      	at org.quartz.core.JobRunShell.run(JobRunShell.java:223)
      	at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:549)
      
      Workaround

      In the example above the regular JIRA mail handler is being used. Service Desk projects should use the Service Desk email channel, not the standard JIRA mail handlers.

      Another workaround for the example above is to set the automation rules to run as a specified user, not current user.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              tevans Tim Evans (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              15 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Backbone Issue Sync