-
Notifications
You must be signed in to change notification settings - Fork 433
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
5.0.0 to 5.1.4 changes status exception behaviour #373
Comments
In this case, the This is a debugging infomation for the following section: Lines 28 to 29 in b6f9a75
|
How do I reproduce this ? Just |
Here is a minimal project that helps to reproduce the issue. I found that the interceptor works and the behavior changes when |
@m-miyano, I've added more test to mimic your scenario, please try to upgrade to repositories {
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots" } // for snapshot builds
}
dependencies {
implementation 'io.github.lognet:grpc-spring-boot-starter:5.1.5-SNAPSHOT'
} |
Thanks @m-miyano , I will add streaming case as well. |
@jorgerod , you mean you have |
Hi @jvmlet This case fails when cause is added to exception and as @m-miyano says when there is the This controller return: Status code: 13 INTERNAL @GRpcService
public class MyController extends ProductEndPointGrpc.ProductEndPointImplBase {
@Override
public void findAllProducts(Empty request, StreamObserver<Service.ProductResponseList> responseObserver) {
responseObserver.onError(Status.NOT_FOUND
.withCause(new IllegalArgumentException())
.asRuntimeException());
}
} And without @GRpcService
public class MyController extends ProductEndPointGrpc.ProductEndPointImplBase {
@Override
public void findAllProducts(Empty request, StreamObserver<Service.ProductResponseList> responseObserver) {
responseObserver.onError(Status.NOT_FOUND
.asRuntimeException());
}
} |
The issue still persists on version 5.1.5. Removing the cause is a bandaid fix for now. Is there any plans to fix this in the next version? |
We are also facing the same problem. We are also waiting for the fix |
Just chiming in here and that this issue seems to come into play only when the Error Handling functionality is in use (@GrpcAdvice/@GrpcErrorHandler). We don't directly use it, but it appears like spring autoconfiguration is creating a default handler whenever the It would be helpful if there were a simple way to disable this bean, or the GRpcValidationConfiguration entirely. Right now it's brought in as part of auto configuration and is only conditional on the presence of the Clearly allowing this to work as expected would be preferred. Perhaps by passing in an "unhandled status" to the |
Also, one possible approach to fix the behavior is a server interceptor that conditionally manipulates the status. This mostly keeps the custom error handling facility and avoids needing to strip the cause (though it may result in some extra nested cause chains.: In kotlin -- @Component
// We want this interceptor to adjust any statuses seen by all interceptors, and thus be as close to the application
// side of request handling as possible. An explicit LOWEST_PRECEDENCE value will place it as close to the
// application handling logic as possible.
@GRpcGlobalInterceptor
@Order(Ordered.LOWEST_PRECEDENCE)
class LogNetStatusHandlingFixInterceptor : ServerInterceptor {
override fun <ReqT : Any, RespT : Any> interceptCall(
serverCall: ServerCall<ReqT, RespT>,
metadata: Metadata,
serverCallHandler: ServerCallHandler<ReqT, RespT>,
): ServerCall.Listener<ReqT> {
return serverCallHandler.startCall(
object : SimpleForwardingServerCall<ReqT, RespT>(serverCall) {
override fun close(
status: Status?,
trailers: Metadata?,
) {
super.close(status?.withAdjustedCause(), trailers)
}
},
metadata,
)
}
companion object {
private val logger = KotlinLogging.logger {}
/**
* @return a [Status] where the [cause] is [this] status as an exception if necessary to avoid the LogNet
* starter's handling behavior.
*/
private fun Status.withAdjustedCause() =
// If the status has no cause specified, or has a signature similar to the status returned when an unhandled
// exception is caught, then simply pass through the status. In the null case, the lognet error handling
// doesn't come into play. In the unhandled status condition, lognet error handlers should have a chance to
// perform custom handling.
if (cause == null || (code == Status.Code.UNKNOWN && description.isNullOrBlank())) {
this
} else {
withCause(this.asException())
}
}
}
|
Hello,
I tried to update from v5.0.0 to v5.1.4, I observed a change in the status code handling when an exception occurs.
My service uses streaming. Here's a snippet of the relevant code:
In the context of
onFailure
, passStatusRuntimeException
toobserver.onError
.simplified code snippet below:
In v5.0.0
In v5.1.4
The issue below mentions a problem with
StatusException
, but the issue also occurs withStatusRuntimeException
.#371
It appears that the newly introduced passage through the
failureHandlingSupport.closeCall
method is causing the impact.grpc-spring-boot-starter/grpc-spring-boot-starter/src/main/java/org/lognet/springboot/grpc/recovery/GRpcExceptionHandlerInterceptor.java
Lines 48 to 53 in b6f9a75
If I've implemented something contrary to your intentions, please let me know.
Thank you always for your support.
The text was updated successfully, but these errors were encountered: