{"record":{"id":"c274470dda26f9bc","repo":"eclipse-vertx/vert.x","slug":"factory-prefix-cannot-be-null","errorCode":null,"errorMessage":"factory.prefix() cannot be null","messagePattern":"factory\\.prefix\\(\\) cannot be null","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"vertx-core/src/main/java/io/vertx/core/impl/verticle/VerticleManager.java","lineNumber":63,"sourceCode":"  public VerticleManager(VertxInternal vertx, Logger log, DeploymentManager deploymentManager) {\n    this.vertx = (VertxImpl) vertx;\n    this.deploymentManager = deploymentManager;\n    this.log = log;\n  }\n\n  public void init(List<VerticleFactory> factories) {\n    if (factories != null) {\n      factories.forEach(this::registerVerticleFactory);\n    }\n    VerticleFactory defaultFactory = new JavaVerticleFactory();\n    defaultFactory.init(vertx);\n    defaultFactories.add(defaultFactory);\n  }\n\n  public void registerVerticleFactory(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    if (facts == null) {\n      facts = new ArrayList<>();\n      verticleFactories.put(prefix, facts);\n    }\n    if (facts.contains(factory)) {\n      throw new IllegalArgumentException(\"Factory already registered\");\n    }\n    facts.add(factory);\n    // Sort list in ascending order\n    facts.sort((fact1, fact2) -> fact1.order() - fact2.order());\n    factory.init(vertx);\n  }\n\n  public void unregisterVerticleFactory(VerticleFactory factory) {\n    String prefix = factory.prefix();\n    if (prefix == null) {","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/eclipse-vertx/vert.x/blob/fb308bd8c3f12c79f4ae89bef67fadf6c80d036e/vertx-core/src/main/java/io/vertx/core/impl/verticle/VerticleManager.java#L45-L81","documentation":"VerticleManager.registerVerticleFactory requires every VerticleFactory to expose a non-null prefix that namespaces deploy identifiers (e.g. 'service:'). A factory returning a null prefix cannot be keyed in the registry, so registration fails fast with IllegalArgumentException.","triggerScenarios":"Implementing a custom VerticleFactory whose prefix() method returns null, then registering it via Vertx.registerVerticleFactory(factory).","commonSituations":"Custom factory implementations that compute the prefix dynamically and return null on a misconfigured instance; overriding prefix() in a subclass and forgetting the return value path.","solutions":["Fix the custom factory's prefix() to return a non-null, non-empty string like \"my-prefix\"","Validate the prefix in the factory's constructor or init() so bad configuration surfaces early"],"exampleFix":"// before\npublic String prefix() { return config == null ? null : config.prefix; }\n// after\npublic String prefix() { return \"my-prefix\"; }","handlingStrategy":"validation","validationCode":"if (factory.prefix() == null || factory.prefix().isEmpty()) {\n  throw new IllegalStateException(\"Verticle factory prefix must be non-null\");\n}\nvertx.registerVerticleFactory(factory);","typeGuard":null,"tryCatchPattern":"try {\n  vertx.registerVerticleFactory(factory);\n} catch (IllegalArgumentException e) {\n  log.error(\"Bad verticle factory: \" + e.getMessage());\n}","preventionTips":["Return a constant string from prefix()","Never derive prefix from nullable configuration","Add a unit test asserting prefix() is non-null"],"tags":["verticle-factory","null-check","registration"],"backgroundTag":"null-argument","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"}