svn commit: r1796050 - /ofbiz/branches/release15.12/framework/service/src/org/ofbiz/service/calendar/TemporalExpressions.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r1796050 - /ofbiz/branches/release15.12/framework/service/src/org/ofbiz/service/calendar/TemporalExpressions.java

mbrohl
Author: mbrohl
Date: Wed May 24 12:38:17 2017
New Revision: 1796050

URL: http://svn.apache.org/viewvc?rev=1796050&view=rev
Log:
Fixed: Fix TemporalExpressions.Frequency to avoid moving job start times away
from given freqCount raster.
(OFBIZ-9374)

Manually applied patch because of package name differences.

If a job is scheduled using TemporalExpressions.Frequency the start time of the
job will gradually move forward when the excecution of the job is delayed by one
or more units of the frequency type.

Example: Job is set up to start at 2017-01-01 00:00:00 and run every ten
minutes. One month later due to some circumstances the job starts at
2017-02-01 00:01:01 which results in the next execution to be scheduled at
2017-02-01 01:11:00 in stead of 2017-02-01 01:10:00.

The reason behind this behaviour is the TemporalExpressions.Frequency#prepareCal
function. It has the purpose to jump from the first starting time to the latest
possible execution of the job. But instead it just sets it to the current time
(with the precision of the chosen frequency type) and calculates the next
execution time from this point.

Thanks: Tobias Laufkötter for reporting and providing the patch.

Modified:
    ofbiz/branches/release15.12/framework/service/src/org/ofbiz/service/calendar/TemporalExpressions.java

Modified: ofbiz/branches/release15.12/framework/service/src/org/ofbiz/service/calendar/TemporalExpressions.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/release15.12/framework/service/src/org/ofbiz/service/calendar/TemporalExpressions.java?rev=1796050&r1=1796049&r2=1796050&view=diff
==============================================================================
--- ofbiz/branches/release15.12/framework/service/src/org/ofbiz/service/calendar/TemporalExpressions.java (original)
+++ ofbiz/branches/release15.12/framework/service/src/org/ofbiz/service/calendar/TemporalExpressions.java Wed May 24 12:38:17 2017
@@ -710,8 +710,8 @@ public class TemporalExpressions impleme
             } else {
                 return skip;
             }
-            float units = deltaMillis / divisor;
-            units = (units / this.freqCount) * this.freqCount;
+            long units = deltaMillis / divisor;
+            units -= units % this.freqCount;
             skip.add(this.freqType, (int)units);
             while (skip.after(cal)) {
                 skip.add(this.freqType, -this.freqCount);