Skip to content

Javassist does not handle interface duplication method correctly #1384

@s2marine

Description

@s2marine

Describe the bug

Javassist reports an error when encountering duplicate method: "duplicate method".
When I change default implementation of the proxy to Bytebuddy, the service starts successfully.

Expected behavior

Duplicate methods should only generate one method.

Actual behavior

Exception in thread "main" com.alipay.sofa.rpc.core.exception.SofaRpcRuntimeException: RPC-010080001: 使用 [javassist] 构造代理出现错误. 
	at com.alipay.sofa.rpc.proxy.javassist.JavassistProxy.getProxy(JavassistProxy.java:149)
	at com.alipay.sofa.rpc.proxy.ProxyFactory.buildProxy(ProxyFactory.java:50)
	at com.alipay.sofa.rpc.bootstrap.DefaultConsumerBootstrap.refer(DefaultConsumerBootstrap.java:156)
	at com.alipay.sofa.rpc.config.ConsumerConfig.refer(ConsumerConfig.java:955)
	at me.s2marine.QuickStartClient.main(QuickStartClient.java:14)
Caused by: javassist.bytecode.DuplicateMemberException: duplicate method: getType in me.s2marine.QuickStartClient$HelloService_proxy_0
	at javassist.bytecode.ClassFile.testExistingMethod(ClassFile.java:685)
	at javassist.bytecode.ClassFile.addMethod(ClassFile.java:660)
	at javassist.CtClassType.addMethod(CtClassType.java:1498)
	at com.alipay.sofa.rpc.proxy.javassist.JavassistProxy.getProxy(JavassistProxy.java:125)
	... 4 more

Steps to reproduce

Minimal yet complete reproducer code (or GitHub URL to code)

public class QuickStartClient {

    public static void main(String[] args) {
        ConsumerConfig<HelloService> consumerConfig = new ConsumerConfig<HelloService>()
                .setInterfaceId(HelloService.class.getName()) // Specify the interface
                .setProtocol("bolt") // Specify the protocol.setDirectUrl
                .setDirectUrl("bolt://127.0.0.1:12200"); // Specify the direct connection address

        // Generate the proxy class
        HelloService helloService = consumerConfig.refer();
    }

    public interface HelloService extends SubInterface1, SubInterface2 {
        String sayHello(String string);
    }

    interface SubInterface1 {
        String getType();

        String someMethod1();
    }

    interface SubInterface2 {
        String getType();

        String someMethod2();
    }
}

Environment

  • SOFARPC version: 5.11.1
  • JVM version (e.g. java -version): 1.8.0_392
  • OS version (e.g. uname -a): Linux archlinux-r9000p-s2marine 6.6.8-arch1-1 #1 SMP PREEMPT_DYNAMIC Thu, 21 Dec 2023 19:01:01 +0000 x86_64 GNU/Linux
  • Maven version: Apache Maven 3.8.7
  • IDE version: Intellij IDEA 2023.3.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    remindTo be further discussed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions