apache/dubbo · error · UnsupportedOperationException

Method [{}] unimplemented.

Error message

Method [{}] unimplemented.

What it means

Thrown by the default InvocationHandler THROW_UNSUPPORTED_INVOKER. Proxy.newInstance() (no-arg) wires this handler into the generated proxy, so any method call on the resulting instance throws UnsupportedOperationException naming the method. It is a placeholder handler meant only for proxies that should never be invoked directly.

Source

Thrown at dubbo-common/src/main/java/org/apache/dubbo/common/bytecode/Proxy.java:44

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.WeakHashMap;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicLong;

import static org.apache.dubbo.common.constants.CommonConstants.MAX_PROXY_COUNT;

/**
 * Proxy.
 */
public class Proxy {
    public static final InvocationHandler THROW_UNSUPPORTED_INVOKER = new InvocationHandler() {
        @Override
        public Object invoke(Object proxy, Method method, Object[] args) {
            throw new UnsupportedOperationException("Method [" + ReflectUtils.getName(method) + "] unimplemented.");
        }
    };

    private static final AtomicLong PROXY_CLASS_COUNTER = new AtomicLong(0);
    private static final Map<ClassLoader, Map<String, Proxy>> PROXY_CACHE_MAP = new WeakHashMap<>();

    private final Class<?> classToCreate;

    protected Proxy(Class<?> classToCreate) {
        this.classToCreate = classToCreate;
    }

    /**
     * Get proxy.
     *
     * @param ics interface class array.
     * @return Proxy instance.
     */

View on GitHub (pinned to 3a3043227f)

Solutions

  1. Use newInstance(handler) with a real InvocationHandler instead of the no-arg newInstance().
  2. If using Dubbo's InvokerInvocationHandler, construct and pass it explicitly.
  3. Treat any UnsupportedOperationException 'unimplemented' as a misconfiguration of the proxy factory, not a runtime bug to catch.

Example fix

// before
Object proxy = dubboProxy.newInstance();
((MyService) proxy).hello(); // throws

// after
InvocationHandler h = new MyInvocationHandler(target);
Object proxy = dubboProxy.newInstance(h);
((MyService) proxy).hello(); // dispatched to h
Defensive patterns

Strategy: validation

Validate before calling

// do not call the no-arg newInstance(); always supply a handler
InvocationHandler handler = new MyInvocationHandler(target);
Object proxy = dubboProxy.newInstance(handler);

Try / catch

try {
    ((MyService) proxy).hello();
} catch (UnsupportedOperationException e) {
    // proxy was created with the default THROW_UNSUPPORTED_INVOKER; supply a real handler
}

Prevention

When it happens

Trigger: Calling Proxy.getProxy(...).newInstance() (the no-arg overload) and then invoking any method on the returned proxy object.

Common situations: Creating a proxy but forgetting to supply a real InvocationHandler; unit-test stubs that instantiate a proxy and then call it; a code path that falls back to newInstance() instead of newInstance(handler).

Related errors


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