From 4292ef91793e805dc39bc649f655b901754c39ad Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 5 Dec 2023 12:58:48 +0100 Subject: [PATCH] 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 eddd91454f35a996ea80185399897004d43a8771) Co-authored-by: Andrea Selva --- .../java/org/logstash/common/io/DeadLetterQueueWriter.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/logstash-core/src/main/java/org/logstash/common/io/DeadLetterQueueWriter.java b/logstash-core/src/main/java/org/logstash/common/io/DeadLetterQueueWriter.java index 342c3ce751e..b321005b49b 100644 --- a/logstash-core/src/main/java/org/logstash/common/io/DeadLetterQueueWriter.java +++ b/logstash-core/src/main/java/org/logstash/common/io/DeadLetterQueueWriter.java @@ -254,7 +254,10 @@ public void close() { } 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); }