[ 
https://issues.apache.org/jira/browse/AMQ-4591?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13701630#comment-13701630
 ] 

Rafael Alfaro commented on AMQ-4591:
------------------------------------

No, what I tried to mean, is that the current behaviour with the current code 
on SVN is that the next schedule time is the current time + 60 seconds for the 
pattern "* * * * *".
But the correct behaviour, must have to be, to calculate the top of the next 
minute.

If you look at the code:
https://svn.apache.org/repos/asf/activemq/trunk/activemq-client/src/main/java/org/apache/activemq/broker/scheduler/CronParser.java

The issue is at the line 47:

            result = result / 1000 * 1000;
 
the previous formula, sets the precision to "seconds", so, if the current time 
is 00:01:40, de next scheduled time will be 00:02:40
That is not correct, because the next scheduled time must have to be the top of 
the next minute.
So, to calculate the top of the next minute, the previous formula must have to 
be:

            result = result / 60000 * 60000;



That is the why I proposed to following patch:


Index: 
activemq-client/src/main/java/org/apache/activemq/broker/scheduler/CronParser.java
===================================================================
--- 
activemq-client/src/main/java/org/apache/activemq/broker/scheduler/CronParser.java
  (revision 1494862)
+++ 
activemq-client/src/main/java/org/apache/activemq/broker/scheduler/CronParser.java
  (working copy)
@@ -44,7 +44,7 @@
         // starting the next event at the top of the minute.
         if (cronEntry.equals("* * * * *")) {
             result = currentTime + 60 * 1000;
-            result = result / 1000 * 1000;
+            result = result / 60000 * 60000;
             return result;
         }
 

                
> CronParser bug on getNextScheduledTime to handle the once per minute case "* 
> * * * *"
> -------------------------------------------------------------------------------------
>
>                 Key: AMQ-4591
>                 URL: https://issues.apache.org/jira/browse/AMQ-4591
>             Project: ActiveMQ
>          Issue Type: Bug
>          Components: Broker
>    Affects Versions: 5.8.0, 5.9.0
>         Environment: Any
>            Reporter: Rafael Alfaro
>              Labels: patch
>         Attachments: CronParser.java.patch
>
>   Original Estimate: 1h
>  Remaining Estimate: 1h
>
> There is a Bug on handle the once per minute case.
> For the cronentry: "* * * * *" 
> The Next Scheduled time is not the top of the next minute.
> Instead, is the current Time plus 60 seconds
> The problem is that the code is trying to set the precision at seconds, but 
> the precision must have to be at minutes. 
> You can check the patch attached to see the change required to fix this issue.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to