From 6550dfbef312f1e9c9b2e6a83e17fbca59bc068d Mon Sep 17 00:00:00 2001 From: halibobo1205 Date: Wed, 20 Mar 2024 13:31:53 +0800 Subject: [PATCH] fix(backup/backupServer): make the thread pool close after the netty channel closes --- .../main/java/org/tron/common/backup/socket/BackupServer.java | 2 +- .../test/java/org/tron/common/backup/BackupServerTest.java | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/framework/src/main/java/org/tron/common/backup/socket/BackupServer.java b/framework/src/main/java/org/tron/common/backup/socket/BackupServer.java index 2acf1e12633..67739ac50d2 100644 --- a/framework/src/main/java/org/tron/common/backup/socket/BackupServer.java +++ b/framework/src/main/java/org/tron/common/backup/socket/BackupServer.java @@ -95,7 +95,6 @@ public void initChannel(NioDatagramChannel ch) public void close() { logger.info("Closing backup server..."); shutdown = true; - ExecutorServiceManager.shutdownAndAwaitTermination(executor, name); backupManager.stop(); if (channel != null) { try { @@ -104,6 +103,7 @@ public void close() { logger.warn("Closing backup server failed.", e); } } + ExecutorServiceManager.shutdownAndAwaitTermination(executor, name); logger.info("Backup server closed."); } } diff --git a/framework/src/test/java/org/tron/common/backup/BackupServerTest.java b/framework/src/test/java/org/tron/common/backup/BackupServerTest.java index 34b17ec186f..bab587ef68a 100644 --- a/framework/src/test/java/org/tron/common/backup/BackupServerTest.java +++ b/framework/src/test/java/org/tron/common/backup/BackupServerTest.java @@ -37,8 +37,10 @@ public void tearDown() { Args.clearParam(); } - @Test + @Test(timeout = 60_000) public void test() throws InterruptedException { backupServer.initServer(); + // wait for the server to start + Thread.sleep(1000); } }