Skip to content

Commit

Permalink
Wrap cron expression issues into appropriate exception
Browse files Browse the repository at this point in the history
to prevent crashing the application start up when the cron expression has wrong format
  • Loading branch information
musketyr committed Nov 12, 2024
1 parent a8b61a7 commit e801951
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,11 @@ public void schedule(com.agorapulse.worker.Job job) {
if (LOG.isDebugEnabled()) {
LOG.debug("Scheduling cron job {} [{}] for {}", configuration.getName(), configuration.getCron(), job.getSource());
}
taskScheduler.schedule(configuration.getCron(), job);
try {
taskScheduler.schedule(configuration.getCron(), job);
} catch (IllegalArgumentException e) {
throw new JobConfigurationException(job, "Failed to schedule job " + configuration.getName() + " declared in " + job.getSource() + ". Invalid CRON expression: " + configuration.getCron(), e);
}
} else if (configuration.getFixedRate() != null) {
Duration duration = configuration.getFixedRate();
if (LOG.isDebugEnabled()) {
Expand Down

0 comments on commit e801951

Please sign in to comment.