{"record":{"id":"2c4abaeed84ff1e0","repo":"apache/dubbo","slug":"extension-name-null","errorCode":null,"errorMessage":"Extension name == null","messagePattern":"Extension name == null","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"dubbo-common/src/main/java/org/apache/dubbo/common/extension/ExtensionLoader.java","lineNumber":510,"sourceCode":"                return true;\n            }\n        }\n        return false;\n    }\n\n    /**\n     * Get extension's instance. Return <code>null</code> if extension is not found or is not initialized. Pls. note\n     * that this method will not trigger extension load.\n     * <p>\n     * In order to trigger extension load, call {@link #getExtension(String)} instead.\n     *\n     * @see #getExtension(String)\n     */\n    @SuppressWarnings(\"unchecked\")\n    public T getLoadedExtension(String name) {\n        checkDestroyed();\n        if (StringUtils.isEmpty(name)) {\n            throw new IllegalArgumentException(\"Extension name == null\");\n        }\n        Holder<Object> holder = getOrCreateHolder(name);\n        return (T) holder.get();\n    }\n\n    private Holder<Object> getOrCreateHolder(String name) {\n        Holder<Object> holder = cachedInstances.get(name);\n        if (holder == null) {\n            cachedInstances.putIfAbsent(name, new Holder<>());\n            holder = cachedInstances.get(name);\n        }\n        return holder;\n    }\n\n    /**\n     * Return the list of extensions which are already loaded.\n     * <p>\n     * Usually {@link #getSupportedExtensions()} should be called in order to get all extensions.","sourceCodeStart":492,"sourceCodeEnd":528,"githubUrl":"https://github.com/apache/dubbo/blob/3a3043227f5571d25eb2889de5bca22f2914843b/dubbo-common/src/main/java/org/apache/dubbo/common/extension/ExtensionLoader.java#L492-L528","documentation":"Thrown by ExtensionLoader.getLoadedExtension(String name) when name is null, empty, or whitespace-only. This method returns an already-loaded extension instance without triggering a load; a blank name makes the cache lookup meaningless. The check uses StringUtils.isEmpty which catches both null and empty string.","triggerScenarios":"Calling getLoadedExtension(null), getLoadedExtension(\"\"), or getLoadedExtension(\"   \") when the name comes from an unvalidated external source, a URL parameter that was absent, or a configuration value that defaulted to null.","commonSituations":"A URL parameter key like 'serializer' is absent and code calls loader.getLoadedExtension(url.getParameter(\"serializer\")) which returns null. A configuration property is not set, resolving to null, and is passed directly. Dynamic dispatch logic computes a null name from a map lookup that missed.","solutions":["Validate the name argument is non-null and non-empty before calling getLoadedExtension.","If the name originates from a URL parameter, provide a fallback default: url.getParameter(\"key\", \"defaultValue\").","If the name is optional, check hasExtension or use getOrDefaultExtension instead of getLoadedExtension."],"exampleFix":"// before\nString name = url.getParameter(\"loadbalance\");\nT ext = loader.getLoadedExtension(name); // name is null\n\n// after\nString name = url.getParameter(\"loadbalance\");\nif (StringUtils.isNotEmpty(name)) {\n    T ext = loader.getLoadedExtension(name);\n}","handlingStrategy":"validation","validationCode":"if (StringUtils.isEmpty(name)) {\n    return null; // or throw a more descriptive exception\n}\nT ext = loader.getLoadedExtension(name);","typeGuard":"static boolean isValidExtensionName(String name) {\n    return name != null && !name.trim().isEmpty();\n}","tryCatchPattern":"try {\n    T ext = loader.getLoadedExtension(name);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().equals(\"Extension name == null\")) {\n        log.warn(\"Extension name was null/empty — treating as not loaded\");\n        return null;\n    }\n    throw e;\n}","preventionTips":["Validate extension names from URL parameters or config before passing to getLoadedExtension.","Use url.getParameter(\"key\", \"defaultName\") to provide a fallback when the parameter is absent.","Encapsulate name resolution in a helper method that handles null/empty centrally."],"tags":["dubbo-spi","null-check","input-validation","configuration"],"backgroundTag":null,"analyzedSha":"3a3043227f5571d25eb2889de5bca22f2914843b","analyzedAt":"2026-08-14T00:43:19.853Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}