apache/dubbo · error · IllegalArgumentException

invocation == null

Error message

invocation == null

What it means

This is a generated-code template (CODE_INVOCATION_ARGUMENT_NULL_CHECK) emitted into the adaptive class for @Adaptive methods that take an org.apache.dubbo.rpc.Invocation parameter. At runtime, the generated $Adaptive class throws IllegalArgumentException("invocation == null") when the Invocation argument is null. The Invocation is needed to resolve method-scoped parameters via getMethodParameter.

Source

Thrown at dubbo-common/src/main/java/org/apache/dubbo/common/extension/AdaptiveClassCodeGenerator.java:69

    private static final String CODE_METHOD_DECLARATION = "public %s %s(%s) %s {\n%s}\n";

    private static final String CODE_METHOD_ARGUMENT = "%s arg%d";

    private static final String CODE_METHOD_THROWS = "throws %s";

    private static final String CODE_UNSUPPORTED =
            "throw new UnsupportedOperationException(\"The method %s of interface %s is not adaptive method!\");\n";

    private static final String CODE_URL_NULL_CHECK =
            "if (arg%d == null) throw new IllegalArgumentException(\"url == null\");\n%s url = arg%d;\n";

    private static final String CODE_EXT_NAME_ASSIGNMENT = "String extName = %s;\n";

    private static final String CODE_EXT_NAME_NULL_CHECK = "if(extName == null) "
            + "throw new IllegalStateException(\"Failed to get extension (%s) name from url (\" + url.toString() + \") use keys(%s)\");\n";

    private static final String CODE_INVOCATION_ARGUMENT_NULL_CHECK =
            "if (arg%d == null) throw new IllegalArgumentException(\"invocation == null\"); "
                    + "String methodName = arg%d.getMethodName();\n";

    private static final String CODE_SCOPE_MODEL_ASSIGNMENT =
            "ScopeModel scopeModel = ScopeModelUtil.getOrDefault(url.getScopeModel(), %s.class);\n";
    private static final String CODE_EXTENSION_ASSIGNMENT =
            "%s extension = (%<s)scopeModel.getExtensionLoader(%s.class).getExtension(extName);\n";

    private static final String CODE_EXTENSION_METHOD_INVOKE_ARGUMENT = "arg%d";

    private final Class<?> type;

    private final String defaultExtName;

    public AdaptiveClassCodeGenerator(Class<?> type, String defaultExtName) {
        this.type = type;
        this.defaultExtName = defaultExtName;
    }

View on GitHub (pinned to 3a3043227f)

Solutions

  1. Construct and pass a non-null Invocation (e.g. MockInvocation, or a real RpcInvocation) to the adaptive method.
  2. Ensure the upstream caller (the Invoker chain or proxy) always builds the Invocation before delegating.
  3. In tests, use Dubbo's test utilities or mock frameworks to create a valid Invocation.

Example fix

// before
adaptiveFilter.invoke(invoker, null); // throws

// after
Invocation inv = new RpcInvocation("methodName", argTypes, args);
adaptiveFilter.invoke(invoker, inv);
Defensive patterns

Strategy: validation

Validate before calling

if (invocation == null) {
    throw new IllegalArgumentException("Invocation must not be null");
}

Type guard

static boolean hasValidInvocation(Invocation inv) {
    return inv != null && inv.getMethodName() != null;
}

Try / catch

try {
    adaptiveFilter.invoke(invoker, invocation);
} catch (IllegalArgumentException e) {
    if ("invocation == null".equals(e.getMessage())) {
        invocation = new RpcInvocation(method, types, args);
        adaptiveFilter.invoke(invoker, invocation);
    } else throw e;
}

Prevention

When it happens

Trigger: At runtime, calling a @Adaptive method that declares an Invocation-typed parameter (e.g. Invoker.invoke, Filter/Cluster SPI methods) and passing null for that argument. The generated check fires before methodName is extracted from the invocation.

Common situations: Calling an adaptive extension's invoke-related method with a null Invocation during unit tests or in custom framework integration code. Happens when a mock invoker chain fails to construct the Invocation object.

Related errors


AI-assisted analysis of apache/dubbo@3a3043227f (2026-08-14). Data as JSON: /api/errors/1123a177ec01929c. Report an issue: GitHub.