{"record":{"id":"057ff280b37fe63b","repo":"apache/dubbo","slug":"extension-name-is-blank-extension","errorCode":null,"errorMessage":"Extension name is blank (Extension {})!","messagePattern":"Extension name is blank \\(Extension (.+?)\\)!","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"dubbo-common/src/main/java/org/apache/dubbo/common/extension/ExtensionLoader.java","lineNumber":701,"sourceCode":"     * @param clazz extension class\n     * @throws IllegalStateException when extension to be placed doesn't exist\n     * @deprecated not recommended any longer, and use only when test\n     */\n    @Deprecated\n    public void replaceExtension(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 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 + \" doesn't exist (Extension \" + type + \")!\");\n            }\n\n            cachedNames.put(clazz, name);\n            cachedClasses.get().put(name, clazz);\n            cachedInstances.remove(name);\n        } else {\n            if (cachedAdaptiveClass == null) {\n                throw new IllegalStateException(\"Adaptive Extension doesn't exist (Extension \" + type + \")!\");\n            }\n\n            cachedAdaptiveClass = clazz;\n            cachedAdaptiveInstance.set(null);\n        }\n    }\n","sourceCodeStart":683,"sourceCodeEnd":719,"githubUrl":"https://github.com/apache/dubbo/blob/3a3043227f5571d25eb2889de5bca22f2914843b/dubbo-common/src/main/java/org/apache/dubbo/common/extension/ExtensionLoader.java#L683-L719","documentation":"Thrown by ExtensionLoader.replaceExtension(String name, Class<?> clazz) when the class is not @Adaptive and the name is null or blank. Non-adaptive extension replacements require a non-blank name to identify which existing extension to replace. Only adaptive class replacements can omit the name.","triggerScenarios":"Calling replaceExtension(null, ConcreteImpl.class) or replaceExtension(\"\", ConcreteImpl.class) where ConcreteImpl is not annotated @Adaptive. The name identifies the existing extension entry to overwrite, so a blank name makes the replacement target ambiguous.","commonSituations":"Developer wraps replaceExtension in a helper that passes a null name when one is not available. A computed name from config resolves to null/empty. Test code uses a placeholder null and forgets to set the actual name.","solutions":["Provide the exact existing extension name as the first argument.","If the name comes from config, validate it is non-blank before calling replaceExtension.","If replacing an adaptive class, annotate the replacement with @Adaptive."],"exampleFix":"// before\nloader.replaceExtension(null, MyImpl.class);\n\n// after\nloader.replaceExtension(\"dubbo\", MyImpl.class);","handlingStrategy":"validation","validationCode":"if (!clazz.isAnnotationPresent(Adaptive.class) && StringUtils.isBlank(name)) {\n    throw new IllegalStateException(\n        \"Extension name required for non-adaptive replacement of type \" + type);\n}\nloader.replaceExtension(name, clazz);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always provide the exact existing extension name when replacing a non-adaptive extension.","Validate name is non-blank before calling replaceExtension."],"tags":["dubbo-spi","input-validation","registration","deprecated","extension-system"],"backgroundTag":null,"analyzedSha":"3a3043227f5571d25eb2889de5bca22f2914843b","analyzedAt":"2026-08-14T00:43:19.853Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}