Skip to content

NullPointerException when using cloud messaging #1081

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

Open
edonelezovic opened this issue Feb 28, 2025 · 3 comments
Open

NullPointerException when using cloud messaging #1081

edonelezovic opened this issue Feb 28, 2025 · 3 comments

Comments

@edonelezovic
Copy link

edonelezovic commented Feb 28, 2025

  • Library version: 9.4.3
  • Firebase Product: cloud messaging

When we are sending messages in bulk to devices using device specific tokens, we randomly get the error below:

java.util.concurrent.ExecutionException: java.lang.NullPointerException
	at com.google.common.util.concurrent.AbstractFuture.getDoneValue(AbstractFuture.java:595)
	at com.google.common.util.concurrent.AbstractFuture.get(AbstractFuture.java:574)
	at com.google.common.util.concurrent.FluentFuture$TrustedFuture.get(FluentFuture.java:91)
	at com.google.common.util.concurrent.ForwardingFuture.get(ForwardingFuture.java:67)
	at businessLayer.Messaging.sendPush(Messaging.java:777)
...

We are using the method sendEachAsync:
BatchResponse firebaseResponse = FirebaseMessaging.getInstance(firebaseApp).sendEachAsync(firebaseMessages, pushDryRun).get();

Besides the error showing up randomly when we are sending the messages, it seems that in older version of the library (<= 9.3.0), that the error is:

java.util.concurrent.ExecutionException: com.google.firebase.messaging.FirebaseMessagingException: com.google.firebase.messaging.FirebaseMessaging
	at com.google.common.util.concurrent.AbstractFuture.getDoneValue(AbstractFuture.java:594)
	at com.google.common.util.concurrent.AbstractFuture.get(AbstractFuture.java:573)
	at com.google.common.util.concurrent.FluentFuture$TrustedFuture.get(FluentFuture.java:91)
	at com.google.common.util.concurrent.ForwardingFuture.get(ForwardingFuture.java:67)
	at businessLayer.Messaging.sendPush(Messaging.java:777)
...

The problem for us is that it seems that this error started showing up randomly last month.
At least some messages seem to be sent, because we have info that users are seeing and clicking on the notifications.
So, it seems that we are correctly calling the procedure.
Any help would be welcomed.

@google-oss-bot
Copy link

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

@edonelezovic
Copy link
Author

edonelezovic commented Mar 3, 2025

We have also started receiving a new error in the same method:

java.util.concurrent.ExecutionException: java.lang.ArrayIndexOutOfBoundsException: arraycopy: length -24 is negative
	at com.google.common.util.concurrent.AbstractFuture.getDoneValue(AbstractFuture.java:596)
	at com.google.common.util.concurrent.AbstractFuture.get(AbstractFuture.java:575)
	at com.google.common.util.concurrent.FluentFuture$TrustedFuture.get(FluentFuture.java:91)
	at com.google.common.util.concurrent.ForwardingFuture.get(ForwardingFuture.java:67)
	at businessLayer.Messaging.sendPush(Messaging.java:777)
...

@edonelezovic
Copy link
Author

edonelezovic commented Apr 2, 2025

We made sure the Messages are not null and not empty.

Downgrading didn't prevent an error, but it was a different error, probably isn't handled in the newer version.

Older version:
java.util.concurrent.ExecutionException: com.google.firebase.messaging.FirebaseMessagingException: com.google.firebase.messaging.FirebaseMessaging

Newer version:
java.util.concurrent.ExecutionException: java.lang.NullPointerException

We needed to implement our custom solution using the Firebase Cloud Messaging API, because we didn't know which push messages were being sent and which weren't when the above method returned an exception. We knew that some of the messages were being sent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants