Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Javassist does not handle interface duplication method correctly #1384

Open
s2marine opened this issue Dec 28, 2023 · 3 comments
Open

Javassist does not handle interface duplication method correctly #1384

s2marine opened this issue Dec 28, 2023 · 3 comments
Labels
remind To be further discussed

Comments

@s2marine
Copy link

s2marine commented Dec 28, 2023

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
@nobodyiam
Copy link
Member

I'm not sure whether it's a good practice to support this scenario, is there an actual situation you encountered?

@s2marine
Copy link
Author

Probably not a good coding practice for this case.
It’s just that I think as a framework, it may need to support the modes which supported by JDK.

@EvenLjj
Copy link
Collaborator

EvenLjj commented Jan 15, 2024

@s2marine Thank you for your feedback. This issue does indeed exist here. One solution is to do logical deduplication in the method com.alipay.sofa.rpc.proxy.javassist.JavassistProxy#createMethod.If you'd like to fix it, welcome to take part in contributing.

@EvenLjj EvenLjj added the remind To be further discussed label Jan 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
remind To be further discussed
Projects
None yet
Development

No branches or pull requests

3 participants