Skip to content

fix: fall back to current time when alert dateCreated is null in EmailAlertNotifyStrategy (#6866) - #6964

Open
juicewcode wants to merge 1 commit into
apache:masterfrom
juicewcode:fix/6866-email-alert-null-datecreated-npe
Open

fix: fall back to current time when alert dateCreated is null in EmailAlertNotifyStrategy (#6866)#6964
juicewcode wants to merge 1 commit into
apache:masterfrom
juicewcode:fix/6866-email-alert-null-datecreated-npe

Conversation

@juicewcode

Copy link
Copy Markdown
Contributor

Fixes #6866

Summary

EmailAlertNotifyStrategy.buildAlertHtmlTemplate null-guarded the wrong variable: Objects.isNull(alert) is dead code (alert already dereferenced). When dateCreated is null, alertTime stayed null and SimpleDateFormat.format() threw NPE, crashing the email notify path. Now guards alertTime and falls back to new Date(), matching AbstractAlertNotifyHandler.

Added EmailAlertNotifyStrategyTest:

  • null dateCreated → no AlertNoticeException, falls back to current time, email sent
  • fixed dateCreated → formatted exactly, email sent

Make sure that:

  • You have read the contribution guidelines.
  • You submit test cases (unit or integration tests) that back your changes.
  • Your local test passed ./mvnw clean install -Dmaven.javadoc.skip=true.

…ilAlertNotifyStrategy (apache#6866)

  buildAlertHtmlTemplate null-guarded Objects.isNull(alert) (dead code) instead
  of alertTime, so a null dateCreated left alertTime null and format() threw NPE,
  breaking the email notify path. Guard alertTime and fall back to new Date();
  adds EmailAlertNotifyStrategyTest for the null and normal paths.
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.

[BUG] EmailAlertNotifyStrategy null-guards the wrong variable (alert not alertTime) — NPE when dateCreated is null

1 participant