Aias00 opened a new issue, #6866:
URL: https://github.com/apache/shenyu/issues/6866

   ## Description
   In `buildAlertHtmlTemplate`, line 83 fetches `Date alertTime = 
alert.getDateCreated()`. Line 84 checks `if (Objects.isNull(alert))` — but 
`alert` has already been dereferenced on lines 81 (`alert.getContent()`) and 83 
(`alert.getDateCreated()`), so this null check is dead (if alert were null, it 
already NPE'd). The intent was to check `Objects.isNull(alertTime)` — i.e., 
fall back to `new Date()` when the alert's `dateCreated` is null. When 
`dateCreated` is null, `alertTime` stays null and line 87 
`simpleDateFormat.format(alertTime)` throws NPE.
   
   ## Location
   - 
`shenyu-alert/src/main/java/org/apache/shenyu/alert/strategy/EmailAlertNotifyStrategy.java:83-87`
   
   ## Impact
   An alert with a null `dateCreated` (e.g. a manually-triggered or 
programmatic alert without a timestamp) crashes the email notification path 
with NPE instead of sending the alert.
   
   ## Suggested fix
   Change line 84 to `if (Objects.isNull(alertTime)) { alertTime = new Date(); 
}`.
   
   ## Related existing
   None — N56 covers `AlertDispatchServiceImpl` cache staleness; this is a 
different file and a wrong-variable defect.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to