fix(codepipeline): fall back when the source poll interval is not positive (#4361)

floci.services.codepipeline.source-poll-interval-ms reached
scheduleWithFixedDelay unchecked. That call rejects a non-positive delay,
and it happens from @PostConstruct, so setting the key to 0 or a negative
value threw IllegalArgumentException while CodePipelineService was being
constructed and left the service unavailable rather than merely
mis-scheduled.

resolveSourcePollInterval now keeps a positive value and otherwise warns
and falls back to the 500ms default, matching resolveInterval in
SwfTimeoutSweeper, which guards the same hazard for the same reason: a
misconfigured interval is not worth failing every other service for.

The new test drives 0, -1 and Long.MIN_VALUE through the startup path
with a proxied EmulatorConfig, so it needs no Quarkus application of its
own. Bypassing the guard turns it red with IllegalArgumentException.

Also corrects the awaitSourcePollCycles javadoc added in #4236. It
claimed the helper blocks until the poller has had that many chances to
run, which a wall-clock sleep does not guarantee: the poller runs on a
fixed delay and each pass takes time of its own, so completed cycles are
a floor in practice. The reason the wait scales with the configured
interval is unchanged.
This commit is contained in:
Priamo Germosen authored and GitHub committed 2026-09-25 07:41:13 -05:00
1 parent 3e6c7a3472
commit 5913812b53
3 files changed
+78 -6

No files matched your search

@@ -103,7 +103,21 @@ public class CodePipelineService {
LambdaService lambdaService, S3Service s3Service,
EmulatorConfig config) {
this(storageFactory, mapper, codeBuildService, codeDeployService, lambdaService, s3Service,
config.services().codepipeline().sourcePollIntervalMs());
resolveSourcePollInterval(config.services().codepipeline().sourcePollIntervalMs()));
}
/**
* A zero or negative interval would make {@code scheduleWithFixedDelay} throw from the startup
* observer and stop the whole emulator becoming ready. A misconfigured value is not worth
* failing every other service for, so it falls back with a warning.
*/
private static long resolveSourcePollInterval(long configured) {
if (configured > 0) {
return configured;
}
LOG.warnv("Ignoring CodePipeline source poll interval {0}ms: must be a positive number of "
+ "milliseconds, falling back to {1}ms", configured, DEFAULT_SOURCE_POLL_INTERVAL_MS);
return DEFAULT_SOURCE_POLL_INTERVAL_MS;
}
@SuppressWarnings("unchecked")