{"record":{"id":"0148443f17e99ab5","repo":"eclipse-vertx/vert.x","slug":"poolsize-must-be-0","errorCode":null,"errorMessage":"poolSize must be > 0","messagePattern":"poolSize must be > 0","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"vertx-core/src/main/java/io/vertx/core/impl/VertxImpl.java","lineNumber":1106,"sourceCode":"  public WorkerExecutorImpl createSharedWorkerExecutor(String name, int poolSize) {\n    return createSharedWorkerExecutor(name, poolSize, maxWorkerExecTime);\n  }\n\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  }","sourceCodeStart":1088,"sourceCodeEnd":1124,"githubUrl":"https://github.com/eclipse-vertx/vert.x/blob/fb308bd8c3f12c79f4ae89bef67fadf6c80d036e/vertx-core/src/main/java/io/vertx/core/impl/VertxImpl.java#L1088-L1124","documentation":"createSharedWorkerPool builds a named shared executor; its size must be at least 1 thread. A poolSize < 1 cannot form a valid ExecutorService, so Vert.x throws IllegalArgumentException immediately. This validates the pool's thread count, separate from maxExecuteTime validation.","triggerScenarios":"vertx.createSharedWorkerPool(name, poolSize) or createSharedWorkerPool(name, poolSize, maxExecuteTime, unit) with poolSize 0 or negative, often from config like Runtime.getRuntime().availableProcessors() on exotic platforms or a computed value.","commonSituations":"availableProcessors() returning 0 in some container misconfigurations; poolSize = maxConcurrent - 1 arithmetic; unset config defaulting to 0; sharing one pool-sizing helper with different minima.","solutions":["Pass poolSize >= 1, e.g. Math.max(1, configuredSize)","Default unset config to a sane value (e.g. 20 or 2*availableProcessors) instead of 0","Fail fast at config load with validation rather than at pool creation"],"exampleFix":"// before\nvertx.createSharedWorkerPool(\"db\", cfg.getInt(\"poolSize\", 0)); // throws\n// after\nint size = Math.max(1, cfg.getInt(\"poolSize\", 20));\nvertx.createSharedWorkerPool(\"db\", size);","handlingStrategy":"validation","validationCode":"if (poolSize < 1) {\n  throw new IllegalArgumentException(\"poolSize must be >= 1, got \" + poolSize);\n}","typeGuard":null,"tryCatchPattern":"try {\n  vertx.createSharedWorkerPool(name, poolSize);\n} catch (IllegalArgumentException e) {\n  // fall back to default pool size\n}","preventionTips":["Default pool size to a positive value (e.g. 20)","Never assume availableProcessors() > 0 in exotic environments","Validate worker-pool config at application startup"],"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-14T00:17:10.932Z"}