{"record":{"id":"eba1426529253e1d","repo":"testcontainers/testcontainers-java","slug":"extension-name-must-not-be-null-or-empty","errorCode":null,"errorMessage":"extension name must not be null or empty","messagePattern":"extension name must not be null or empty","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/hivemq/src/main/java/org/testcontainers/hivemq/HiveMQExtension.java","lineNumber":205,"sourceCode":"\n        private boolean disabledOnStartup = false;\n\n        @Nullable\n        private Class<?> mainClass;\n\n        @NotNull\n        private final LinkedList<Class<?>> additionalClasses = new LinkedList<>();\n\n        /**\n         * Builds the {@link HiveMQExtension} with the provided values or default values.\n         * @return the HiveMQ Extension\n         */\n        public @NotNull HiveMQExtension build() {\n            if (id == null || id.isEmpty()) {\n                throw new IllegalArgumentException(\"extension id must not be null or empty\");\n            }\n            if (name == null || name.isEmpty()) {\n                throw new IllegalArgumentException(\"extension name must not be null or empty\");\n            }\n            if (version == null || version.isEmpty()) {\n                throw new IllegalArgumentException(\"extension version must not be null or empty\");\n            }\n            if (mainClass == null) {\n                throw new IllegalArgumentException(\"extension main class must not be null\");\n            }\n            return new HiveMQExtension(\n                id,\n                name,\n                version,\n                priority,\n                startPriority,\n                disabledOnStartup,\n                mainClass,\n                additionalClasses\n            );\n        }","sourceCodeStart":187,"sourceCodeEnd":223,"githubUrl":"https://github.com/testcontainers/testcontainers-java/blob/8e549514e3f01c57d70546fbb8599d138f3903e5/modules/hivemq/src/main/java/org/testcontainers/hivemq/HiveMQExtension.java#L187-L223","documentation":"HiveMQExtension.Builder.build() validates that the extension's name was set before constructing the HiveMQExtension. The builder accumulates id, name, version, mainClass, etc., and refuses to build an extension with a null or empty name, since HiveMQ requires extensions to be named.","triggerScenarios":"Calling HiveMQExtension.Builder.build() without calling name(...) first, or calling name(null)/name(\"\").","commonSituations":"Programmatically constructing extensions where fields come from config files or maps and the 'name' key is missing or empty; copying a builder setup and dropping the name() call.","solutions":["Call .name(\"your-extension-name\") on the builder before build()","Validate the source config/map contains a non-empty name before building","Add a unit test constructing the extension with all required fields"],"exampleFix":"// before\nnew HiveMQExtension.Builder().id(\"ext\").version(\"1.0\").mainClass(MyExt.class).build();\n// after\nnew HiveMQExtension.Builder().id(\"ext\").name(\"my-extension\").version(\"1.0\").mainClass(MyExt.class).build();","handlingStrategy":"validation","validationCode":"if (name == null || name.isEmpty()) throw new IllegalStateException(\"Set builder.name() before build()\");","typeGuard":"boolean hasName = builder != null && name != null && !name.isEmpty();","tryCatchPattern":null,"preventionTips":["Always set id, name, version, mainClass together in one helper method","Validate config maps for required extension fields before building"],"tags":["hivemq","builder-validation","null-argument"],"backgroundTag":"missing-required-argument","analyzedSha":"8e549514e3f01c57d70546fbb8599d138f3903e5","analyzedAt":"2026-09-12T14:56:41.227Z","contentChangedAt":"2026-09-12T14:56:41.227Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}