NullPointerException in TimerUtil.java

Hi Team,

we are migrating from Activiti to Flowable and facing the problem using timers. Everything was working fine with Activiti and Flowable v5.

public enum TimeCycleDefinition {

EVERY_DAY("0 0 12 * * ?", "Every day (default)"), // every day at 12:00
EVERY_2DAYS("0 0 12 1/2 * ?", "Every other day"), // every 2 days at 12:00
EVERY_3DAYS("0 0 12 1/3 * ?", "Every three days"), // every 3 days at 12:00
EVERY_5DAYS("0 0 12 1/5 * ?", "Every five days"), // every 5 days at 12:00
EVERY_10DAYS("0 0 12 1/10 * ?", "Every ten days"), // every 10 days at 12:00
EVERY_HOUR("0 0 0/1 * * ?", "Every hour"), // every hour
EVERY_4HOURS("0 0 0/4 * * ?", "Every 4 hours"), // every 4 hours
EVERY_8HOURS("0 0 0/8 * * ?", "Every 8 hours"), // every 8 hours
EVERY_12HOURS("0 0 0/12 * * ?", "Every 12 hours"), // every 12 hours
EVERY_MIN("0 0/1 * * * ?", "Every 1 min (test)"), // every minute (TEST)
NONE("0 0 0 1 1 ? 1970", "None"); // this event will never fire

private final String value;
private final String label;


}

If using the NONE value for timeCycle,

Flowable engine fails with NPE.

20:28:04,287 ERROR AbstractCommandContext:100 - Error while closing command context
java.lang.NullPointerException
at org.flowable.engine.impl.util.TimerUtil.createTimerEntityForTimerEventDefinition(TimerUtil.java:154)


if (repeat) {
String prepared = prepareRepeat(dueDateString);
timer.setRepeat(prepared);
}

Here timer is null.

We use org.flowable.spring.SpringAdvancedBusinessCalendarManagerFactory

Hi Alex,

I tried to reproduce the issue. Without success.
Could you try to reproduce the issue in the jUnit test please?
mvn archetype to generate jUnit test template:

mvn archetype:generate -DarchetypeGroupId=org.flowable -DarchetypeArtifactId=flowable-archetype-unittest -DarchetypeVersion=6.0.1 -DgroupId=org.flowable -DartifactId=junittest

Regards
Martin

Hi Martin,

Here is the link
https://drive.google.com/open?id=0B60Jt3r-RIpTeHBhdG5fVUpxR1k

I could not upload the file to the ticket, it allows only images.

Thank you
Alexander

Looking at the code in TimerUtil it appears that a duedate must be set to instantiate the timer variable.

Line 119:

        TimerJobEntity timer = null;
        if (duedate != null) {
            timer = Context.getCommandContext().getTimerJobEntityManager().create();

This was changed with commit 3c1c6e5ae532fd6793e1c474100e32ff2eaea705 on July 16, 2015. Prior to that commit the timer object was always allocated and not null.

Hi,

@Alex: thanks a lot for the test. The test helped me a lot to create a pull request
David is right.
I created a pull request to fix the feature
https://github.com/flowable/flowable-engine/pull/425

The question is what is mandatory for the timer to be created.

Regards
Martin

DueDate is mandatory. Tijs fixed NPE with https://github.com/flowable/flowable-engine/commit/3b9e9ec3ffaa9688e876fb594b4c0b9644258274

Hi Tijs, Martin

How can I disable the timer in this case? Before I used “0 0 0 1 1 ? 1970” specifically for this reason.

Thank you
Alexander

Hi Alexander,

The issue is that no due date can be determined with the example expression you used (0 0 0 1 1 ? 1970). You want no timer to be created in that case and the process just to continue?

Best regards,

Tijs

Hi Tijs, Martin

Yes, we have process definitions where the initiator might decide whether use notifications or not as a part of the process. It can be every day/hour etc. but also no notification at all.

Would it be possible not to create the timer if due date is overdue already?

Kind regards
Alexander

@alex.chabatar : do you mean a boundary timer event that may or may not be active dependening on the input of the initiator? Imho, the better solution would be to have an expression that evaluates a condition whether or not the boundary event should be created (and not only for timers). wdyt?