From 5ada8f301abe128b7984e99bb61e25570ff26e89 Mon Sep 17 00:00:00 2001 From: pray4skylark Date: Fri, 2 Oct 2026 13:55:39 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20NotificationListener=20=EC=88=98?= =?UTF-8?q?=EC=8B=A0=EC=9E=90=20Null-safe=20=EB=B0=A9=EC=96=B4=20=EB=A1=9C?= =?UTF-8?q?=EC=A7=81=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/srsystem/listener/NotificationListener.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/backend/src/main/java/com/srsystem/listener/NotificationListener.java b/backend/src/main/java/com/srsystem/listener/NotificationListener.java index f4e991d..cb5751d 100644 --- a/backend/src/main/java/com/srsystem/listener/NotificationListener.java +++ b/backend/src/main/java/com/srsystem/listener/NotificationListener.java @@ -29,8 +29,16 @@ public class NotificationListener { @Async @TransactionalEventListener public void handleNotification(NotificationEvent event) { - Employee recipient = employeeRepository.findById(event.getRecipientId()) - .orElseThrow(() -> new BusinessException(ErrorCode.EMPLOYEE_NOT_FOUND)); + if (event == null || event.getRecipientId() == null) { + 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() .user(recipient)