apache / shenyu

Apache ShenYu is a Java native API Gateway for service proxy, protocol conversion and API governance.
https://shenyu.apache.org/
Apache License 2.0
8.41k stars 2.92k forks source link

[BUG] sofa plug throw ClassCastException in Complex parameters #2069

Closed li-keguo closed 2 years ago

li-keguo commented 3 years ago

Is there an existing issue for this?

Current Behavior

start [shenyu-admin],[shenyu-bootstrap],[shenyu-examples-sofa]

it ok all

request:

GET http://localhost:9195/sofa/findByListId

HTTP/1.1 200 OK
Content-Type: application/json
content-length: 133

{
  "code": 200,
  "message": "Access to success!",
  "data": {
    "id": "[123.0, 124.0, 125.0]",
    "name": "hello world shenyu sofa param findByListId"
  }
}

Response code: 200 (OK); Time: 268ms; Content length: 133 bytes

it ok: but atchSave method

PUT http://localhost:9195/sofa/batchSave

HTTP/1.1 500 Internal Server Error
Content-Type: application/json
Content-Length: 245

{
  "code": 500,
  "message": "Internal Server Error",
  "data": "com.alipay.sofa.rpc.core.exception.SofaTimeOutException: com.alipay.remoting.rpc.exception.InvokeTimeoutException: Invoke timeout when invoke with callback.The address is 10.100.20.106:8888"
}

Response code: 500 (Internal Server Error); Time: 3147ms; Content length: 245 bytes

I'm debug:

    @ShenyuSofaClient(path = "/batchSave", desc = "batchSave")
    public SofaSimpleTypeBean batchSave(final List<SofaSimpleTypeBean> sofaTestList) {
        SofaSimpleTypeBean simpleTypeBean = new SofaSimpleTypeBean();
        simpleTypeBean.setId(sofaTestList.stream().map(SofaSimpleTypeBean::getId).collect(Collectors.joining("-")));
        simpleTypeBean.setName("hello world shenyu sofa param batchSave :" + sofaTestList.stream().map(SofaSimpleTypeBean::getName).collect(Collectors.joining("-")));
        return simpleTypeBean;
    }

image

param is not cast

Expected Behavior

success

Steps To Reproduce

No response

Environment

ShenYu version(s):master

Debug logs

2021-09-13 17:50:50 [shenyu-netty-kqueue-2] INFO org.apache.shenyu.plugin.base.AbstractShenyuPlugin - sofa selector success match , selector name :/sofa 2021-09-13 17:50:50 [shenyu-netty-kqueue-2] INFO org.apache.shenyu.plugin.base.AbstractShenyuPlugin - sofa rule success match , rule name :/sofa/batchSave 2021-09-13 17:50:50 [SOFA-RPC-CB-4-T8] ERROR org.apache.shenyu.web.handler.GlobalErrorHandler - [65a7de44] Resolved [ShenyuException: java.lang.ClassCastException: com.google.gson.internal.LinkedTreeMap cannot be cast to org.apache.shenyu.examples.sofa.api.entity.SofaSimpleTypeBean] for HTTP PUT /sofa/batchSave 2021-09-13 17:50:50 [SOFA-RPC-CB-4-T8] ERROR org.springframework.boot.autoconfigure.web.reactive.error.AbstractErrorWebExceptionHandler - [65a7de44] 500 Server Error for HTTP PUT "/sofa/batchSave" org.apache.shenyu.common.exception.ShenyuException: java.lang.ClassCastException: com.google.gson.internal.LinkedTreeMap cannot be cast to org.apache.shenyu.examples.sofa.api.entity.SofaSimpleTypeBean at reactor.core.publisher.Mono.lambda$onErrorMap$30(Mono.java:3270) Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException: Error has been observed at the following site(s): | checkpoint ⇢ org.apache.shenyu.web.configuration.ErrorHandlerConfiguration$1 [DefaultWebFilterChain] | checkpoint ⇢ org.apache.shenyu.web.filter.WebSocketParamFilter [DefaultWebFilterChain] | checkpoint ⇢ org.apache.shenyu.web.filter.FileSizeFilter [DefaultWebFilterChain] | checkpoint ⇢ org.apache.shenyu.bootstrap.filter.HealthFilter [DefaultWebFilterChain] | checkpoint ⇢ org.apache.shenyu.web.filter.CrossFilter [DefaultWebFilterChain] | checkpoint ⇢ org.apache.shenyu.web.filter.LocalDispatcherFilter [DefaultWebFilterChain] | checkpoint ⇢ org.springframework.boot.actuate.metrics.web.reactive.server.MetricsWebFilter [DefaultWebFilterChain] | checkpoint ⇢ HTTP PUT "/sofa/batchSave" [ExceptionHandlingWebHandler] Stack trace: at reactor.core.publisher.Mono.lambda$onErrorMap$30(Mono.java:3270) at reactor.core.publisher.FluxOnErrorResume$ResumeSubscriber.onError(FluxOnErrorResume.java:88) at reactor.core.publisher.MonoCompletionStage.lambda$subscribe$0(MonoCompletionStage.java:80) at java.util.concurrent.CompletableFuture.uniWhenComplete(CompletableFuture.java:774) at java.util.concurrent.CompletableFuture$UniWhenComplete.tryFire(CompletableFuture.java:750) at java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:488) at java.util.concurrent.CompletableFuture.completeExceptionally(CompletableFuture.java:1990) at org.apache.shenyu.plugin.sofa.proxy.SofaProxyService$1.onAppException(SofaProxyService.java:89) at com.alipay.sofa.rpc.message.bolt.BoltInvokerCallback.onResponse(BoltInvokerCallback.java:104) at com.alipay.remoting.rpc.RpcInvokeCallbackListener$CallbackTask.run(RpcInvokeCallbackListener.java:169) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748) Caused by: java.lang.ClassCastException: com.google.gson.internal.LinkedTreeMap cannot be cast to org.apache.shenyu.examples.sofa.api.entity.SofaSimpleTypeBean at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193) at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1384) at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:482) at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472) at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708) at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499) at org.apache.shenyu.examples.sofa.service.impl.SofaMultiParamServiceImpl.batchSave(SofaMultiParamServiceImpl.java:77) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at com.alipay.sofa.rpc.filter.ProviderInvoker.invoke(ProviderInvoker.java:77) at com.alipay.sofa.rpc.filter.sofatracer.ProviderTracerFilter.invoke(ProviderTracerFilter.java:74) at com.alipay.sofa.rpc.filter.FilterInvoker.invoke(FilterInvoker.java:96) at com.alipay.sofa.rpc.filter.ProviderBaggageFilter.invoke(ProviderBaggageFilter.java:45) at com.alipay.sofa.rpc.filter.FilterInvoker.invoke(FilterInvoker.java:96) at com.alipay.sofa.rpc.filter.RpcServiceContextFilter.invoke(RpcServiceContextFilter.java:62) at com.alipay.sofa.rpc.filter.FilterInvoker.invoke(FilterInvoker.java:96) at com.alipay.sofa.rpc.filter.ProviderExceptionFilter.invoke(ProviderExceptionFilter.java:37) at com.alipay.sofa.rpc.filter.FilterInvoker.invoke(FilterInvoker.java:96) at com.alipay.sofa.rpc.filter.FilterChain.invoke(FilterChain.java:262) at com.alipay.sofa.rpc.server.ProviderProxyInvoker.invoke(ProviderProxyInvoker.java:65) at com.alipay.sofa.rpc.server.bolt.BoltServerProcessor.doInvoke(BoltServerProcessor.java:226) at com.alipay.sofa.rpc.server.bolt.BoltServerProcessor.handleRequest(BoltServerProcessor.java:171) at com.alipay.sofa.rpc.server.bolt.BoltServerProcessor.handleRequest(BoltServerProcessor.java:61) at com.alipay.remoting.rpc.protocol.RpcRequestProcessor.dispatchToUserProcessor(RpcRequestProcessor.java:218) at com.alipay.remoting.rpc.protocol.RpcRequestProcessor.doProcess(RpcRequestProcessor.java:145) at com.alipay.remoting.rpc.protocol.RpcRequestProcessor$ProcessTask.run(RpcRequestProcessor.java:371) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748) 2021-09-13 17:52:01 [AsyncResolver-bootstrap-executor-0] INFO com.netflix.discovery.shared.resolver.aws.ConfigClusterResolver - Resolving eureka endpoints via configuration 2021-09-13 17:53:08 [shenyu-netty-kqueue-3] INFO org.apache.shenyu.plugin.base.AbstractShenyuPlugin - sofa selector success match , selector name :/sofa 2021-09-13 17:53:08 [shenyu-netty-kqueue-3] INFO org.apache.shenyu.plugin.base.AbstractShenyuPlugin - sofa rule success match , rule name :/sofa/batchSave 2021-09-13 17:53:11 [SOFA-RPC-CB-4-T1] ERROR org.apache.shenyu.web.handler.GlobalErrorHandler - [a381f150] Resolved [ShenyuException: com.alipay.sofa.rpc.core.exception.SofaTimeOutException: com.alipay.remoting.rpc.exception.InvokeTimeoutException: Invoke timeout when invoke with callback.The address is 10.100.20.106:8888] for HTTP PUT /sofa/batchSave 2021-09-13 17:53:11 [SOFA-RPC-CB-4-T1] ERROR org.springframework.boot.autoconfigure.web.reactive.error.AbstractErrorWebExceptionHandler - [a381f150] 500 Server Error for HTTP PUT "/sofa/batchSave" org.apache.shenyu.common.exception.ShenyuException: com.alipay.sofa.rpc.core.exception.SofaTimeOutException: com.alipay.remoting.rpc.exception.InvokeTimeoutException: Invoke timeout when invoke with callback.The address is 10.100.20.106:8888 at reactor.core.publisher.Mono.lambda$onErrorMap$30(Mono.java:3270) Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException: Error has been observed at the following site(s): | checkpoint ⇢ org.apache.shenyu.web.configuration.ErrorHandlerConfiguration$1 [DefaultWebFilterChain] | checkpoint ⇢ org.apache.shenyu.web.filter.WebSocketParamFilter [DefaultWebFilterChain] | checkpoint ⇢ org.apache.shenyu.web.filter.FileSizeFilter [DefaultWebFilterChain] | checkpoint ⇢ org.apache.shenyu.bootstrap.filter.HealthFilter [DefaultWebFilterChain] | checkpoint ⇢ org.apache.shenyu.web.filter.CrossFilter [DefaultWebFilterChain] | checkpoint ⇢ org.apache.shenyu.web.filter.LocalDispatcherFilter [DefaultWebFilterChain] | checkpoint ⇢ org.springframework.boot.actuate.metrics.web.reactive.server.MetricsWebFilter [DefaultWebFilterChain] | checkpoint ⇢ HTTP PUT "/sofa/batchSave" [ExceptionHandlingWebHandler] Stack trace: at reactor.core.publisher.Mono.lambda$onErrorMap$30(Mono.java:3270) at reactor.core.publisher.FluxOnErrorResume$ResumeSubscriber.onError(FluxOnErrorResume.java:88) at reactor.core.publisher.MonoCompletionStage.lambda$subscribe$0(MonoCompletionStage.java:80) at java.util.concurrent.CompletableFuture.uniWhenComplete(CompletableFuture.java:774) at java.util.concurrent.CompletableFuture$UniWhenComplete.tryFire(CompletableFuture.java:750) at java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:488) at java.util.concurrent.CompletableFuture.completeExceptionally(CompletableFuture.java:1990) at org.apache.shenyu.plugin.sofa.proxy.SofaProxyService$1.onSofaException(SofaProxyService.java:94) at com.alipay.sofa.rpc.message.bolt.BoltInvokerCallback.onException(BoltInvokerCallback.java:149) at com.alipay.remoting.rpc.RpcInvokeCallbackListener$CallbackTask.run(RpcInvokeCallbackListener.java:151) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748) Caused by: com.alipay.sofa.rpc.core.exception.SofaTimeOutException: com.alipay.remoting.rpc.exception.InvokeTimeoutException: Invoke timeout when invoke with callback.The address is 10.100.20.106:8888 at com.alipay.sofa.rpc.message.bolt.BoltInvokerCallback.onException(BoltInvokerCallback.java:144) at com.alipay.remoting.rpc.RpcInvokeCallbackListener$CallbackTask.run(RpcInvokeCallbackListener.java:151) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748) Caused by: com.alipay.remoting.rpc.exception.InvokeTimeoutException: Invoke timeout when invoke with callback.The address is 10.100.20.106:8888 at com.alipay.remoting.rpc.RpcInvokeCallbackListener$CallbackTask.run(RpcInvokeCallbackListener.java:117) ... 3 common frames omitted 2021-09-13 17:57:01 [AsyncResolver-bootstrap-executor-0] INFO com.netflix.discovery.shared.resolver.aws.ConfigClusterResolver - Resolving eureka endpoints via configuration

Anything else?

No response

yu199195 commented 3 years ago

can you fix it?

li-keguo commented 3 years ago

I try,

if I can't,help me