Skip to content

Occasional Pager NullPointerException from recurly-java-client #278

Description

@gstanek

Describe the bug

We see occasional NullPointerExceptions propagated out of the recurly-client-java. The relevant observed stack trace is:

java.util.concurrent.ExecutionException: java.lang.NullPointerException: Cannot invoke "com.recurly.v3.Pager.getNext()" because "pager" is null
	at java.base/java.util.concurrent.FutureTask.report(FutureTask.java:122)
	at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:191)
	at com.sproutsocial.revenue.internal.account.v1.service.AccountServiceImpl.getAccountResponse(AccountServiceImpl.java:872)
	at com.sproutsocial.revenue.internal.account.v1.service.AccountServiceImpl.getAccountsBatches(AccountServiceImpl.java:281)
	at com.sproutsocial.revenue.internal.account.v1.service.AccountServiceImpl.lambda$getAccounts$0(AccountServiceImpl.java:239)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at com.sproutsocial.revenue.commons.multithreading.MdcThreadPoolExecutor$1.run(MdcThreadPoolExecutor.java:99)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.lang.Thread.run(Thread.java:840)
	Caused by: java.lang.NullPointerException: Cannot invoke "com.recurly.v3.Pager.getNext()" because "pager" is null
	at com.recurly.v3.Pager.clone(Pager.java:93)
	at com.recurly.v3.Pager.getNextPage(Pager.java:89)
	at com.sproutsocial.revenue.internal.client.RecurlyClientImpl.executePaginatedQueryInEnv(RecurlyClientImpl.java:740)
	at com.sproutsocial.revenue.internal.client.RecurlyClientImpl.getPaginatedEntitiesById(RecurlyClientImpl.java:685)
	at com.sproutsocial.revenue.internal.client.RecurlyClientImpl.listInvoicesByAccountCode(RecurlyClientImpl.java:536)
	at com.sproutsocial.revenue.internal.account.v1.service.AccountServiceImpl.lambda$getAccountResponse$6(AccountServiceImpl.java:835)
	... 5 common frames omitted

Specifically of note:

	Caused by: java.lang.NullPointerException: Cannot invoke "com.recurly.v3.Pager.getNext()" because "pager" is null
	at com.recurly.v3.Pager.clone(Pager.java:93)
	at com.recurly.v3.Pager.getNextPage(Pager.java:89)

Our theory is some sort of network exception prevents this.client.makeRequest from returning an instantiated pager object, leading to the NullPointerException within the clone method.

To Reproduce

This does not happen consistently or often (the rate has been a few times a month). Given the stack trace, this bug appears to be entirely within the context of the recurly-client-java code.

Expected behavior

The recurly java client does not encounter NullPointerExceptions, causing failed transactions.

Your Environment

  • Which version of this library are you using?
    <dependency>
      <groupId>com.recurly.v3</groupId>
      <artifactId>api-client</artifactId>
      <version>4.51.0</version>
      <exclusions>
        <exclusion>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-compiler-plugin</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
  • Which version of the language are you using?
    Java 17

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug?Potentially a bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions