polarismesh / grpc-java-polaris

gRPC-Java integrates with Polaris Service Discovery and Governance
Other
11 stars 19 forks source link

Consumer调用服务时异常 #32

Closed pyronn closed 1 year ago

pyronn commented 1 year ago

使用example的例子,provider可以正常启动并接入,consumer启动后在调用服务时会抛出以下类型转换异常并卡住。异常的代码处,会进入两次,第一次进入时类型时正确的不会抛异常,第二次是一个异步调用进入的,类型不匹配。麻烦看一下,谢谢。

Caused by: java.lang.ClassCastException: com.tencent.polaris.grpc.loadbalance.PolarisSubChannel cannot be cast to com.tencent.polaris.client.pojo.InstanceByProto
    at com.tencent.polaris.client.util.Utils.isHealthyInstance(Utils.java:100)
    at com.tencent.polaris.plugins.router.healthy.RecoverRouter.lambda$router$0(RecoverRouter.java:52)
    at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:174)
    at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1382)
    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 com.tencent.polaris.plugins.router.healthy.RecoverRouter.router(RecoverRouter.java:53)
    at com.tencent.polaris.plugins.router.common.AbstractServiceRouter.getFilteredInstances(AbstractServiceRouter.java:69)
    at com.tencent.polaris.client.flow.BaseFlow.processRouterChain(BaseFlow.java:172)
    at com.tencent.polaris.client.flow.BaseFlow.processServiceRouters(BaseFlow.java:147)
    at com.tencent.polaris.router.client.api.DefaultRouterAPI.processRouters(DefaultRouterAPI.java:138)
    at com.tencent.polaris.grpc.loadbalance.PolarisPicker.doRoute(PolarisPicker.java:167)
    at com.tencent.polaris.grpc.loadbalance.PolarisPicker.pickSubchannel(PolarisPicker.java:116)
    at io.grpc.internal.DelayedClientTransport.reprocess(DelayedClientTransport.java:297)
    at io.grpc.internal.ManagedChannelImpl.updateSubchannelPicker(ManagedChannelImpl.java:896)
    at io.grpc.internal.ManagedChannelImpl.access$5300(ManagedChannelImpl.java:118)
    at io.grpc.internal.ManagedChannelImpl$LbHelperImpl$1UpdateBalancingState.run(ManagedChannelImpl.java:1476)
    at io.grpc.SynchronizationContext.drain(SynchronizationContext.java:95)
    at io.grpc.SynchronizationContext.execute(SynchronizationContext.java:127)
    at io.grpc.internal.InternalSubchannel$TransportListener.transportReady(InternalSubchannel.java:547)
    at io.grpc.netty.ClientTransportLifecycleManager.notifyReady(ClientTransportLifecycleManager.java:44)
    at io.grpc.netty.NettyClientHandler$FrameListener.onSettingsRead(NettyClientHandler.java:914)
    at io.netty.handler.codec.http2.DefaultHttp2ConnectionDecoder$FrameReadListener.onSettingsRead(DefaultHttp2ConnectionDecoder.java:526)
    at io.netty.handler.codec.http2.DefaultHttp2ConnectionDecoder$PrefaceFrameListener.onSettingsRead(DefaultHttp2ConnectionDecoder.java:745)
    at io.netty.handler.codec.http2.Http2InboundFrameLogger$1.onSettingsRead(Http2InboundFrameLogger.java:93)
    at io.netty.handler.codec.http2.DefaultHttp2FrameReader.readSettingsFrame(DefaultHttp2FrameReader.java:542)
    at io.netty.handler.codec.http2.DefaultHttp2FrameReader.processPayloadState(DefaultHttp2FrameReader.java:263)
    at io.netty.handler.codec.http2.DefaultHttp2FrameReader.readFrame(DefaultHttp2FrameReader.java:160)
    at io.netty.handler.codec.http2.Http2InboundFrameLogger.readFrame(Http2InboundFrameLogger.java:41)
    at io.netty.handler.codec.http2.DefaultHttp2ConnectionDecoder.decodeFrame(DefaultHttp2ConnectionDecoder.java:181)
    at io.netty.handler.codec.http2.Http2ConnectionHandler$FrameDecoder.decode(Http2ConnectionHandler.java:378)
    at io.netty.handler.codec.http2.Http2ConnectionHandler$PrefaceDecoder.decode(Http2ConnectionHandler.java:242)
    at io.netty.handler.codec.http2.Http2ConnectionHandler.decode(Http2ConnectionHandler.java:438)
    at io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:508)
    at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:447)
    at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:276)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
    at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
    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:719)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:655)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:581)
    at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:493)
    at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
    at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
    at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
    at java.lang.Thread.run(Thread.java:748)

Environment

pyronn commented 1 year ago

升级polaris-all到1.10.1可解决,有不兼容的接口需要调整

chuntaojun commented 1 year ago

ok,我这里进行处理下