[
https://jira.jboss.org/jira/browse/JBPM-2517?page=com.atlassian.jira.plug...
]
Joram Barrez resolved JBPM-2517.
--------------------------------
Fix Version/s: (was: jBPM 4.2)
Resolution: Cannot Reproduce Bug
The code you posted will indeed cause overflows, since Java will use a byte for hard-coded
values < 1024.
However, the current duedate calculation code is as follows (where did your code snippet
come from?):
public long convertToMillis(Duration duration){
long millis = duration.getMillis();
millis += duration.getSeconds() * secondInMillis;
millis += duration.getMinutes() * minuteInMillis;
millis += duration.getHours() * hourInMillis;
if (duration.isBusinessTime()) {
millis += duration.getDays() * businessDayInMillis;
millis += duration.getWeeks() * businessWeekInMillis;
millis += duration.getMonths() * businessMonthInMillis;
millis += duration.getYears() * businessYearInMillis;
} else {
millis += duration.getDays() * dayInMillis;
millis += duration.getWeeks() * weekInMillis;
millis += duration.getMonths() * monthInMillis;
millis += duration.getYears() * yearInMillis;
}
return millis;
}
where the duration.getXXX are ints and the other fields are longs (eg protected long
secondInMillis = 1000; )
So the overflow doesn't happen with the current code base. Added a test case to prove
this (with 750 years).
Timer with due date set > 24 days in jPDL process definition will
cause the timer to be set in the past
-------------------------------------------------------------------------------------------------------
Key: JBPM-2517
URL:
https://jira.jboss.org/jira/browse/JBPM-2517
Project: jBPM
Issue Type: Bug
Security Level: Public(Everyone can see)
Components: Runtime Engine
Affects Versions: jBPM 4.0
Reporter: Tobias Groothuyse
Assignee: Joram Barrez
I have a process with
<time duedate="5 weeks"/>
However when this timer gets instantiated in a running process it's actual duedate
which is calculated is in the past. I traced this bug to the following piece of code:
TimerImpl.class
{code}
} else {
long millis = duration.getMillis() +
1000*( duration.getSeconds() +
60*( duration.getMinutes() +
60*( duration.getHours() +
24*( duration.getDays() +
7*duration.getWeeks()))));
dueDate = new Date(now.getTime() + millis);
}
{code}
Because all the fields from the duration object are of type int, when duration.getDays()
is larger then 24 or a weeks larger than 4 for that matter an int overflow will occur and
long millis will have a negative value.
It is probably best to use the normale calendar operations in all cases to add intervals
to the current systime.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira