Shutdown DLQ segments flusher only if it has been started (#15649) (#15656)

In DLQ unit testing sometime the DLQ writer is started explicitly without starting the segments flushers. In such cases the test 's logs contains exceptions which could lead to think that the test fails silently.

Avoid to invoke scheduledFlusher's shutdown when it's not started (such behaviour is present only in tests).

(cherry picked from commit eddd91454f)

Co-authored-by: Andrea Selva <selva.andre@gmail.com>
This commit is contained in:
github-actions[bot] 2023-12-05 12:58:48 +01:00 committed by GitHub
parent dae1585325
commit 4292ef9179
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -254,7 +254,10 @@ public final class DeadLetterQueueWriter implements Closeable {
}
try {
flushScheduler.shutdown();
// flushScheduler is null only if it's not explicitly started, which happens only in tests.
if (flushScheduler != null) {
flushScheduler.shutdown();
}
} catch (Exception e) {
logger.warn("Unable shutdown flush scheduler, ignoring", e);
}