alibaba / fastjson2

🚄 FASTJSON2 is a Java JSON library with excellent performance.
Apache License 2.0
3.78k stars 495 forks source link

dubbo项目kotlin模块java模块相互调用序列化失败 #2301

Closed pigeon-fancier closed 7 months ago

pigeon-fancier commented 8 months ago

问题描述

简要描述您碰到的问题。 org.apache.dubbo.rpc.StatusRpcException: INTERNAL : java.lang.NullPointerException: Cannot load from object array because "this.encodeTypes" is null

环境信息

请填写以下信息:

重现步骤

如何操作可以重现该问题: dubbo协议tri,序列化使用fastjson2,消费者、生产者提供的接口参数都是kotlin的data class,必现

rowstop commented 8 months ago

异常信息补全些看下

pigeon-fancier commented 8 months ago

异常信息补全些看下

这个第一次发现是kotlin data class set的问题,现在是一个新问题,具体可以参考如下issue先,我先检查看看dubbo中的fastjson2版本是不是2.0.47 https://github.com/apache/dubbo/issues/13733#issuecomment-1963538184

pigeon-fancier commented 8 months ago

两端使用的配置,新版dubbo默认是fastjson2,所以没有特别指定使用fastjson2,默认来源:

dubbo:
  application:
    name: dubbo-springboot-consumer
    qos-enable: false
    check-serializable: false
    trust-serialize-class-level: 2
    serialize-check-status: DISABLE
    auto-trust-serialize-class: false
  protocol:
    name: tri
    port: -1
    accesslog: logs/dubbo.log
  registry:
    username: *nacosUserName
    password: *nacosPassword
    parameters:
      namespace: '@dubbo.nacos.namespace@'
    address: '@dubbo.nacos.server.addr@'
  provider:
    accesslog: logs/dubbo.log

生产者端

AbstractServerTransportListener :  [DUBBO] server internal error, dubbo version: 3.3.0-beta.1, current host: 192.168.1.126

java.nio.BufferUnderflowException: null
    at java.base/java.nio.HeapByteBuffer.get(HeapByteBuffer.java:183) ~[na:na]
    at org.apache.dubbo.rpc.protocol.tri.TripleCustomerProtocolWapper$TripleRequestWrapper.parseFrom(TripleCustomerProtocolWapper.java:261) ~[dubbo-3.3.0-beta.1.jar:3.3.0-beta.1]
    at org.apache.dubbo.rpc.protocol.tri.h12.grpc.GrpcHttp2ServerTransportListener$DetermineMethodDescriptorListener.onFragmentMessage(GrpcHttp2ServerTransportListener.java:183) ~[dubbo-3.3.0-beta.1.jar:3.3.0-beta.1]
    at org.apache.dubbo.remoting.http12.message.LengthFieldStreamingDecoder.invokeListener(LengthFieldStreamingDecoder.java:171) ~[dubbo-3.3.0-beta.1.jar:3.3.0-beta.1]
    at org.apache.dubbo.remoting.http12.message.LengthFieldStreamingDecoder.processBody(LengthFieldStreamingDecoder.java:163) ~[dubbo-3.3.0-beta.1.jar:3.3.0-beta.1]
    at org.apache.dubbo.remoting.http12.message.LengthFieldStreamingDecoder.deliver(LengthFieldStreamingDecoder.java:108) ~[dubbo-3.3.0-beta.1.jar:3.3.0-beta.1]
    at org.apache.dubbo.remoting.http12.message.LengthFieldStreamingDecoder.decode(LengthFieldStreamingDecoder.java:72) ~[dubbo-3.3.0-beta.1.jar:3.3.0-beta.1]
    at org.apache.dubbo.rpc.protocol.tri.h12.grpc.GrpcHttp2ServerTransportListener$LazyFindMethodListener.onMessage(GrpcHttp2ServerTransportListener.java:149) ~[dubbo-3.3.0-beta.1.jar:3.3.0-beta.1]
    at org.apache.dubbo.rpc.protocol.tri.h12.AbstractServerTransportListener.doOnData(AbstractServerTransportListener.java:190) ~[dubbo-3.3.0-beta.1.jar:3.3.0-beta.1]
    at org.apache.dubbo.rpc.protocol.tri.h12.AbstractServerTransportListener.lambda$onData$1(AbstractServerTransportListener.java:178) ~[dubbo-3.3.0-beta.1.jar:3.3.0-beta.1]
    at org.apache.dubbo.common.threadpool.serial.SerializingExecutor.run(SerializingExecutor.java:102) ~[dubbo-3.3.0-beta.1.jar:3.3.0-beta.1]
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) ~[na:na]
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) ~[na:na]
    at org.apache.dubbo.common.threadlocal.InternalRunnable.run(InternalRunnable.java:41) ~[dubbo-3.3.0-beta.1.jar:3.3.0-beta.1]
    at java.base/java.lang.Thread.run(Thread.java:842) ~[na:na]

消费者端

[Request processing failed: org.apache.dubbo.rpc.RpcException: java.util.concurrent.ExecutionException: org.apache.dubbo.rpc.StatusRpcException: INTERNAL : java.lang.NullPointerException: Cannot load from object array because "this.encodeTypes" is null] with root cause
org.apache.dubbo.rpc.StatusRpcException: INTERNAL : java.lang.NullPointerException: Cannot load from object array because "this.encodeTypes" is null
    at org.apache.dubbo.rpc.TriRpcStatus.asException(TriRpcStatus.java:214)
    at org.apache.dubbo.rpc.protocol.tri.call.UnaryClientCallListener.onClose(UnaryClientCallListener.java:54)
    at org.apache.dubbo.rpc.protocol.tri.call.TripleClientCall.onComplete(TripleClientCall.java:112)
    at org.apache.dubbo.rpc.protocol.tri.stream.TripleClientStream$ClientTransportListener.finishProcess(TripleClientStream.java:250)
    at org.apache.dubbo.rpc.protocol.tri.stream.TripleClientStream$ClientTransportListener$1.close(TripleClientStream.java:319)
    at org.apache.dubbo.rpc.protocol.tri.frame.TriDecoder.deliver(TriDecoder.java:101)
    at org.apache.dubbo.rpc.protocol.tri.frame.TriDecoder.close(TriDecoder.java:67)
    at org.apache.dubbo.rpc.protocol.tri.stream.TripleClientStream$ClientTransportListener.onTrailersReceived(TripleClientStream.java:339)
    at org.apache.dubbo.rpc.protocol.tri.stream.TripleClientStream$ClientTransportListener.lambda$onHeader$1(TripleClientStream.java:442)
    at org.apache.dubbo.common.threadpool.serial.SerializingExecutor.run(SerializingExecutor.java:102)
    at org.apache.dubbo.common.threadpool.ThreadlessExecutor$RunnableWrapper.run(ThreadlessExecutor.java:152)
    at org.apache.dubbo.common.threadpool.ThreadlessExecutor.waitAndDrain(ThreadlessExecutor.java:77)
    at org.apache.dubbo.rpc.AsyncRpcResult.get(AsyncRpcResult.java:205)
    at org.apache.dubbo.rpc.protocol.AbstractInvoker.waitForResultIfSync(AbstractInvoker.java:287)
    at org.apache.dubbo.rpc.protocol.AbstractInvoker.invoke(AbstractInvoker.java:190)
    at org.apache.dubbo.rpc.listener.ListenerInvokerWrapper.invoke(ListenerInvokerWrapper.java:71)
    at org.apache.dubbo.rpc.filter.RpcExceptionFilter.invoke(RpcExceptionFilter.java:41)
    at org.apache.dubbo.rpc.cluster.filter.FilterChainBuilder$CopyOfFilterChainNode.invoke(FilterChainBuilder.java:334)
    at org.apache.dubbo.rpc.cluster.filter.FilterChainBuilder$CallbackRegistrationInvoker.invoke(FilterChainBuilder.java:196)
    at org.apache.dubbo.rpc.protocol.ReferenceCountInvokerWrapper.invoke(ReferenceCountInvokerWrapper.java:88)
    at org.apache.dubbo.rpc.cluster.support.AbstractClusterInvoker.invokeWithContext(AbstractClusterInvoker.java:383)
    at org.apache.dubbo.rpc.cluster.support.FailoverClusterInvoker.doInvoke(FailoverClusterInvoker.java:80)
    at org.apache.dubbo.rpc.cluster.support.AbstractClusterInvoker.invoke(AbstractClusterInvoker.java:344)
    at org.apache.dubbo.rpc.cluster.router.RouterSnapshotFilter.invoke(RouterSnapshotFilter.java:46)
    at org.apache.dubbo.rpc.cluster.filter.FilterChainBuilder$CopyOfFilterChainNode.invoke(FilterChainBuilder.java:334)
    at org.apache.dubbo.monitor.support.MonitorFilter.invoke(MonitorFilter.java:108)
    at org.apache.dubbo.rpc.cluster.filter.FilterChainBuilder$CopyOfFilterChainNode.invoke(FilterChainBuilder.java:334)
    at org.apache.dubbo.rpc.cluster.filter.support.MetricsClusterFilter.invoke(MetricsClusterFilter.java:59)
    at org.apache.dubbo.rpc.cluster.filter.FilterChainBuilder$CopyOfFilterChainNode.invoke(FilterChainBuilder.java:334)
    at org.apache.dubbo.rpc.protocol.dubbo.filter.FutureFilter.invoke(FutureFilter.java:53)
    at org.apache.dubbo.rpc.cluster.filter.FilterChainBuilder$CopyOfFilterChainNode.invoke(FilterChainBuilder.java:334)
    at org.apache.dubbo.spring.security.filter.ContextHolderParametersSelectedTransferFilter.invoke(ContextHolderParametersSelectedTransferFilter.java:41)
    at org.apache.dubbo.rpc.cluster.filter.FilterChainBuilder$CopyOfFilterChainNode.invoke(FilterChainBuilder.java:334)
    at org.apache.dubbo.metrics.filter.MetricsFilter.invoke(MetricsFilter.java:76)
    at org.apache.dubbo.rpc.cluster.filter.support.MetricsConsumerFilter.invoke(MetricsConsumerFilter.java:37)
    at org.apache.dubbo.rpc.cluster.filter.FilterChainBuilder$CopyOfFilterChainNode.invoke(FilterChainBuilder.java:334)
    at org.apache.dubbo.rpc.cluster.filter.support.ConsumerClassLoaderFilter.invoke(ConsumerClassLoaderFilter.java:40)
    at org.apache.dubbo.rpc.cluster.filter.FilterChainBuilder$CopyOfFilterChainNode.invoke(FilterChainBuilder.java:334)
    at org.apache.dubbo.tracing.filter.ObservationSenderFilter.invoke(ObservationSenderFilter.java:57)
    at org.apache.dubbo.rpc.cluster.filter.FilterChainBuilder$CopyOfFilterChainNode.invoke(FilterChainBuilder.java:334)
    at org.apache.dubbo.rpc.cluster.filter.support.ConsumerContextFilter.invoke(ConsumerContextFilter.java:116)
    at org.apache.dubbo.rpc.cluster.filter.FilterChainBuilder$CopyOfFilterChainNode.invoke(FilterChainBuilder.java:334)
    at org.apache.dubbo.rpc.cluster.filter.FilterChainBuilder$CallbackRegistrationInvoker.invoke(FilterChainBuilder.java:196)
    at org.apache.dubbo.rpc.cluster.support.wrapper.AbstractCluster$ClusterFilterInvoker.invoke(AbstractCluster.java:91)
    at org.apache.dubbo.rpc.cluster.support.wrapper.MockClusterInvoker.invoke(MockClusterInvoker.java:103)
    at org.apache.dubbo.rpc.cluster.support.wrapper.ScopeClusterInvoker.invoke(ScopeClusterInvoker.java:169)
    at org.apache.dubbo.registry.client.migration.MigrationInvoker.invoke(MigrationInvoker.java:284)
    at org.apache.dubbo.rpc.proxy.InvocationUtil.invoke(InvocationUtil.java:61)
    at org.apache.dubbo.rpc.proxy.InvokerInvocationHandler.invoke(InvokerInvocationHandler.java:75)
wenshao commented 8 months ago

错误堆栈中没有fastjson2啊