Skip to content

Commit a1781bd

Browse files
tjleingThomas Leing
andauthored
Fix Pinpoint NullPointerException (#3007)
Co-authored-by: Thomas Leing <[email protected]>
1 parent e0a5771 commit a1781bd

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

aws-android-sdk-pinpoint/src/main/java/com/amazonaws/mobileconnectors/pinpoint/targeting/notification/NotificationClientBase.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,12 +306,16 @@ private boolean initClassesAndMethodsByReflection() {
306306
notificationChannelClass = Class.forName("android.app.NotificationChannel"); //API Level 26
307307
}
308308
if (!buildMethodsByReflection()) {
309+
// make sure that we don't try to use the notificationBuilderClass
310+
notificationBuilderClass = null;
309311
// fall back to creating the legacy notification.
310312
return false;
311313
}
312314
return true;
313315
} catch (final ClassNotFoundException ex) {
314316
log.debug("Failed to get notification builder classes by reflection : " + ex.getMessage(), ex);
317+
// make sure that we don't try to use the notificationBuilderClass
318+
notificationBuilderClass = null;
315319
return false;
316320
}
317321
}
@@ -399,6 +403,9 @@ private boolean registerDefaultNotificationChannel() {
399403
} catch (final NoSuchMethodException ex) {
400404
log.debug("Failed to get notification channel method getId by reflection. : " + ex.getMessage(), ex);
401405
return false;
406+
} catch (final NullPointerException ex) {
407+
log.debug("Reflected methods not successfully created. :" + ex.getMessage(), ex);
408+
return false;
402409
}
403410
}
404411

@@ -589,6 +596,10 @@ private Notification createNotification(final int iconResId, final String title,
589596
log.debug("Exception while instantiating notification builder or bigTextStyle or bigPictureStyle classes. : " + ex.getMessage(),
590597
ex);
591598
return createLegacyNotification(iconResId, title, contentText, contentIntent);
599+
} catch (final NullPointerException ex) {
600+
log.debug("Reflected methods not successfully created. : " + ex.getMessage(),
601+
ex);
602+
return createLegacyNotification(iconResId, title, contentText, contentIntent);
592603
}
593604

594605
try {

0 commit comments

Comments
 (0)