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)