{"record":{"id":"8438f5689a10ba13","repo":"apache/shenyu","slug":"caught-exception-while-waiting-for-rpc-e-getmessage","errorCode":null,"errorMessage":"Caught exception while waiting for rpc :{ ${e.getMessage()}}","messagePattern":"Caught exception while waiting for rpc :(.+?)","errorType":"exception","errorClass":"ShenyuGrpcException","httpStatus":null,"severity":"error","filePath":"shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-rpc/shenyu-plugin-grpc/src/main/java/org/apache/shenyu/plugin/grpc/client/ShenyuGrpcClient.java","lineNumber":104,"sourceCode":"        \n        ShenyuGrpcCallRequest callParams = new ShenyuGrpcCallRequest();\n        callParams.setMethodDescriptor(jsonMarshallerMethodDescriptor);\n        callParams.setChannel(channel);\n        callParams.setCallOptions(callOptions);\n        callParams.setResponseObserver(streamObserver);\n        callParams.setRequests(jsonRequestList);\n        \n        try {\n            this.invoke(callParams).get();\n        } catch (InterruptedException e) {\n            // InterruptedExceptions should never be ignored in the code.\n            // InterruptedExceptions should either be rethrown - immediately or after cleaning up the method’s state -\n            // or the thread should be re-interrupted by calling Thread.interrupt() even if this is supposed to be a single-threaded application.\n            // Any other course of action risks delaying thread shutdown and loses the information\n            // that the thread was interrupted - probably without finishing its task.\n            LOG.error(\"Grpc plugin invoke method is exception, Will cause the thread to be interrupted\");\n            Thread.currentThread().interrupt();\n            throw new ShenyuGrpcException(\"Caught exception while waiting for rpc :{ \" + e.getMessage() + \"}\", e);\n        } catch (ExecutionException e) {\n            throw new ShenyuGrpcException(\"Caught exception while waiting for rpc :{ \" + e.getMessage() + \"}\", e);\n        }\n        return CompletableFuture.completedFuture(shenyuGrpcResponse);\n    }\n    \n    /**\n     * Grpc call.\n     *\n     * @param callParams callParams\n     * @return ListenableFuture future\n     */\n    public ListenableFuture<Void> invoke(final ShenyuGrpcCallRequest callParams) {\n        MethodDescriptor.MethodType methodType = callParams.getMethodDescriptor().getType();\n        List<DynamicMessage> requestList = callParams.getRequests();\n        \n        StreamObserver<DynamicMessage> responseObserver = callParams.getResponseObserver();\n        CompleteObserver<DynamicMessage> doneObserver = new CompleteObserver<>();","sourceCodeStart":86,"sourceCodeEnd":122,"githubUrl":"https://github.com/apache/shenyu/blob/567142e07261b3e615ae8850b30f4421f455cc5d/shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-rpc/shenyu-plugin-grpc/src/main/java/org/apache/shenyu/plugin/grpc/client/ShenyuGrpcClient.java#L86-L122","documentation":"ShenyuGrpcClient.call waits on a Future for the gRPC response. An InterruptedException is handled by re-interrupting the thread and throwing ShenyuGrpcException('Caught exception while waiting for rpc ...') wrapping the cause, so callers get a consistent gateway exception when the blocking wait fails.","triggerScenarios":"The thread blocked on future.get() inside call() is interrupted — typically by gateway timeout/dispatcher cancellation or shutdown — or an ExecutionException occurs because the underlying gRPC invocation failed.","commonSituations":"Client disconnects or request times out and the reactive pipeline cancels the work; gateway shutdown while gRPC calls are in flight; upstream gRPC server error surfacing via ExecutionException.","solutions":["Read the wrapped cause (e.getCause()) to find the real gRPC failure (deadline exceeded, UNAVAILABLE, etc.).","Check gRPC server health/connectivity if the cause is a transport error (UNAVAILABLE, connection refused).","Increase the gRPC deadline/timeout config if long-running calls are being cancelled.","Avoid shutting down or undeploying the gateway while calls are in flight; drain traffic first."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    return shenyuGrpcClient.call(request);\n} catch (ShenyuGrpcException e) {\n    Throwable root = e.getCause();\n    LOG.error(\"grpc rpc wait failed, root cause: {}\", root == null ? e : root.getMessage());\n    return errorResponse(exchange, HttpStatus.GATEWAY_TIMEOUT);\n}","preventionTips":["Set sane gRPC deadlines so hung calls fail fast instead of being interrupted by cancellation.","Monitor gateway shutdowns/cancellations during in-flight rpc calls.","Log and alert on e.getCause() to distinguish interruption vs. upstream failure.","Ensure health checks keep upstream gRPC servers reachable."],"tags":["grpc","thread-interrupted","rpc","timeout"],"backgroundTag":"thread-interrupted","analyzedSha":"567142e07261b3e615ae8850b30f4421f455cc5d","analyzedAt":"2026-09-12T10:08:21.293Z","contentChangedAt":"2026-09-12T10:08:21.293Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}