Skip to content

Fix: Add null check for notification object in ReplaceNotificationEvent#388

Open
prjanitor wants to merge 1 commit intodahliaOS:mainfrom
prjanitor:prjanitor/b4ce01729ca15ba5c37185e7e63a203cd0f73815
Open

Fix: Add null check for notification object in ReplaceNotificationEvent#388
prjanitor wants to merge 1 commit intodahliaOS:mainfrom
prjanitor:prjanitor/b4ce01729ca15ba5c37185e7e63a203cd0f73815

Conversation

@prjanitor
Copy link
Copy Markdown

Summary

This PR adds a null check for the notification object in the ReplaceNotificationEvent case of the _notificationEventListener method.

Problem

The ReplaceNotificationEvent case was calling onNotificationReplaced(oldId, id) without verifying that the new notification exists. If the notification service returns null for a non-existent notification ID, this could lead to unexpected behavior or crashes downstream.

Solution

Added the same null-check pattern used in ShowNotificationEvent:

  • Retrieve the notification using service.getNotification(id)
  • Return early if the notification is null
  • Only call onNotificationReplaced if the notification exists

Testing

This change ensures consistency with the existing null-check pattern in ShowNotificationEvent and prevents potential null pointer issues when notification IDs are invalid or stale.


This PR was generated by PRJanitor — an automated tool that finds and fixes small bugs in open-source projects.

We respect your contribution guidelines — if your project doesn't accept bot PRs, we won't send more. You can also add a .github/prjanitor.yml file with enabled: false to opt out explicitly.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant