{"record":{"id":"5b6cc7947d7eb8ec","repo":"eclipse-vertx/vert.x","slug":"maxexecutetime-must-be-0-5b6cc7","errorCode":null,"errorMessage":"maxExecuteTime must be > 0","messagePattern":"maxExecuteTime must be > 0","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"vertx-core/src/main/java/io/vertx/core/impl/VertxImpl.java","lineNumber":1109,"sourceCode":"\n  @Override\n  public synchronized WorkerExecutorImpl createSharedWorkerExecutor(String name, int poolSize, long maxExecuteTime) {\n    return createSharedWorkerExecutor(name, poolSize, maxExecuteTime, maxWorkerExecTimeUnit);\n  }\n\n  @Override\n  public synchronized WorkerExecutorImpl createSharedWorkerExecutor(String name, int poolSize, long maxExecuteTime, TimeUnit maxExecuteTimeUnit) {\n    CloseableResource<WorkerPool> sharedWorkerPool = createSharedWorkerPool(name, poolSize, maxExecuteTime, maxExecuteTimeUnit);\n    sharedWorkerPool = registerResource(sharedWorkerPool);\n    return new WorkerExecutorImpl(this, CleanerProvider.INSTANCE.get(), sharedWorkerPool);\n  }\n\n  public CloseableResource<WorkerPool> createSharedWorkerPool(String name, int poolSize, long maxExecuteTime, TimeUnit maxExecuteTimeUnit) {\n    if (poolSize < 1) {\n      throw new IllegalArgumentException(\"poolSize must be > 0\");\n    }\n    if (maxExecuteTime < 1) {\n      throw new IllegalArgumentException(\"maxExecuteTime must be > 0\");\n    }\n    Supplier<WorkerPool> factory = () -> {\n      ThreadFactory workerThreadFactory = createThreadFactory(threadFactory, checker, useDaemonThread, maxExecuteTime, maxExecuteTimeUnit, name + \"-\", true);\n      ExecutorService workerExec = executorServiceFactory.createExecutor(workerThreadFactory, poolSize, poolSize);\n      PoolMetrics<?, ?> workerMetrics = metrics != null ? metrics.createPoolMetrics(\"worker\", name, poolSize) : null;\n      return new WorkerPool(workerExec, workerMetrics);\n    };\n    return createSharedResource(\"__vertx.shared.workerPools\", name, factory);\n  }\n\n  @Override\n  public WorkerPool wrapWorkerPool(ExecutorService executor) {\n    PoolMetrics workerMetrics = metrics != null ? metrics.createPoolMetrics( \"worker\", null, -1) : null;\n    return new WorkerPool(executor, workerMetrics);\n  }\n\n  private ThreadFactory createThreadFactory(VertxThreadFactory threadFactory, BlockedThreadChecker checker, Boolean useDaemonThread, long maxExecuteTime, TimeUnit maxExecuteTimeUnit, String prefix, boolean worker) {\n    AtomicInteger threadCount = new AtomicInteger(0);","sourceCodeStart":1091,"sourceCodeEnd":1127,"githubUrl":"https://github.com/eclipse-vertx/vert.x/blob/fb308bd8c3f12c79f4ae89bef67fadf6c80d036e/vertx-core/src/main/java/io/vertx/core/impl/VertxImpl.java#L1091-L1127","documentation":"createSharedWorkerPool validates the maximum worker execution time and throws IllegalArgumentException when maxExecuteTime < 1. This value drives the thread-blocked checker; a non-positive timeout would disable meaningful blocking detection and cannot be configured.","triggerScenarios":"vertx.createSharedWorkerPool(name, poolSize, maxExecuteTime, maxExecuteTimeUnit) with maxExecuteTime 0 or negative — e.g. config value in seconds converted to 0, or 0 intended as 'unlimited'.","commonSituations":"maxExecuteTimeUnit conversion producing 0 (e.g. sub-unit values truncated); 0 mistakenly used to mean 'no limit' (there is no such option here); negative values from bad config files.","solutions":["Pass maxExecuteTime >= 1 in the chosen TimeUnit, e.g. Math.max(1, configured)","To express a very long limit, use a large value with TimeUnit like 1 with TimeUnit.HOURS rather than 0","Validate config at startup and reject non-positive execute times"],"exampleFix":"// before\nvertx.createSharedWorkerPool(\"blocking\", 10, 0, TimeUnit.SECONDS); // throws\n// after\nvertx.createSharedWorkerPool(\"blocking\", 10, 1, TimeUnit.HOURS);","handlingStrategy":"validation","validationCode":"if (maxExecuteTime < 1) {\n  throw new IllegalArgumentException(\"maxExecuteTime must be >= 1, got \" + maxExecuteTime);\n}","typeGuard":null,"tryCatchPattern":"try {\n  vertx.createSharedWorkerPool(name, poolSize, maxExecuteTime, unit);\n} catch (IllegalArgumentException e) {\n  // use a sane default like 60s\n}","preventionTips":["Remember 0 does not mean 'unlimited' here; use a large value + TimeUnit instead","Check conversions that truncate small values to 0","Validate execute-time config at load"],"tags":["worker-pool","executor","argument-validation","configuration"],"backgroundTag":"invalid-config-value","analyzedSha":"fb308bd8c3f12c79f4ae89bef67fadf6c80d036e","analyzedAt":"2026-09-06T11:37:12.241Z","contentChangedAt":"2026-09-06T11:37:12.241Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}