Add FailureAnalyzer for missing GrpcSecurity in servlet mode#340
Add FailureAnalyzer for missing GrpcSecurity in servlet mode#340dsyer merged 1 commit intospring-projects:mainfrom
Conversation
Provide a clear startup failure analysis when GrpcSecurity is requested while the gRPC server is running in servlet mode. Closes: spring-projectsgh-328 Signed-off-by: Andrey Litvitski <andrey1010102008@gmail.com>
|
I am also open to any suggestions regarding messages in |
| @Override | ||
| protected @Nullable FailureAnalysis analyze(Throwable rootFailure, NoSuchBeanDefinitionException cause) { | ||
| if (!isMissingGrpcSecurity(cause) || !isActuallyServletMode()) { | ||
| return null; | ||
| } | ||
| return new FailureAnalysis(getDescription(), getAction(), cause); | ||
| } |
There was a problem hiding this comment.
We want to call the current analyzer if and only if the thrown exception is related to GrpcSecurity and when the spring.grpc.server.servlet.enabled option is enabled and, accordingly, GrpcServlet is present in the path.
BTW, I'm not entirely sure whether GrpcServlet is always in the path or not, you can correct me if this is not the case, then we can simplify the check in isActuallyServletMode a little.
There was a problem hiding this comment.
Depends what you mean by "always" doesn't it? If the failure analyzer is relevant then it will be.
There was a problem hiding this comment.
I was referring to the situation where a user includes a starter, which in turn pulls in io.grpc.grpc-netty or io.grpc.grpc-servlet-jakarta.
Basically, checking for the existence of the GrpcServlet, and therefore checking whether it's in the path, is justified.
Provide a clear startup failure analysis when
GrpcSecurityis requested while the gRPC server is running in servlet mode.Closes: gh-328