fix: NotificationListener 수신자 Null-safe 방어 로직 추가
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user