[fix][broker]optimize the shutdown sequence of broker service when it close
@@ -448,7 +448,11 @@ public class PulsarService implements AutoCloseable, ShutdownService {
(long) (GRACEFUL_SHUTDOWN_TIMEOUT_RATIO_OF_TOTAL_TIMEOUT
* getConfiguration()
.getBrokerShutdownTimeoutMs())));
-
+ // close protocol handler before closing broker service
+ if (protocolHandlers != null) {
+ protocolHandlers.close();
+ protocolHandlers = null;
+ }
List<CompletableFuture<Void>> asyncCloseFutures = new ArrayList<>();
if (this.brokerService != null) {
@@ -528,11 +532,6 @@ public class PulsarService implements AutoCloseable, ShutdownService {
offloadersCache.close();
- if (protocolHandlers != null) {
- protocolHandlers.close();
- protocolHandlers = null;
- }
-
if (coordinationService != null) {
coordinationService.close();
}
