Fix npe in MessageSender (#120)

This commit is contained in:
Pavel Popov 2020-07-13 15:48:18 +03:00 committed by GitHub
parent 9df803b90c
commit 3bd2fe516b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -14,6 +14,7 @@ import org.apache.http.HttpStatus;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.Callable;
@Slf4j
@ -47,7 +48,7 @@ public abstract class MessageSender<M extends Message> implements Callable<Messa
queueStatus.setSuccess(true);
} catch (Exception e) {
if (currentMessage != null)
log.warn("Couldn't send message with id {} {} to hook {}. We'll try to resend it", currentMessage.getId(), currentMessage, queueStatus.getQueue().getHook(), e);
log.warn("Couldn't send message with id {} {} to hook {}. We'll try to resend it", currentMessage.getId(), currentMessage, Optional.ofNullable(queueStatus).map(QueueStatus::getQueue).map(Queue::getHook), e);
queueStatus.setSuccess(false);
}
return queueStatus;