QuartzDeadlineManager cancelAllWithinScope() throws NPE


We are using QuartDeadlineManager (Axon 4.5.11).

In our code we call cancelAllWithinScope(). During replay of some event handlers jobDetail can be null thus jobDetail.getJobdataMap() throws a NullPointerException.

    public void cancelAllWithinScope(String deadlineName, ScopeDescriptor scope) {
        try {
            Set<JobKey> jobKeys = scheduler.getJobKeys(GroupMatcher.jobGroupEquals(deadlineName));
            for (JobKey jobKey : jobKeys) {
                JobDetail jobDetail = scheduler.getJobDetail(jobKey);
                ScopeDescriptor jobScope = DeadlineJob.DeadlineJobDataBinder
                        .deadlineScope(serializer, jobDetail.getJobDataMap());
                if (scope.equals(jobScope)) {
        } catch (SchedulerException e) {
            throw new DeadlineException("An error occurred while cancelling a timer for a deadline manager", e);

I haven’t figured out how/why exactly.
Or should the code have a null check in there? Any ideas?

I think the best way would be to not run the cancelAll on replay. Maybe all the event handling for that handler can be skipped while replaying? It should be fine to add a null check. I think you should be able to call cancelAll with a non existing scope, and not throw an exception in that case.

Thanks for the reply @Gerard !
It looks like I have to add the null check for now.