apache/dubbo · error · RpcException

Can not merge result because missing method [ {merger} ] in

Error message

Can not merge result because missing method [ {merger} ] in class [ {returnType.getName()} ]

What it means

Thrown by MergeableClusterInvoker when the configured merger starts with '.', telling Dubbo to merge results by reflecting a method on the return type, but that method (named by the merger substring) taking a single returnType argument does not exist or the returnType is null. NoSuchMethodException (method missing) or NullPointerException (returnType null) both surface as this RpcException.

Source

Thrown at dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/support/MergeableClusterInvoker.java:154

        }

        if (resultList.isEmpty()) {
            return AsyncRpcResult.newDefaultAsyncResult(invocation);
        } else if (resultList.size() == 1) {
            return AsyncRpcResult.newDefaultAsyncResult(resultList.get(0).getValue(), invocation);
        }

        if (returnType == void.class) {
            return AsyncRpcResult.newDefaultAsyncResult(invocation);
        }

        if (merger.startsWith(".")) {
            merger = merger.substring(1);
            Method method;
            try {
                method = returnType.getMethod(merger, returnType);
            } catch (NoSuchMethodException | NullPointerException e) {
                throw new RpcException("Can not merge result because missing method [ " + merger + " ] in class [ "
                        + returnType.getName() + " ]");
            }
            if (!Modifier.isPublic(method.getModifiers())) {
                method.setAccessible(true);
            }
            result = resultList.remove(0).getValue();
            try {
                if (method.getReturnType() != void.class
                        && method.getReturnType().isAssignableFrom(result.getClass())) {
                    for (Result r : resultList) {
                        result = method.invoke(result, r.getValue());
                    }
                } else {
                    for (Result r : resultList) {
                        method.invoke(result, r.getValue());
                    }
                }
            } catch (Exception e) {

View on GitHub (pinned to 3a3043227f)

Solutions

  1. Add a public method named exactly <merger>(ReturnType) on the return type that combines two instances and returns the merged result.
  2. Correct the method name in the merger config to match an existing combining method (watch for typos and case).
  3. If the method legitimately returns void or you want SPI-based merging, remove the leading dot and use a named Merger extension or merger="true" instead.
  4. Verify the invoked method's declared return type matches the type the merge method operates on.

Example fix

// before: return type lacks a combining method
public class Stats { /* no merge(Stats) */ }
<dubbo:method name="getStats" merger=".merge"/>

// after: add the public combining method
public class Stats {
    public Stats merge(Stats other) { /* combine fields */ return this; }
}
Defensive patterns

Strategy: validation

Validate before calling

// Validate the merge method exists BEFORE configuring the service
Method m;
try {
    m = ReturnType.class.getMethod(mergerName.substring(1), ReturnType.class);
} catch (NoSuchMethodException e) {
    throw new IllegalStateException("return type lacks merge method " + mergerName, e);
}

Prevention

When it happens

Trigger: Method-level or interface-level config merger=".someMethod" where the service method's return type has no public someMethod(ReturnType) signature; or the invoked method returns void/void-compatible so returnType resolves to null (NPE on returnType.getMethod); or a typo in the method name after the dot.

Common situations: Configuring merger=".addAll" on a service whose return type is a custom DTO without such a combining method; returning void from a method that has a merger; renaming a merge method in code but not updating the dubbo config; copy-pasting a merger config from another service with a different return type.

Related errors


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