bhawnapannu2701 opened a new pull request, #3941:
URL: https://github.com/apache/logging-log4j2/pull/3941

   Problem
   ConfigurationScheduler.scheduleWithCron created a CronRunnable, scheduled 
it, and only afterwards assigned its CronScheduledFuture.
   Under fast-firing cron expressions the runnable could execute before its 
future was set, causing a NullPointerException when calling 
scheduledFuture.getFireTime().
   
   Root cause
   Race condition between scheduling the task and assigning the 
CronScheduledFuture to the runnable.
   
   Fix
   
   Assign a placeholder CronScheduledFuture to the runnable before scheduling.
   
   Update that placeholder with the real ScheduledFuture immediately after 
scheduling.
   
   Add null-guards in CronRunnable.run() and handle first execution safely.
   
   Enhance toString() to tolerate an unassigned future.
   
   Tests
   Added CronSchedulerNpeTest which schedules a cron expression firing every 
second and asserts that it runs without throwing.
   Before the fix it reproduced the NPE; after the fix all tests pass.
   
   Risks
   Minimal. Changes are contained to cron scheduling logic and do not alter 
normal scheduling semantics.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to