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

[Bug] In the Dubbo interface, the parameter type is defined as the parent class, but when the caller invokes the remote interface method, a subclass is passed as the parameter. This leads to an inability to deserialize the parameter #14701

Open
3 of 4 tasks
lichangan18356288293 opened this issue Sep 20, 2024 · 3 comments
Labels
component/need-triage Need maintainers to triage type/need-triage Need maintainers to triage

Comments

@lichangan18356288293
Copy link

Pre-check

  • I am sure that all the content I provide is in English.

Search before asking

  • I had searched in the issues and found no similar issues.

Apache Dubbo Component

Java SDK (apache/dubbo)

Dubbo Version

dubbo 3.2.7 jdk 17

Steps to reproduce this issue

first:
First, i define an interface as follows:
public interface RemotePrinterService {

/**

  • print file
  • @param printPara
    */
    Boolean printPdfFile(PrintPara printPara);
    }

Second, create a Dubbo implementation class to implement this interface.
@DubboService
public class RemotePrinterServiceImpl implements RemotePrinterService {

private final IPrinterService printerService;

public RemotePrinterServiceImpl(IPrinterService printerService) {
this.printerService = printerService;
}

/**

  • print file
  • @param printPara
    */
    @OverRide
    public Boolean printPdfFile(PrintPara printPara ) {
    return printerService.printPdfFile(printPara);
    }
    }

Final, there is a service that will call this print interface. However, it added a class that extends PrintPara, and during the call, it passes a subclass of PrintPara as the parameter. This will cause the following error:

[NettyServerWorker-5-2] WARN o.a.d.r.p.d.DecodeableRpcInvocation - [?,?] - [DUBBO] Decode rpc invocation failed: org.apache.dubbo.common.serialize.SerializationException: java.lang.IllegalArgumentException: deserialize failed. expected class: class com.xxx.oas.api.tool.printer.bo.PrintPara but actual class: class java.util.HashMap, dubbo version: 3.2.7, current host: 10.8.7.33, error code: 4-20. This may be caused by , go to https://dubbo.apache.org/faq/4/20 to find instructions.
java.io.IOException: org.apache.dubbo.common.serialize.SerializationException: java.lang.IllegalArgumentException: deserialize failed. expected class: class com.xxx.oas.api.tool.printer.bo.PrintPara but actual class: class java.util.HashMap
at org.apache.dubbo.common.serialize.DefaultSerializationExceptionWrapper.handleToIOException(DefaultSerializationExceptionWrapper.java:358)
at org.apache.dubbo.common.serialize.DefaultSerializationExceptionWrapper.access$000(DefaultSerializationExceptionWrapper.java:28)
at org.apache.dubbo.common.serialize.DefaultSerializationExceptionWrapper$ProxyObjectInput.readObject(DefaultSerializationExceptionWrapper.java:168)
at org.apache.dubbo.rpc.protocol.dubbo.DecodeableRpcInvocation.drawArgs(DecodeableRpcInvocation.java:268)
at org.apache.dubbo.rpc.protocol.dubbo.DecodeableRpcInvocation.decode(DecodeableRpcInvocation.java:169)
at org.apache.dubbo.rpc.protocol.dubbo.DecodeableRpcInvocation.decode(DecodeableRpcInvocation.java:102)
at org.apache.dubbo.rpc.protocol.dubbo.DubboCodec.decodeBody(DubboCodec.java:195)
at org.apache.dubbo.remoting.exchange.codec.ExchangeCodec.decode(ExchangeCodec.java:138)
at org.apache.dubbo.remoting.exchange.codec.ExchangeCodec.decode(ExchangeCodec.java:92)
at org.apache.dubbo.rpc.protocol.dubbo.DubboCountCodec.decode(DubboCountCodec.java:60)
at org.apache.dubbo.remoting.transport.netty4.NettyCodecAdapter$InternalDecoder.decode(NettyCodecAdapter.java:103)
at io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:529)
at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:468)
at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:290)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
at io.netty.handler.codec.ByteToMessageDecoder.handlerRemoved(ByteToMessageDecoder.java:266)
at io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:536)
at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:468)
at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:290)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:440)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919)
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:166)
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:788)
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:724)
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:650)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:562)
at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997)
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.base/java.lang.Thread.run(Thread.java:840)
Caused by: org.apache.dubbo.common.serialize.SerializationException: java.lang.IllegalArgumentException: deserialize failed. expected class: class com.xxx.oas.api.tool.printer.bo.PrintPara but actual class: class java.util.HashMap
... 37 common frames omitted
Caused by: java.lang.IllegalArgumentException: deserialize failed. expected class: class com.xxx.oas.api.tool.printer.bo.PrintPara but actual class: class java.util.HashMap
at org.apache.dubbo.common.serialize.fastjson2.FastJson2ObjectInput.readObject(FastJson2ObjectInput.java:132)
at org.apache.dubbo.common.serialize.DefaultSerializationExceptionWrapper$ProxyObjectInput.readObject(DefaultSerializationExceptionWrapper.java:166)
... 34 common frames omitted

What you expected to happen

Call ended normally.

Anything else

No response

Are you willing to submit a pull request to fix on your own?

  • Yes I am willing to submit a pull request on my own!

Code of Conduct

@lichangan18356288293 lichangan18356288293 added component/need-triage Need maintainers to triage type/need-triage Need maintainers to triage labels Sep 20, 2024
@AlbumenJ
Copy link
Member

@lichangan18356288293
Copy link
Author

@AlbumenJ
Copy link
Member

Check serializable

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/need-triage Need maintainers to triage type/need-triage Need maintainers to triage
Projects
Status: Todo
Development

No branches or pull requests

2 participants