{"record":{"id":"f3c591d77ee7caaa","repo":"apache/dubbo","slug":"extension-name-is-blank-extension-type","errorCode":null,"errorMessage":"Extension name is blank (Extension ${type})!","messagePattern":"Extension name is blank \\(Extension (.+?)\\)!","errorType":"validation","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"dubbo-common/src/main/java/org/apache/dubbo/common/extension/ExtensionLoader.java","lineNumber":662,"sourceCode":"     *\n     * @param name  extension name\n     * @param clazz extension class\n     * @throws IllegalStateException when extension with the same name has already been registered.\n     */\n    public void addExtension(String name, Class<?> clazz) {\n        checkDestroyed();\n        getExtensionClasses(); // load classes\n\n        if (!type.isAssignableFrom(clazz)) {\n            throw new IllegalStateException(\"Input type \" + clazz + \" doesn't implement the Extension \" + type);\n        }\n        if (clazz.isInterface()) {\n            throw new IllegalStateException(\"Input type \" + clazz + \" can't be interface!\");\n        }\n\n        if (!clazz.isAnnotationPresent(Adaptive.class)) {\n            if (StringUtils.isBlank(name)) {\n                throw new IllegalStateException(\"Extension name is blank (Extension \" + type + \")!\");\n            }\n            if (cachedClasses.get().containsKey(name)) {\n                throw new IllegalStateException(\"Extension name \" + name + \" already exists (Extension \" + type + \")!\");\n            }\n\n            cachedNames.put(clazz, name);\n            cachedClasses.get().put(name, clazz);\n        } else {\n            if (cachedAdaptiveClass != null) {\n                throw new IllegalStateException(\"Adaptive Extension already exists (Extension \" + type + \")!\");\n            }\n\n            cachedAdaptiveClass = clazz;\n        }\n    }\n\n    /**\n     * Replace the existing extension via API","sourceCodeStart":644,"sourceCodeEnd":680,"githubUrl":"https://github.com/apache/dubbo/blob/3a3043227f5571d25eb2889de5bca22f2914843b/dubbo-common/src/main/java/org/apache/dubbo/common/extension/ExtensionLoader.java#L644-L680","documentation":"Thrown by ExtensionLoader.addExtension(String name, Class<?> clazz) when the class is not annotated @Adaptive and the name argument is null or blank. Non-adaptive extensions require a unique non-blank name so they can be looked up by name later. Only adaptive classes (annotated @Adaptive) can be registered with a null name.","triggerScenarios":"Calling addExtension(null, ConcreteImpl.class) or addExtension(\"  \", ConcreteImpl.class) where ConcreteImpl is not @Adaptive. The name is what consumers use to select this extension via getExtension(name), so it must be meaningful and non-empty.","commonSituations":"Developer forgets to specify a name when programmatically registering a test extension. A helper method that wraps addExtension passes a computed name that happens to be null or empty.","solutions":["Provide a non-blank, unique name as the first argument to addExtension.","If the name is computed dynamically, validate it is non-blank before calling addExtension.","If registering an adaptive class, ensure it is annotated with @Adaptive."],"exampleFix":"// before\nloader.addExtension(null, MyImpl.class);\n\n// after\nloader.addExtension(\"myImpl\", MyImpl.class);","handlingStrategy":"validation","validationCode":"if (!clazz.isAnnotationPresent(Adaptive.class) && StringUtils.isBlank(name)) {\n    throw new IllegalStateException(\n        \"Extension name required for non-adaptive class \" + clazz);\n}\nloader.addExtension(name, clazz);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always provide a non-blank, descriptive name for non-adaptive extension registrations.","Generate names from the class simple name if a natural name is not available.","Validate name is non-blank before calling addExtension."],"tags":["dubbo-spi","input-validation","registration","extension-system"],"backgroundTag":null,"analyzedSha":"3a3043227f5571d25eb2889de5bca22f2914843b","analyzedAt":"2026-08-14T00:43:19.853Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}