-
Notifications
You must be signed in to change notification settings - Fork 434
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
Security interceptor doesn't propagate the original exception #357
Comments
Please read this section carefully |
btw, what is the order of your interceptors ? |
Thank you for the swift response. The mapped interceptors resolve to the following:
It is not a checked exception but an unchecked exception. I read the documentation like I should not do anything special about that right? I have tried with a checked exception and calling the This is my handler method: @GRpcExceptionHandler
public Status tokenExpiredExceptionHandler(MyRuntimeException e, GRpcExceptionScope scope) {
log.info("My Error Handler");
return Status.ABORTED;
} The method is added to the available error handlers, and it is also selected but not invoked with the right exception.
|
The error handling interceptor should be executed before authentication interceptor, have you set your custom order of interceptors ? |
Do you have your own custom interceptor ? Where do you throw the exception from ? |
Have not specified the order so it's using default. I did try to specify with this: grpc:
recovery:
interceptor-order: 0
security:
auth:
interceptor-order: 10 But same result. The server code is stripped down to this now: @GRpcService
@Slf4j
public class GrpcDataEndpoint extends UploadDataServiceGrpc.UploadDataServiceImplBase {
static class MyRuntimeException extends RuntimeException {
public MyRuntimeException(String message) {
super(message);
}
}
@GRpcExceptionHandler
public Status tokenExpiredExceptionHandler(MyRuntimeException npe, GRpcExceptionScope scope) {
log.info("My Error Handler 2");
return Status.ABORTED;
}
@Override
public StreamObserver<UploadDataRequest> uploadData(StreamObserver<UploadDataResponse> responseObserver) {
return new StreamObserver<>() {
@Override
public void onNext(UploadDataRequest value) {
throw new MyRuntimeException("test");
}
@Override
public void onError(Throwable t) {
log.error("Error: {}", t.getMessage());
}
@Override
public void onCompleted() {
responseObserver.onCompleted();
}
};
}
} |
I'll try to reproduce bidi-stream call in test |
I will try to create a minimal test project for you to see |
Was able to reproduce, will be fixed (soon). |
Sounds great. Thank you |
Yup it's working with the snapshot version. |
|
Using the starter v 5.1.1, with bearer token authentication enabled like described:
This all works gr8. However, when i throw a simple exception extenting runtime exception from the onNext method, the following error occurs
Caught exception while handling exception using method public ....
java.lang.IllegalArgumentException: argument type mismatch
So it does find the correct method I have specified with
@GRpcExceptionHandler
but invokes it with the wrong parameters.What I have been able to figure out, is that it is wrapped in a
AuthenticationException
on this lineThus, it does fint the correct method, when searching for available handlers, but it is not invoked with the cause, which is the exception i throw that also mathes the execption handler.
Does this have something to do with the fact that it is caught in the
SecurityInterceptor
and I may have set things up the wrong way?Any pointers would be greatly appreciated.
I can work around it, by creating an exception handler that takes
RuntimeException
and then just check the type of the cause in there, but that doesn't seem like the intended way to do it :)The text was updated successfully, but these errors were encountered: