{"record":{"id":"8239774c18d87c3e","repo":"eclipse-vertx/vert.x","slug":"can-t-specify-1-instances-to-deploy","errorCode":null,"errorMessage":"Can't specify < 1 instances to deploy","messagePattern":"Can't specify < 1 instances to deploy","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"vertx-core/src/main/java/io/vertx/core/impl/VertxImpl.java","lineNumber":829,"sourceCode":"\n  @Override\n  public Future<String> deployVerticle(Supplier<? extends Deployable> supplier, DeploymentOptions options) {\n    Callable<? extends Deployable> adapter = supplier::get;\n    return deployVerticle(adapter, options).map(DeploymentContext::id);\n  }\n\n  private Future<DeploymentContext> deployVerticle(Callable<? extends Deployable> supplier, DeploymentOptions options) {\n    boolean closed;\n    synchronized (this) {\n      closed = this.closed;\n    }\n    if (closed) {\n      // If we are closed use a context less future\n      return Future.failedFuture(\"Vert.x closed\");\n    } else {\n      ContextInternal currentContext = getOrCreateContext();\n      if (options.getInstances() < 1) {\n        throw new IllegalArgumentException(\"Can't specify < 1 instances to deploy\");\n      }\n      ClassLoader cl = options.getClassLoader();\n      if (cl == null) {\n        cl = Thread.currentThread().getContextClassLoader();\n        if (cl == null) {\n          cl = getClass().getClassLoader();\n        }\n      }\n      Deployment deployment;\n      try {\n        deployment = DefaultDeployment.deployment(this, log, options, v -> \"java:\" + v.getClass().getName(), cl, supplier);\n      } catch (Exception e) {\n        return currentContext.failedFuture(e);\n      }\n\n      // NEED TO SOLVE THIS\n\n      return deploymentManager.deploy(currentContext.deploymentID(), currentContext, deployment);","sourceCodeStart":811,"sourceCodeEnd":847,"githubUrl":"https://github.com/eclipse-vertx/vert.x/blob/fb308bd8c3f12c79f4ae89bef67fadf6c80d036e/vertx-core/src/main/java/io/vertx/core/impl/VertxImpl.java#L811-L847","documentation":"When deploying verticles you can request multiple instances via DeploymentOptions.setInstances(n); Vert.x requires at least 1. Passing 0 or a negative count throws IllegalArgumentException synchronously from deployVerticle before any deployment begins.","triggerScenarios":"vertx.deployVerticle(...) with DeploymentOptions whose getInstances() < 1 — e.g. setInstances(0), or instances loaded from config/environment as an unset default 0.","commonSituations":"Instances count read from a properties/env config where 0 was meant as 'use default'; arithmetic like parallelism - 1 yielding 0 on single-core machines; copy-paste of setInstances(0) in test scaffolding.","solutions":["Call options.setInstances(Math.max(1, desiredInstances))","Ensure config-derived instance counts default to 1 (or another positive value) when unset","Reject invalid configuration at startup with a clear message before deploying"],"exampleFix":"// before\nopts.setInstances(cfg.getInteger(\"instances\", 0)); // 0 -> IllegalArgumentException\n// after\nopts.setInstances(Math.max(1, cfg.getInteger(\"instances\", 1)));","handlingStrategy":"validation","validationCode":"DeploymentOptions opts = new DeploymentOptions();\nif (opts.getInstances() < 1) {\n  opts.setInstances(1);\n}","typeGuard":null,"tryCatchPattern":"try {\n  vertx.deployVerticle(supplier, opts);\n} catch (IllegalArgumentException e) {\n  // log config error: instances must be >= 1\n}","preventionTips":["Default instances to 1 when config is absent","Reject non-positive instance counts at startup","Avoid arithmetic that can produce 0 instances"],"tags":["deployment","configuration","argument-validation"],"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"}