[fix][test] Fix flaky test AdditionalServletsTest.testEmptyStringAsExtractionDirectory
@@ -52,10 +52,8 @@ public class AdditionalServletsTest {
AdditionalServletWithClassLoader as1 = mock(AdditionalServletWithClassLoader.class);
AdditionalServletWithClassLoader as2 = mock(AdditionalServletWithClassLoader.class);
- String originalTmpDirectory = System.getProperty("java.io.tmpdir");
try (MockedStatic<AdditionalServletUtils> 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 class AdditionalServletsTest {
Assert.assertEquals(servlets.getServlets().get("AS1"), as1);
Assert.assertEquals(servlets.getServlets().get("AS2"), as2);
- } finally {
- System.setProperty("java.io.tmpdir", originalTmpDirectory);
}
}
