You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Charles Karow <ch...@karow.com> on 2022/04/21 13:11:30 UTC

Tapestry PeriodicExecutor - CronExpression issue with "L"

Hi,

There seems to be an issue with CronExpression using "L" (last day of 
month).

When I place the following code in my AppModule, the job is triggered at 
the appointed time, and then keeps executing over and over immediately 
in a seemingly infinite loop. I can work around by using a 
day-of-the-month number only, but would prefer using "L-10."

Is there any other work around?

Thanks,

Charles

     @Startup
     public static void scheduleJobs(PeriodicExecutor executor)
         {
         executor.addJob(
                 new CronSchedule("0 55 8 L-9 * ? *"),
                 "Testing",
                 new Runnable() {
                     @Override
                     public void run() {
                     System.err.println("Executing Test...");
                     }
                 });

         }


-- 
Charles Karow
Karow Associates <http://www.karow.com/>
Charles Karow Software Architect/Engineer
1.410.276.4016  • LinkedIn <http://www.linkedin.com/in/karow>
"Specializing in Fast, Reliable Web Applications"


Re: Tapestry PeriodicExecutor - CronExpression issue with "L"

Posted by Ben Weidig <be...@netzgut.net>.
Hi Charles,


I gave it a quick look and debugged
org.apache.tapestry5.ioc.internal.services.cron.CronExpression.getTimeAfter(Date)
with your expression and can confirm that there's an issue with handling
"L-<number>".

At first, it got the right day, but then it gets reset to today.

The code is quite complex, and I haven't found the bug yet.


There are three possible workarounds I can think of:

   - Implement org.apache.tapestry5.ioc.services.cron.Schedule yourself
   with another Cron-Parser. This option might be overkill and hard to get
   right.
   - Use a scheduling framework like http://www.quartz-scheduler.org/ which
   might also be a hassle to do correctly. We use it, but with a lot of
   boilerplate/glue code.
   - Schedule a Job on every 18th that calculates the next execution date
   for the "real" Job and add it with a fixed day of month.
   Jobs get removed if no further execution date is calculable, so it
   shouldn't accumulate memory over time.


I've created an issue: https://issues.apache.org/jira/browse/TAP5-2723


Cheers

Ben

On Mon, Apr 25, 2022 at 11:50 PM Charles Karow <ch...@karow.com> wrote:

> Hi,
>
> There seems to be an issue with CronExpression using "L" (last day of
> month).
>
> When I place the following code in my AppModule, the job is triggered at
> the appointed time, and then keeps executing over and over immediately in a
> seemingly infinite loop. I can work around by using a day-of-the-month
> number only, but would prefer using "L-10."
>
> Is there any other work around?
>
> Thanks,
>
> Charles
>
>     @Startup
>     public static void scheduleJobs(PeriodicExecutor executor)
>         {
>         executor.addJob(
>                 new CronSchedule("0 55 8 L-9 * ? *"),
>                 "Testing",
>                 new Runnable() {
>                     @Override
>                     public void run() {
>                     System.err.println("Executing Test...");
>                     }
>                 });
>
>         }
>
>
> --
> [image: Karow Associates] <http://www.karow.com/>
> Charles Karow  Software Architect/Engineer
> 1.410.276.4016  •  [image: LinkedIn] <http://www.linkedin.com/in/karow>
> "Specializing in Fast, Reliable Web Applications"
>
>