diff --git a/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/web/plugin/servlet/AdditionalServletsTest.java b/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/web/plugin/servlet/AdditionalServletsTest.java index 3d708fe9ec0a3c..dd5045b1b09eba 100644 --- a/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/web/plugin/servlet/AdditionalServletsTest.java +++ b/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/web/plugin/servlet/AdditionalServletsTest.java @@ -52,10 +52,8 @@ public void testEmptyStringAsExtractionDirectory() throws IOException { AdditionalServletWithClassLoader as1 = mock(AdditionalServletWithClassLoader.class); AdditionalServletWithClassLoader as2 = mock(AdditionalServletWithClassLoader.class); - String originalTmpDirectory = System.getProperty("java.io.tmpdir"); try (MockedStatic utils = mockStatic(AdditionalServletUtils.class)) { - String tmpDirectory = "/my/tmp/directory"; - System.setProperty("java.io.tmpdir", tmpDirectory); + String tmpDirectory = System.getProperty("java.io.tmpdir"); utils.when(() -> AdditionalServletUtils.searchForServlets( "/additionalServletDirectory", tmpDirectory)).thenReturn(definitions); utils.when(() -> AdditionalServletUtils.load(asm1, tmpDirectory)).thenReturn(as1); @@ -65,8 +63,6 @@ public void testEmptyStringAsExtractionDirectory() throws IOException { Assert.assertEquals(servlets.getServlets().get("AS1"), as1); Assert.assertEquals(servlets.getServlets().get("AS2"), as2); - } finally { - System.setProperty("java.io.tmpdir", originalTmpDirectory); } }