From f4f9f1f8f8602a36efa27cf113e0c58f72ff9fd5 Mon Sep 17 00:00:00 2001 From: Nikolay Lunyak Date: Thu, 22 Jun 2023 11:43:21 +0000 Subject: [PATCH] [Tests] Remove temporary directories check from finalize This implementation of `finalize()` is incorrect. See: https://docs.oracle.com/en/java/javase/20/docs/api/java.base/java/lang/Object.html#finalize() > If an uncaught exception is thrown by the finalize method, the exception is ignored and finalization of that object terminates. > If a subclass overrides finalize it must invoke the superclass finalizer explicitly. Instead of providing help by highlighting the tests that forget to clear the temporary directories, this `finalize()` causes OOM. Merge-request: KT-MR-10756 Merged-by: Nikolay Lunyak --- .../test/services/impl/TemporaryDirectoryManagerImpl.kt | 7 ------- 1 file changed, 7 deletions(-) diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/services/impl/TemporaryDirectoryManagerImpl.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/services/impl/TemporaryDirectoryManagerImpl.kt index aa4ac9ddceb..24eb6913ace 100644 --- a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/services/impl/TemporaryDirectoryManagerImpl.kt +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/services/impl/TemporaryDirectoryManagerImpl.kt @@ -47,13 +47,6 @@ class TemporaryDirectoryManagerImpl(testServices: TestServices) : TemporaryDirec } } - @Suppress("removal") - fun finalize() { - if (rootTempDir.isInitialized() && rootDir.exists()) { - error("The temporary directory $rootDir has not been deleted by the time the corresponding ${this::class.simpleName} is finalized.") - } - } - companion object { private val onWindows: Boolean = System.getProperty("os.name").lowercase(Locale.getDefault()).contains("windows")