From 3c15eca2c9ac6f8e9ba37a624cb19cc3c8782402 Mon Sep 17 00:00:00 2001 From: Oleg Zhurakousky Date: Thu, 22 Feb 2024 15:40:28 +0100 Subject: [PATCH] Fix executor termination in StreamBridge --- .../springframework/cloud/stream/function/StreamBridge.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/core/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/function/StreamBridge.java b/core/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/function/StreamBridge.java index 7225f9cad..03f91359c 100644 --- a/core/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/function/StreamBridge.java +++ b/core/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/function/StreamBridge.java @@ -327,14 +327,12 @@ public final class StreamBridge implements StreamOperations, SmartInitializingSi @Override public void destroy() throws Exception { + this.executorService.shutdown(); if (!this.executorService.awaitTermination(10000, TimeUnit.MILLISECONDS)) { logger.warn("Failed to terminate executor. Terminating current tasks."); this.executorService.shutdownNow(); } - else { - this.executorService.shutdown(); - } - + this.executorService = null; this.async = false; channelCache.keySet().forEach(bindingService::unbindProducers);