-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
@CanIgnoreReturnValue for blocking stub methods returning Empty #11296
base: master
Are you sure you want to change the base?
@CanIgnoreReturnValue for blocking stub methods returning Empty #11296
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, interesting. Yeah, handling this case seems valuable. Although it adds a new direct dependency on errorprone, right? I see grpc-api is exposing errorprone as an API dependency already, but I'm still a bit uncomfortable given how much of a pain dependencies in codegen have been in other cases.
I'm surprised Bazel didn't fail to build; I'd have expected //compiler:java_grpc_library_deps__do_not_reference to need updating. Maybe we don't have any Empty-returning methods being built with Bazel.
Looks like it may be better to put |
The warning is reported as
Using both on the same type would be confusing. |
Right. Remove |
I guess the original intent of annotating However, if method returns Another way to avoid such a warning would be generating the blocking stub method as void. IMHO that would make things even more clear, but would need some code generation options for compatibility. |
Doh. I forgot about that perspective. I was thinking about the methods in AbstractStub and AbstractBlockingStub themselves, particularly all the So one view could be "it's unlikely someone will do an RPC and ignore the response if they actually need the response, but it is very likely someone wants to ignore Empty" and thus "we don't check return values for generated messages." There is harm to checking and there's very little value gained. Dunno how much that resonates with people.
Yeah, I considered mentioning it. I saw it as a "if we knew this from the beginning" sort of thing. ABI makes it annoying to deal with now. But I realize now we are a bit lucky here. #10318 is creating a "v2" blocking stub. We could use void there. We could also avoid the Empty request argument. I'm not certain whether Empty→void won't cause its own problems. But it does seem we can consider it. |
I think the easiest thing here is to just change |
I am not sure about if it's worth generating more classes like in blockingStubV), the corresponding improvements can be applied to the existing stub and configured via options - meaning FileOptions / ServiceOptions / MethodOptions. For example, there could be 2 options related to Empty:
|
Currently IntelliJ IDEA highlights blocking calls as a warning - as
AbstractBlockingStub
is annotated with@CheckReturnValue
.I think as a separate feature, such an annotation can be also adde via method level option, but that would need more discussions.
For the tests - instead we can change return type of an existing method.