apache/pulsar · error · IllegalArgumentException
Not support to set continueExistingPeriodicTasksAfterShutdow
Error message
Not support to set continueExistingPeriodicTasksAfterShutdownPolicy, it is always false
What it means
SingleThreadNonConcurrentFixedRateScheduler always behaves as if continueExistingPeriodicTasksAfterShutdownPolicy is false: after shutdown, periodic tasks are never continued. Therefore the inherited setContinueExistingPeriodicTasksAfterShutdownPolicy method unconditionally throws IllegalArgumentException to reject any attempt to change this fixed policy.
Source
Thrown at pulsar-common/src/main/java/org/apache/pulsar/common/util/SingleThreadNonConcurrentFixedRateScheduler.java:199
* Long.MAX_VALUE.
*/
private long overflowFree(long delay) {
Delayed head = (Delayed) super.getQueue().peek();
if (head != null) {
long headDelay = head.getDelay(NANOSECONDS);
if (headDelay < 0 && (delay - headDelay < 0)) {
delay = Long.MAX_VALUE + headDelay;
}
}
return delay;
}
/**
* {@inheritDoc}
*/
@Override
public void setContinueExistingPeriodicTasksAfterShutdownPolicy(boolean flag) {
throw new IllegalArgumentException("Not support to set continueExistingPeriodicTasksAfterShutdownPolicy, it is"
+ " always false");
}
/**
* {@inheritDoc}
*/
@Override
public boolean getContinueExistingPeriodicTasksAfterShutdownPolicy() {
return false;
}
/**
* {@inheritDoc}
*/
@Override
public void setExecuteExistingDelayedTasksAfterShutdownPolicy(boolean flag) {
throw new IllegalArgumentException("Not support to set executeExistingDelayedTasksAfterShutdownPolicy, it is"
+ " always false");View on GitHub (pinned to 820761864e)
Solutions
- Remove the call to setContinueExistingPeriodicTasksAfterShutdownPolicy; the scheduler intentionally never continues periodic tasks after shutdown.
- Adjust generic scheduler-configuration code to skip this policy for this scheduler type (e.g. instanceof check or capability flag).
- If post-shutdown execution of periodic tasks is required, use a plain ScheduledThreadPoolExecutor instead of this scheduler.
- Handle the IllegalArgumentException defensively if the call site must stay source-compatible with multiple scheduler types.
Example fix
// before
scheduler.setContinueExistingPeriodicTasksAfterShutdownPolicy(true);
// after
if (!(scheduler instanceof SingleThreadNonConcurrentFixedRateScheduler)) {
scheduler.setContinueExistingPeriodicTasksAfterShutdownPolicy(true);
} Defensive patterns
Strategy: try-catch
Validate before calling
static boolean supportsShutdownPolicies(java.util.concurrent.ScheduledExecutorService s) {
return !(s instanceof org.apache.pulsar.common.util.SingleThreadNonConcurrentFixedRateScheduler);
} Type guard
static boolean isPolicyConfigurable(java.util.concurrent.ScheduledExecutorService s) {
return s instanceof java.util.concurrent.ScheduledThreadPoolExecutor;
} Try / catch
try {
scheduler.setContinueExistingPeriodicTasksAfterShutdownPolicy(flag);
} catch (IllegalArgumentException e) {
LOG.info("Scheduler {} does not support shutdown policy override: {}", scheduler, e.getMessage());
} Prevention
- Do not call shutdown-policy setters on SingleThreadNonConcurrentFixedRateScheduler — the policies are fixed to false
- Gate generic executor-tuning code with instanceof ScheduledThreadPoolExecutor checks
- If post-shutdown periodic execution is a requirement, choose ScheduledThreadPoolExecutor instead
- Document in executor configuration utilities which policy calls are optional/unsupported
When it happens
Trigger: Calling setContinueExistingPeriodicTasksAfterShutdownPolicy(true or false) on a SingleThreadNonConcurrentFixedRateScheduler instance, typically in code that configures a ScheduledExecutorService generically and applies this policy tuning call to any scheduler.
Common situations: Framework or utility code that customizes ScheduledExecutorService instances (e.g. copied ThreadPoolExecutor tuning snippets) invokes the setter on this custom scheduler; migration of code that used ScheduledThreadPoolExecutor to this Pulsar scheduler.
Related errors
- Not support to set executeExistingDelayedTasksAfterShutdownP
- Not support to set removeOnCancelPolicy, it is always false
- Another partition exists for [${topicName}].
- AutoConsumeSchema is not supported with schemaId
- This schema is not meant to be used for encoding
AI-assisted analysis of apache/pulsar@820761864e (2026-09-06).
Data as JSON: /api/errors/00d6a5008b089eb4.
Report an issue: GitHub.