Null pointer exception while setting a deadline on a stub
See original GitHub issueI posted this on the grpc mailing list too, reposting here because I’m not sure what the right forum is.
I followed directions in this issue to add deadlines to a RPC. But I get a null pointer error.
java.lang.NullPointerException at io.grpc.stub.AbstractStub.withDeadlineAfter(AbstractStub.java:117)
My code is
blockingStub.withDeadlineAfter(10, TimeUnit.DAYS).doSomething()
Can the callOptions here be null by any chance?
* Returns a new stub with a deadline that is after the given {@code duration} from now.
*
* @see CallOptions#withDeadlineAfter
*/
public final S withDeadlineAfter(long duration, TimeUnit unit) {
return build(channel, callOptions.withDeadlineAfter(duration, unit));
}
I’m using the code generated by the protobuf java plugin and the constructor initializes callOptions to CallOptions.DEFAULT, so I’m not sure what’s wrong here. Anyone else faced this issue? I’m using protobuf-gradle-plugin:0.7.6.
* Constructor for use by subclasses, with the default {@code CallOptions}.
*
* @param channel the channel that this stub will use to do communications
*/
protected AbstractStub(Channel channel) {
this(channel, CallOptions.DEFAULT);
}
Issue Analytics
- State:
- Created 7 years ago
- Comments:7
Top Results From Across the Web
Mockito - NullpointerException when stubbing Method
The reason why is that any() returns a generic object reference. This object is unboxed to an integer, so the generic type is...
Read more >How to avoid null pointer exception in Java - Javatpoint
Null Pointer Exception is a kind of run time exception that is thrown when the java program attempts to use the object reference...
Read more >PK77063: NULLPOINTEREXCEPTION IN SETTIME ... - IBM
When referencing a date component and specifying a format string a NullPointerException may be thrown if the date component has not been assigned...
Read more >NullPointerException (Java Platform SE 8 ) - Oracle Help Center
Thrown when an application attempts to use null in a case where an object is required. These include: Calling the instance method of...
Read more >Misunderstanding of Null Pointer Exception in unit test
Now I am trying to code unit test for service layer methods. I set this memberRepository.findAll() >> mockMembers as a mock in test...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@shishir127 no worries 😃. Only thing, next time you report a bug,please include the gRPC version and extra points if you also include a reproducer!
Thanks
@buchgr So I dug a bit deeper and realized mocks were used somewhere during a test setup which was definitely the cause for the NPE 😞 😓 . Sorry for the trouble.