apache/dubbo · error · IllegalArgumentException
%s argument %s() == null
Error message
%s argument %s() == null
What it means
This is a generated-code template emitted by generateGetUrlNullCheck() into the adaptive class. At runtime, the generated class throws IllegalArgumentException when the carrier argument is non-null but its URL getter (e.g. getUrl()) returns null. The message names both the argument's class and the getter method name.
Source
Thrown at dubbo-common/src/main/java/org/apache/dubbo/common/extension/AdaptiveClassCodeGenerator.java:427
Map.Entry<String, Integer> entry =
getterReturnUrl.entrySet().iterator().next();
return generateGetUrlNullCheck(entry.getValue(), pts[entry.getValue()], entry.getKey());
}
}
/**
* 1, test if argi is null
* 2, test if argi.getXX() returns null
* 3, assign url with argi.getXX()
*/
private String generateGetUrlNullCheck(int index, Class<?> type, String method) {
// Null point check
StringBuilder code = new StringBuilder();
code.append(String.format(
"if (arg%d == null) throw new IllegalArgumentException(\"%s argument == null\");\n",
index, type.getName()));
code.append(String.format(
"if (arg%d.%s() == null) throw new IllegalArgumentException(\"%s argument %s() == null\");\n",
index, method, type.getName(), method));
code.append(String.format("%s url = arg%d.%s();\n", URL.class.getName(), index, method));
return code.toString();
}
}
View on GitHub (pinned to 3a3043227f)
Solutions
- Ensure the carrier object's URL field is initialized before it reaches the adaptive method (e.g. pass a non-null URL to the carrier's constructor).
- Trace the carrier object's construction to confirm the URL is set.
- If the URL may legitimately be absent, restructure the call to pass a URL directly.
Example fix
// before
Context ctx = new Context(); // getUrl() returns null
adaptiveSpi.doWork(ctx);
// after
URL url = URL.valueOf("dubbo://127.0.0.1:20880/Service");
Context ctx = new Context(url); // getUrl() now non-null
adaptiveSpi.doWork(ctx); Defensive patterns
Strategy: validation
Validate before calling
URL url = carrier.getUrl();
if (url == null) {
throw new IllegalArgumentException("Carrier's URL getter returned null");
} Type guard
static boolean carrierHasUrl(Object carrier) throws Exception {
if (carrier == null) return false;
for (Method m : carrier.getClass().getMethods()) {
if (m.getReturnType() == URL.class && m.getParameterCount() == 0) {
return m.invoke(carrier) != null;
}
}
return false;
} Try / catch
try {
adaptiveMethod(carrier);
} catch (IllegalArgumentException e) {
if (e.getMessage().contains("() == null")) {
// re-initialize carrier with URL and retry
} else throw e;
} Prevention
- Initialize the URL field on carrier objects before they reach adaptive methods.
- Ensure constructors or factories for carrier objects always set URL.
- Check for null URLs after deserialization of carrier objects.
When it happens
Trigger: At runtime, calling a @Adaptive method where the URL is obtained via argX.getUrl(), the argument argX is non-null, but argX.getUrl() returns null. The generated second null-check fires: 'if (argN.getXxx() == null) throw new IllegalArgumentException("<type> argument <getter>() == null")'.
Common situations: The carrier object exists but its URL field was never initialized — e.g. an InvocationContext or Invoker whose URL was not set during construction. Happens when objects are created by factories that don't always populate URL, or after deserialization that lost the URL.
Related errors
- url == null
- %s argument == null
- Failed to get extension (%s) name from url (${url}) use keys
- invocation == null
- Failed to create adaptive class for interface ${type.getName
AI-assisted analysis of apache/dubbo@3a3043227f (2026-08-14).
Data as JSON: /api/errors/293b8daeb97d1569.
Report an issue: GitHub.