From 80d0890952515f9b4c29a306a30858d65955a1ea Mon Sep 17 00:00:00 2001 From: Himshikha Gupta Date: Wed, 25 Sep 2024 15:06:39 +0530 Subject: [PATCH] fixing thread leak in UT Signed-off-by: Himshikha Gupta --- .../gateway/remote/ClusterMetadataManifestTests.java | 9 +++++---- .../gateway/remote/ClusterStateChecksumTests.java | 9 +++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/server/src/test/java/org/opensearch/gateway/remote/ClusterMetadataManifestTests.java b/server/src/test/java/org/opensearch/gateway/remote/ClusterMetadataManifestTests.java index 63993904176a0..09c2933680be3 100644 --- a/server/src/test/java/org/opensearch/gateway/remote/ClusterMetadataManifestTests.java +++ b/server/src/test/java/org/opensearch/gateway/remote/ClusterMetadataManifestTests.java @@ -36,7 +36,7 @@ import org.opensearch.test.OpenSearchTestCase; import org.opensearch.threadpool.TestThreadPool; import org.opensearch.threadpool.ThreadPool; -import org.junit.AfterClass; +import org.junit.After; import java.io.IOException; import java.util.ArrayList; @@ -67,10 +67,11 @@ public class ClusterMetadataManifestTests extends OpenSearchTestCase { - private static final ThreadPool threadPool = new TestThreadPool(ClusterMetadataManifestTests.class.getName()); + private final ThreadPool threadPool = new TestThreadPool(getClass().getName()); - @AfterClass - public static void shutdown() throws Exception { + @After + public void teardown() throws Exception { + super.tearDown(); threadPool.shutdown(); } diff --git a/server/src/test/java/org/opensearch/gateway/remote/ClusterStateChecksumTests.java b/server/src/test/java/org/opensearch/gateway/remote/ClusterStateChecksumTests.java index 31495e259e749..9b98187053a39 100644 --- a/server/src/test/java/org/opensearch/gateway/remote/ClusterStateChecksumTests.java +++ b/server/src/test/java/org/opensearch/gateway/remote/ClusterStateChecksumTests.java @@ -36,7 +36,7 @@ import org.opensearch.test.OpenSearchTestCase; import org.opensearch.threadpool.TestThreadPool; import org.opensearch.threadpool.ThreadPool; -import org.junit.AfterClass; +import org.junit.After; import java.io.IOException; import java.util.EnumSet; @@ -44,10 +44,11 @@ import java.util.Map; public class ClusterStateChecksumTests extends OpenSearchTestCase { - private static final ThreadPool threadPool = new TestThreadPool(ClusterStateChecksumTests.class.getName()); + private final ThreadPool threadPool = new TestThreadPool(getClass().getName()); - @AfterClass - public static void shutdown() throws Exception { + @After + public void teardown() throws Exception { + super.tearDown(); threadPool.shutdown(); }