From da439e714463757652bc08519c0df892dbb1a09f Mon Sep 17 00:00:00 2001 From: Jon Chambers Date: Thu, 21 May 2026 10:24:52 -0400 Subject: [PATCH] Guard against `NullPointerExceptions` when getting details from a `GoogleJsonResponseException` --- .../subscriptions/GooglePlayBillingManager.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/subscriptions/GooglePlayBillingManager.java b/service/src/main/java/org/whispersystems/textsecuregcm/subscriptions/GooglePlayBillingManager.java index 4770e4c06..b899fe81a 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/subscriptions/GooglePlayBillingManager.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/subscriptions/GooglePlayBillingManager.java @@ -14,7 +14,6 @@ import com.google.api.services.androidpublisher.AndroidPublisherRequest; import com.google.api.services.androidpublisher.AndroidPublisherScopes; import com.google.api.services.androidpublisher.model.AutoRenewingPlan; import com.google.api.services.androidpublisher.model.Money; -import com.google.api.services.androidpublisher.model.OfferDetails; import com.google.api.services.androidpublisher.model.SubscriptionPurchaseLineItem; import com.google.api.services.androidpublisher.model.SubscriptionPurchaseV2; import com.google.api.services.androidpublisher.model.SubscriptionPurchasesAcknowledgeRequest; @@ -335,9 +334,14 @@ public class GooglePlayBillingManager implements SubscriptionPaymentProcessor { if (e.getStatusCode() == Response.Status.TOO_MANY_REQUESTS.getStatusCode()) { throw new RateLimitExceededException(null); } - final String details = e instanceof GoogleJsonResponseException - ? ((GoogleJsonResponseException) e).getDetails().toString() - : ""; + + final String details; + + if (e instanceof GoogleJsonResponseException googleJsonResponseException && googleJsonResponseException.getDetails() != null) { + details = googleJsonResponseException.getDetails().toString(); + } else { + details = ""; + } final String message = String.format("Unexpected HTTP status code %s from androidpublisher: %s", e.getStatusCode(), details);