{"record":{"id":"14eb5b05f92d2719","repo":"eclipse-vertx/vert.x","slug":"factory-isn-t-registered","errorCode":null,"errorMessage":"factory isn't registered","messagePattern":"factory isn't registered","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"vertx-core/src/main/java/io/vertx/core/impl/verticle/VerticleManager.java","lineNumber":95,"sourceCode":"  }\n\n  public void unregisterVerticleFactory(VerticleFactory factory) {\n    String prefix = factory.prefix();\n    if (prefix == null) {\n      throw new IllegalArgumentException(\"factory.prefix() cannot be null\");\n    }\n    List<VerticleFactory> facts = verticleFactories.get(prefix);\n    boolean removed = false;\n    if (facts != null) {\n      if (facts.remove(factory)) {\n        removed = true;\n      }\n      if (facts.isEmpty()) {\n        verticleFactories.remove(prefix);\n      }\n    }\n    if (!removed) {\n      throw new IllegalArgumentException(\"factory isn't registered\");\n    }\n  }\n\n  public Set<VerticleFactory> verticleFactories() {\n    Set<VerticleFactory> facts = new HashSet<>();\n    for (List<VerticleFactory> list: verticleFactories.values()) {\n      facts.addAll(list);\n    }\n    return facts;\n  }\n\n  private List<VerticleFactory> resolveFactories(String identifier) {\n    /*\n      We resolve the verticle factory list to use as follows:\n      1. We look for a prefix in the identifier.\n      E.g. the identifier might be \"js:app.js\" <-- the prefix is \"js\"\n      If it exists we use that to lookup the verticle factory list\n      2. We look for a suffix (like a file extension),","sourceCodeStart":77,"sourceCodeEnd":113,"githubUrl":"https://github.com/eclipse-vertx/vert.x/blob/fb308bd8c3f12c79f4ae89bef67fadf6c80d036e/vertx-core/src/main/java/io/vertx/core/impl/verticle/VerticleManager.java#L77-L113","documentation":"Thrown when unregisterVerticleFactory cannot find the given factory in its prefix's registered list. The manager only removes factories that were actually registered; unregistering an unknown factory is treated as a programming error.","triggerScenarios":"Calling unregisterVerticleFactory with a factory never registered on this Vertx, or already unregistered, or a different instance with the same prefix.","commonSituations":"Double-cleanup in shutdown code; factory registered on a different Vertx instance than the one being cleaned up; tests unregistering a shared mock multiple times.","solutions":["Only unregister factories you registered on the same Vertx instance","Track registration state (e.g. an AtomicBoolean) and skip redundant unregister calls","Ignore/absorb the IllegalArgumentException if best-effort cleanup is intended"],"exampleFix":"// before\nvertx.unregisterVerticleFactory(factory); // throws if not registered\n// after\nif (registered.compareAndSet(true, false)) {\n  vertx.unregisterVerticleFactory(factory);\n}","handlingStrategy":"validation","validationCode":"if (registeredFactories.remove(factory)) {\n  vertx.unregisterVerticleFactory(factory);\n}","typeGuard":null,"tryCatchPattern":"try {\n  vertx.unregisterVerticleFactory(factory);\n} catch (IllegalArgumentException e) {\n  if (\"factory isn't registered\".equals(e.getMessage())) return; // best-effort cleanup\n  throw e;\n}","preventionTips":["Track which factories you registered per Vertx instance","Use try/finally paired with a registration flag","Don't share factory instances across Vertx instances during cleanup"],"tags":["verticle-factory","unregistration","not-registered"],"backgroundTag":"resource-not-found","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"}