apache/dubbo · error · IllegalArgumentException
Extension type == null
Error message
Extension type == null
What it means
Thrown by getExtensionClass(String name) when the ExtensionLoader's internal 'type' field (the SPI interface) is null. The type field is set in the ExtensionLoader constructor from the interface passed to ExtensionLoader.getExtensionLoader(Class). This error indicates the loader was created or corrupted in a way that left the SPI interface unset - an internal invariant violation rather than a user configuration problem.
Source
Thrown at dubbo-common/src/main/java/org/apache/dubbo/common/extension/ExtensionLoader.java:947
/**
* return true if and only if:
* <p>
* 1, public
* <p>
* 2, name starts with "set"
* <p>
* 3, only has one parameter
*/
private boolean isSetter(Method method) {
return method.getName().startsWith("set")
&& method.getParameterTypes().length == 1
&& Modifier.isPublic(method.getModifiers());
}
private Class<?> getExtensionClass(String name) {
if (type == null) {
throw new IllegalArgumentException("Extension type == null");
}
if (name == null) {
throw new IllegalArgumentException("Extension name == null");
}
return getExtensionClasses().get(name);
}
private Map<String, Class<?>> getExtensionClasses() {
Map<String, Class<?>> classes = cachedClasses.get();
if (classes == null) {
loadExtensionClassesLock.lock();
try {
classes = cachedClasses.get();
if (classes == null) {
try {
classes = loadExtensionClasses();
} catch (InterruptedException e) {
logger.error(View on GitHub (pinned to 3a3043227f)
Solutions
- Always obtain an ExtensionLoader via ExtensionLoader.getExtensionLoader(MySpiInterface.class) - never construct one directly.
- If using the ExtensionDirector API, obtain loaders through extensionDirector.getExtensionLoader(Class) which manages type correctly.
- In tests, ensure you pass a concrete interface Class object, not null.
Example fix
// before
ExtensionLoader loader = someDirector.getExtensionLoader(null);
loader.getExtension("foo"); // throws [142]
// after
ExtensionLoader<MySpi> loader = extensionDirector.getExtensionLoader(MySpi.class);
loader.getExtension("foo"); Defensive patterns
Strategy: validation
Validate before calling
// Always obtain loaders through the factory, which validates non-null type
public static <T> ExtensionLoader<T> safeLoader(ExtensionDirector d, Class<T> type) {
java.util.Objects.requireNonNull(type, "SPI interface type must not be null");
return d.getExtensionLoader(type);
} Prevention
- Never construct ExtensionLoader directly - always use ExtensionLoader.getExtensionLoader(Class) or ExtensionDirector.getExtensionLoader(Class).
- Pass concrete interface Class objects, never null.
- In tests, assert the loader is non-null and typed before use.
When it happens
Trigger: getExtensionClass(name) is called on an ExtensionLoader instance whose type field is null. This is only reachable if an ExtensionLoader was constructed with a null interface argument or if the type field was reflectively cleared - ExtensionLoader.getExtensionLoader(Class) itself validates non-null at entry, so normal API use should not reach this.
Common situations: Test code that constructs ExtensionLoader directly via reflection instead of through getExtensionLoader(); a framework bug or a custom fork that bypasses the factory method; corruption from a classloader-reloading scenario that nulls internal fields.
Related errors
- Extension instance (name: {}, class: {}) couldn't be instant
- Exception occurred when loading extension class (interface:
- More than 1 default extension name on extension {}: {}
- Error occurred when loading extension class (interface: {},
- No such extension name for the class {} in the config {}
AI-assisted analysis of apache/dubbo@3a3043227f (2026-08-14).
Data as JSON: /api/errors/2093c0ce30b38ff9.
Report an issue: GitHub.