fix: NotificationListener 수신자 Null-safe 방어 로직 추가
This commit is contained in:
@@ -29,8 +29,16 @@ public class NotificationListener {
|
|||||||
@Async
|
@Async
|
||||||
@TransactionalEventListener
|
@TransactionalEventListener
|
||||||
public void handleNotification(NotificationEvent event) {
|
public void handleNotification(NotificationEvent event) {
|
||||||
Employee recipient = employeeRepository.findById(event.getRecipientId())
|
if (event == null || event.getRecipientId() == null) {
|
||||||
.orElseThrow(() -> new BusinessException(ErrorCode.EMPLOYEE_NOT_FOUND));
|
log.warn("NotificationEvent is null or recipientId is missing: {}", event);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Employee recipient = employeeRepository.findById(event.getRecipientId()).orElse(null);
|
||||||
|
if (recipient == null) {
|
||||||
|
log.warn("Recipient employee not found for id: {}. Notification skipped.", event.getRecipientId());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Notification notification = Notification.builder()
|
Notification notification = Notification.builder()
|
||||||
.user(recipient)
|
.user(recipient)
|
||||||
|
|||||||
Reference in New Issue
Block a user