salesforce / reactive-grpc

Reactive stubs for gRPC
BSD 3-Clause "New" or "Revised" License
829 stars 118 forks source link

How to customize ClientInterceptor and ServerInterceptor #327

Closed thousmile closed 9 months ago

thousmile commented 10 months ago

Blocking interceptor, error reporting


io.grpc.StatusRuntimeException: UNAUTHENTICATED: Invalid tenantId
    at io.grpc.Status.asRuntimeException(Status.java:537) ~[grpc-api-1.60.1.jar:1.60.1]
    Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException: 
Assembly trace from producer [reactor.core.publisher.MonoCreate] :
    reactor.core.publisher.Mono.create(Mono.java:202)
    com.salesforce.reactorgrpc.stub.ClientCalls.oneToOne(ClientCalls.java:38)
Error has been observed at the following site(s):
    *_________Mono.create ⇢ at com.salesforce.reactorgrpc.stub.ClientCalls.oneToOne(ClientCalls.java:38)
    |_     Mono.transform ⇢ at com.salesforce.reactorgrpc.stub.ClientCalls.oneToOne(ClientCalls.java:57)
    |_           Mono.map ⇢ at com.xaaef.grpc.client.GrpcClientController.getStringValue(GrpcClientController.java:131)
    |_          Flux.from ⇢ at org.springframework.core.codec.CharSequenceEncoder.encode(CharSequenceEncoder.java:73)
    |_           Flux.map ⇢ at org.springframework.core.codec.CharSequenceEncoder.encode(CharSequenceEncoder.java:73)
    |_ Flux.singleOrEmpty ⇢ at org.springframework.http.codec.EncoderHttpMessageWriter.write(EncoderHttpMessageWriter.java:128)
    |_ Mono.switchIfEmpty ⇢ at org.springframework.http.codec.EncoderHttpMessageWriter.write(EncoderHttpMessageWriter.java:129)
    |_       Mono.flatMap ⇢ at org.springframework.http.codec.EncoderHttpMessageWriter.write(EncoderHttpMessageWriter.java:133)
    |_   Mono.doOnDiscard ⇢ at org.springframework.http.codec.EncoderHttpMessageWriter.write(EncoderHttpMessageWriter.java:139)
    |_         checkpoint ⇢ Handler com.xaaef.grpc.client.GrpcClientController#getStringValue(String) [DispatcherHandler]
    |_ Mono.onErrorResume ⇢ at org.springframework.web.reactive.DispatcherHandler.handleResult(DispatcherHandler.java:194)
    *________Mono.flatMap ⇢ at org.springframework.web.reactive.DispatcherHandler.lambda$handleResult$8(DispatcherHandler.java:195)
    *________Mono.flatMap ⇢ at org.springframework.web.reactive.DispatcherHandler.handleRequestWith(DispatcherHandler.java:184)
    *________Mono.flatMap ⇢ at org.springframework.web.reactive.DispatcherHandler.handle(DispatcherHandler.java:154)
    *__________Mono.defer ⇢ at org.springframework.web.server.handler.DefaultWebFilterChain.filter(DefaultWebFilterChain.java:106)
    |_           Mono.tap ⇢ at org.springframework.web.filter.reactive.ServerHttpObservationFilter.filter(ServerHttpObservationFilter.java:104)
    |_         checkpoint ⇢ org.springframework.web.filter.reactive.ServerHttpObservationFilter [DefaultWebFilterChain]
    *__________Mono.defer ⇢ at org.springframework.web.server.handler.DefaultWebFilterChain.filter(DefaultWebFilterChain.java:106)
    |_ Mono.onErrorResume ⇢ at org.springframework.web.server.handler.ExceptionHandlingWebHandler.handle(ExceptionHandlingWebHandler.java:77)
    *__________Mono.error ⇢ at org.springframework.web.server.handler.ExceptionHandlingWebHandler$CheckpointInsertingHandler.handle(ExceptionHandlingWebHandler.java:98)
    |_         checkpoint ⇢ HTTP GET "/getStringValue?key=hello1" [ExceptionHandlingWebHandler]
Original Stack Trace:
        at io.grpc.Status.asRuntimeException(Status.java:537) ~[grpc-api-1.60.1.jar:1.60.1]
        at io.grpc.stub.ClientCalls$StreamObserverToCallListenerAdapter.onClose(ClientCalls.java:481) ~[grpc-stub-1.60.1.jar:1.60.1]
        at io.grpc.PartialForwardingClientCallListener.onClose(PartialForwardingClientCallListener.java:39) ~[grpc-api-1.60.1.jar:1.60.1]
        at io.grpc.ForwardingClientCallListener.onClose(ForwardingClientCallListener.java:23) ~[grpc-api-1.60.1.jar:1.60.1]
        at io.grpc.ForwardingClientCallListener$SimpleForwardingClientCallListener.onClose(ForwardingClientCallListener.java:40) ~[grpc-api-1.60.1.jar:1.60.1]
        at io.micrometer.core.instrument.binder.grpc.MetricCollectingClientCallListener.onClose(MetricCollectingClientCallListener.java:57) ~[micrometer-core-1.11.7.jar:1.11.7]
        at io.grpc.internal.ClientCallImpl.closeObserver(ClientCallImpl.java:574) ~[grpc-core-1.60.1.jar:1.60.1]
        at io.grpc.internal.ClientCallImpl.access$300(ClientCallImpl.java:72) ~[grpc-core-1.60.1.jar:1.60.1]
        at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1StreamClosed.runInternal(ClientCallImpl.java:742) ~[grpc-core-1.60.1.jar:1.60.1]
        at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1StreamClosed.runInContext(ClientCallImpl.java:723) ~[grpc-core-1.60.1.jar:1.60.1]
        at io.grpc.internal.ContextRunnable.run(ContextRunnable.java:37) ~[grpc-core-1.60.1.jar:1.60.1]
        at io.grpc.internal.SerializingExecutor.run(SerializingExecutor.java:133) ~[grpc-core-1.60.1.jar:1.60.1]
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144) ~[na:na]
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642) ~[na:na]
        at java.base/java.lang.Thread.run(Thread.java:1583) ~[na:na]
franciscovinueza-cpi commented 5 months ago

Did you find the solution for this problem?