[Fix #1515] Moving CronUtils dependency to a different module#1523
Conversation
cacf919 to
a79898a
Compare
There was a problem hiding this comment.
Pull request overview
This PR addresses #1515 by moving the cron-utils dependency out of impl/core into a dedicated impl/cron module, so downstream users don’t inherit cron parsing dependencies unless they need scheduler/cron functionality.
Changes:
- Introduces a new
serverlessworkflow-impl-cronmodule that provides aCronResolverFactoryimplementation viaServiceLoader. - Removes the
cron-utilsdependency fromserverlessworkflow-impl-coreand wires cron factory loading intoWorkflowApplication. - Updates implementation/test and jackson modules plus documentation to include/mention the new cron module.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| impl/test/pom.xml | Adds serverlessworkflow-impl-cron to test classpath. |
| impl/README.md | Documents the new serverlessworkflow-impl-cron module. |
| impl/pom.xml | Registers the new cron submodule and adds it to dependency management. |
| impl/jackson/pom.xml | Adds dependency on serverlessworkflow-impl-cron. |
| impl/cron/src/main/resources/META-INF/services/io.serverlessworkflow.impl.scheduler.CronResolverFactory | Registers cron provider for ServiceLoader. |
| impl/cron/src/main/java/io/serverlessworkflow/impl/cron/CronUtilsResolverFactory.java | New cron-utils-backed CronResolverFactory implementation. |
| impl/cron/src/main/java/io/serverlessworkflow/impl/cron/CronUtilsResolver.java | New cron-utils-backed CronResolver implementation. |
| impl/cron/pom.xml | Defines the new cron module and its dependencies. |
| impl/cron/.checkstyle | Adds an IDE checkstyle config file (problematic due to absolute paths). |
| impl/core/src/main/java/io/serverlessworkflow/impl/WorkflowApplication.java | Loads CronResolverFactory via ServiceLoader and constructs scheduler with it. |
| impl/core/src/main/java/io/serverlessworkflow/impl/scheduler/DefaultWorkflowScheduler.java | Removes the no-arg constructor tied to cron-utils implementation. |
| impl/core/src/main/java/io/serverlessworkflow/impl/scheduler/CronResolverFactory.java | Makes CronResolverFactory a prioritized service. |
| impl/core/pom.xml | Removes the cron-utils dependency from core. |
Comments suppressed due to low confidence (1)
impl/cron/src/main/java/io/serverlessworkflow/impl/cron/CronUtilsResolverFactory.java:24
CronUtilsResolverFactoryis registered viaMETA-INF/services/...CronResolverFactory, but the provider class is package-private.ServiceLoaderrequires the provider class to bepublic(and have a public no-arg constructor) or it will fail to instantiate it at runtime.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
a8d62e0 to
6888ba5
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
impl/core/src/main/java/io/serverlessworkflow/impl/scheduler/DefaultWorkflowScheduler.java:34
- Removing the public no-arg constructor is a source/binary breaking change for downstream users that instantiate
DefaultWorkflowSchedulerdirectly. Consider keeping the no-arg constructor and resolvingCronResolverFactoryviaServiceLoader(with a safe fallback) so the core module can stay free ofcron-utilswhile preserving the API.
public DefaultWorkflowScheduler(
ScheduledExecutorService service, CronResolverFactory cronFactory) {
super(service);
this.cronFactory = cronFactory;
}
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
impl/core/src/main/java/io/serverlessworkflow/impl/scheduler/DefaultWorkflowScheduler.java:34
- Removing the no-arg
DefaultWorkflowScheduler()constructor is a breaking API change for downstream users who may instantiate it directly. Consider reintroducing it and loadingCronResolverFactoryviaServiceLoader(or failing fast with a clear exception) soimpl-corecan remain cron-utils-free without breaking existing code.
public DefaultWorkflowScheduler(
ScheduledExecutorService service, CronResolverFactory cronFactory) {
super(service);
this.cronFactory = cronFactory;
}
ricardozanini
left a comment
There was a problem hiding this comment.
We need to add optional to the jackson lib or cron-utils will be imported anyway.
…ent module Signed-off-by: fjtirado <ftirados@ibm.com>
| new CronResolverFactory() { | ||
| private CronResolver emptyResolver = | ||
| new CronResolver() { | ||
| @Override | ||
| public Optional<Duration> nextExecution() { | ||
| throw new UnsupportedOperationException( | ||
| "Missing CronResolverFactory, please add serverlessworkflow-impl-cron dependency to your classpath"); | ||
| } | ||
| }; | ||
|
|
||
| @Override | ||
| public CronResolver parseCron(String cron) { | ||
| return emptyResolver; | ||
| } | ||
| }); |
Fix #1515