fix: NotificationListener 수신자 Null-safe 방어 로직 추가

This commit is contained in:
pray4skylark
2026-10-02 13:55:39 +09:00
parent f41f33545a
commit 5ada8f301a
@@ -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)