apache / dubbo

The java implementation of Apache Dubbo. An RPC and microservice framework.
https://dubbo.apache.org/
Apache License 2.0
40.4k stars 26.41k forks source link

Annotation based service with 'callback parameter' method not works correctly #4643

Closed dyachkovD closed 5 years ago

dyachkovD commented 5 years ago

Steps to reproduce this issue

  1. Make service like this
@Service(interfaceClass = MessagingService.class, methods = {
        @Method(name = "addMessageListener", arguments = {
                @Argument(index = 0, callback = true)
        })
})
public class MessagingServiceImpl implements MessagingService {

    @Override
    public void addMessageListener(MessageListener listener) {
        //...
    }
}
  1. Call method addMessageListener on consumer side

Expected Result

No exceptions thrown

Actual Result

Throws IllegalStateException

Caused by: org.apache.dubbo.rpc.RpcException: Failed to invoke remote method: addMessageListener, provider: dubbo://127.0.0.1:20880/com.example.api.service.MessagingService?application=dubbo-spring-boot-starter&default.generic=false&default.lazy=false&default.sticky=false&dubbo=2.0.2&generic=false&interface=com.example.api.service.MessagingService&lazy=false&methods=addMessageListener&pid=5389&register.ip=192.168.1.103&revision=0.0.1-SNAPSHOT&side=consumer&sticky=false&timestamp=1563276164135, cause: io.netty.handler.codec.EncoderException: java.lang.IllegalStateException: Serialized class com.example.client.controller.MainController$1 must implement java.io.Serializable io.netty.handler.codec.EncoderException: java.lang.IllegalStateException: Serialized class com.example.client.controller.MainController$1 must implement java.io.Serializable

beiwei30 commented 5 years ago

It looks like a serialization issue, check this:

Serialized class com.example.client.controller.MainController$1 must implement java.io.Serializable
dyachkovD commented 5 years ago

@beiwei30 No, com.example.client.controller.MainController$1 is simple closure. If i use XML configuration, works fine. The @Argument annotation seems to be ignored. Need reopen this issue.