diff --git a/ml-algorithms/src/test/java/org/opensearch/ml/engine/utils/FileUtilsTest.java b/ml-algorithms/src/test/java/org/opensearch/ml/engine/utils/FileUtilsTest.java index 16138fea8b..390286aadd 100644 --- a/ml-algorithms/src/test/java/org/opensearch/ml/engine/utils/FileUtilsTest.java +++ b/ml-algorithms/src/test/java/org/opensearch/ml/engine/utils/FileUtilsTest.java @@ -22,16 +22,19 @@ import org.junit.rules.TemporaryFolder; public class FileUtilsTest { - private final TemporaryFolder tempDir = new TemporaryFolder(); + private TemporaryFolder tempDir; @Before public void setUp() throws Exception { + tempDir = new TemporaryFolder(); tempDir.create(); } @After - public void tearUp() { - tempDir.delete(); + public void tearDown() { + if (tempDir != null) { + tempDir.delete(); + } } @Test