Skip to content

Commit 487f818

Browse files
sdhukapoojamat
andauthored
fix: Catch NPE while creating notification (#2588)
Co-authored-by: poojamat <[email protected]>
1 parent b06b2d5 commit 487f818

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -623,10 +623,13 @@ private Notification createNotification(final int iconResId, final String title,
623623

624624
return (Notification) buildMethod.invoke(notificationBuilder);
625625
} catch (final InvocationTargetException ex) {
626-
log.debug("Can't invoke notification builder methods. : " + ex.getMessage(), ex);
626+
log.error("Can't invoke notification builder methods. : " + ex.getMessage(), ex);
627627
return createLegacyNotification(iconResId, title, contentText, contentIntent);
628628
} catch (final IllegalAccessException ex) {
629-
log.debug("Can't access notification builder methods. : " + ex.getMessage(), ex);
629+
log.error("Can't access notification builder methods. : " + ex.getMessage(), ex);
630+
return createLegacyNotification(iconResId, title, contentText, contentIntent);
631+
} catch (final NullPointerException ex) {
632+
log.error("Can't access notification builder methods. : " + ex.getMessage(), ex);
630633
return createLegacyNotification(iconResId, title, contentText, contentIntent);
631634
}
632635
}
@@ -723,7 +726,7 @@ private boolean displayNotification(
723726
final int requestID = getNotificationRequestId(pinpointObjectId, activityId);
724727

725728
log.debug("Displaying Notification for campaign/journey: " + pinpointObjectId +
726-
" ; activity: " + activityId +
729+
" ; activity: " + activityId +
727730
" ; notification requestId: " + requestID);
728731

729732
new Thread(new Runnable() {

0 commit comments

Comments
 (0)