Move throwOnIllegalState call to drain queue method to prevent improper error logging during worker shutdown

This commit is contained in:
Zach Humpherys 2024-02-19 13:08:28 -08:00
parent a5d1c67660
commit 62061a2d2d

View file

@ -289,7 +289,6 @@ public class PrefetchRecordsPublisher implements RecordsPublisher {
} }
private PrefetchRecordsRetrieved peekNextResult() { private PrefetchRecordsRetrieved peekNextResult() {
throwOnIllegalState();
return publisherSession.peekNextRecord(); return publisherSession.peekNextRecord();
} }
@ -389,6 +388,7 @@ public class PrefetchRecordsPublisher implements RecordsPublisher {
// If there is an event available to drain and if there is at least one demand, // If there is an event available to drain and if there is at least one demand,
// then schedule it for delivery // then schedule it for delivery
if (publisherSession.hasDemandToPublish() && canDispatchRecord(recordsToDeliver)) { if (publisherSession.hasDemandToPublish() && canDispatchRecord(recordsToDeliver)) {
throwOnIllegalState();
subscriber.onNext(recordsToDeliver.prepareForPublish()); subscriber.onNext(recordsToDeliver.prepareForPublish());
recordsToDeliver.dispatched(); recordsToDeliver.dispatched();
lastEventDeliveryTime = Instant.now(); lastEventDeliveryTime = Instant.now();