question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Null pointer exception while setting a deadline on a stub

See original GitHub issue

I 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:closed
  • Created 7 years ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
buchgrcommented, Aug 11, 2016

@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

0reactions
shishir127commented, Aug 10, 2016

@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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found