From e8bbf1edacce0d765a8a2501adc2f82396aa1454 Mon Sep 17 00:00:00 2001 From: Christian Melchior Date: Tue, 21 Nov 2023 13:47:57 +0100 Subject: [PATCH 1/3] Smaller fixes for corner cases hit while running tests on Github Actions. --- benchmarks/settings.gradle.kts | 2 +- buildSrc/src/main/kotlin/Config.kt | 2 +- examples/kmm-sample/settings.gradle.kts | 2 +- .../settings.gradle.kts | 2 +- .../kotlin/io/realm/kotlin/Configuration.kt | 18 +++++++--------- .../kotlin/internal/ConfigurationImpl.kt | 5 +++-- .../kotlin/test/common/Decimal128Tests.kt | 3 +++ .../test/common/EmbeddedRealmObjectTests.kt | 3 +++ .../kotlin/test/common/FqNameImportTests.kt | 3 +++ .../realm/kotlin/test/common/ImportTests.kt | 3 +++ .../io/realm/kotlin/test/common/LinkTests.kt | 3 +++ .../kotlin/test/common/NullabilityTests.kt | 3 +++ .../realm/kotlin/test/common/ReadMeTests.kt | 4 +++- .../test/common/RealmConfigurationTests.kt | 2 +- .../kotlin/test/common/RealmInMemoryTests.kt | 2 +- .../common/migration/RealmMigrationTests.kt | 2 +- .../notifications/RealmNotificationsTests.kt | 2 +- .../notifications/SystemNotificationTests.kt | 4 ++++ .../kotlin/test/platform/PlatformUtils.kt | 19 ++++++++++++++++- .../io/realm/kotlin/test/jvm/RealmTests.kt | 21 ++++++++++++++++--- 20 files changed, 80 insertions(+), 25 deletions(-) diff --git a/benchmarks/settings.gradle.kts b/benchmarks/settings.gradle.kts index e24ab8657a..75f6d9c7d8 100644 --- a/benchmarks/settings.gradle.kts +++ b/benchmarks/settings.gradle.kts @@ -18,7 +18,7 @@ // For CI buils, the packages are expected to have // been built and deployed to a local filesystem // maven repo. -if (System.getenv("JENKINS_HOME") == null) { +if (System.getenv("JENKINS_HOME") == null && System.getenv("CI") == null) { includeBuild("../packages") } diff --git a/buildSrc/src/main/kotlin/Config.kt b/buildSrc/src/main/kotlin/Config.kt index 4778352d30..574dc1d571 100644 --- a/buildSrc/src/main/kotlin/Config.kt +++ b/buildSrc/src/main/kotlin/Config.kt @@ -61,7 +61,7 @@ private fun findHostOs(): OperatingSystem { val HOST_OS: OperatingSystem = findHostOs() object Realm { - val ciBuild = (System.getenv("JENKINS_HOME") != null) + val ciBuild = (System.getenv("JENKINS_HOME") != null || System.getenv("CI") != null) const val version = "1.13.0-SNAPSHOT" const val group = "io.realm.kotlin" const val projectUrl = "https://realm.io" diff --git a/examples/kmm-sample/settings.gradle.kts b/examples/kmm-sample/settings.gradle.kts index a0159ae60a..b6c2f49fff 100644 --- a/examples/kmm-sample/settings.gradle.kts +++ b/examples/kmm-sample/settings.gradle.kts @@ -3,7 +3,7 @@ // been built and deployed to a local filesystem // maven repo. We cannot reference `Realm.ciBuild` // from buildSrc here. -if (System.getenv("JENKINS_HOME") == null) { +if (System.getenv("JENKINS_HOME") == null && System.getenv("CI") == null) { includeBuild("../../packages") } diff --git a/examples/realm-java-compatibility/settings.gradle.kts b/examples/realm-java-compatibility/settings.gradle.kts index 481cc5c8fc..3cdeb134c2 100644 --- a/examples/realm-java-compatibility/settings.gradle.kts +++ b/examples/realm-java-compatibility/settings.gradle.kts @@ -19,7 +19,7 @@ // been built and deployed to a local filesystem // maven repo. We cannot reference `Realm.ciBuild` // from buildSrc here. -if (System.getenv("JENKINS_HOME") == null) { +if (System.getenv("JENKINS_HOME") == null && System.getenv("CI") == null) { includeBuild("../../packages") } diff --git a/packages/library-base/src/commonMain/kotlin/io/realm/kotlin/Configuration.kt b/packages/library-base/src/commonMain/kotlin/io/realm/kotlin/Configuration.kt index f395541bde..d16f2e2eab 100644 --- a/packages/library-base/src/commonMain/kotlin/io/realm/kotlin/Configuration.kt +++ b/packages/library-base/src/commonMain/kotlin/io/realm/kotlin/Configuration.kt @@ -300,32 +300,30 @@ public interface Configuration { } as S /** - * Dispatcher used to run background writes to the Realm. + * Dispatcher on which Realm notifications are run. It is possible to listen for changes to + * Realm objects from any thread, but the underlying logic will run on this dispatcher + * before any changes are returned to the caller thread. * * Defaults to a single threaded dispatcher started when the configuration is built. * * NOTE On Android the dispatcher's thread must have an initialized * [Looper](https://developer.android.com/reference/android/os/Looper#prepare()). * - * @param dispatcher dispatcher on which writes are run. It is required to be backed by a - * single thread only. + * @param dispatcher dispatcher on which notifications are run. It is required to be backed + * by a single thread only. */ internal fun notificationDispatcher(dispatcher: CoroutineDispatcher) = apply { this.notificationDispatcher = dispatcher } as S /** - * Dispatcher on which Realm notifications are run. It is possible to listen for changes to - * Realm objects from any thread, but the underlying logic will run on this dispatcher - * before any changes are returned to the caller thread. - * - * Defaults to a single threaded dispatcher started when the configuration is built. + * Dispatcher used to run background writes to the Realm. * * * NOTE On Android the dispatcher's thread must have an initialized * [Looper](https://developer.android.com/reference/android/os/Looper#prepare()). * - * @param dispatcher Dispatcher on which notifications are run. It is required to be backed - * by a single thread only. + * @param dispatcher dispatcher on which writes are run. It is required to be backed by a + * single thread only. */ internal fun writeDispatcher(dispatcher: CoroutineDispatcher) = apply { this.writeDispatcher = dispatcher diff --git a/packages/library-base/src/commonMain/kotlin/io/realm/kotlin/internal/ConfigurationImpl.kt b/packages/library-base/src/commonMain/kotlin/io/realm/kotlin/internal/ConfigurationImpl.kt index 3463f478c0..1c5fae2b73 100644 --- a/packages/library-base/src/commonMain/kotlin/io/realm/kotlin/internal/ConfigurationImpl.kt +++ b/packages/library-base/src/commonMain/kotlin/io/realm/kotlin/internal/ConfigurationImpl.kt @@ -37,6 +37,7 @@ import io.realm.kotlin.internal.interop.RealmInterop import io.realm.kotlin.internal.interop.RealmSchemaPointer import io.realm.kotlin.internal.interop.SchemaMode import io.realm.kotlin.internal.interop.use +import io.realm.kotlin.internal.platform.PATH_SEPARATOR import io.realm.kotlin.internal.platform.appFilesDirectory import io.realm.kotlin.internal.platform.prepareRealmFilePath import io.realm.kotlin.internal.platform.realmObjectCompanionOrThrow @@ -255,8 +256,8 @@ public open class ConfigurationImpl( private fun normalizePath(directoryPath: String, fileName: String): String { var dir = directoryPath.ifEmpty { appFilesDirectory() } // If dir is a relative path, replace with full path for easier debugging - if (dir.startsWith("./")) { - dir = dir.replaceFirst("./", "${appFilesDirectory()}/") + if (dir.startsWith(".$PATH_SEPARATOR")) { + dir = dir.replaceFirst(".$PATH_SEPARATOR", "${appFilesDirectory()}$PATH_SEPARATOR") } return prepareRealmFilePath(dir, fileName) } diff --git a/packages/test-base/src/commonTest/kotlin/io/realm/kotlin/test/common/Decimal128Tests.kt b/packages/test-base/src/commonTest/kotlin/io/realm/kotlin/test/common/Decimal128Tests.kt index 5ad5dbc77d..cc3d74ecf4 100644 --- a/packages/test-base/src/commonTest/kotlin/io/realm/kotlin/test/common/Decimal128Tests.kt +++ b/packages/test-base/src/commonTest/kotlin/io/realm/kotlin/test/common/Decimal128Tests.kt @@ -28,6 +28,9 @@ class Decimal128Tests { @AfterTest fun tearDown() { + if (this::realm.isInitialized) { + realm.close() + } PlatformUtils.deleteTempDir(tmpDir) } diff --git a/packages/test-base/src/commonTest/kotlin/io/realm/kotlin/test/common/EmbeddedRealmObjectTests.kt b/packages/test-base/src/commonTest/kotlin/io/realm/kotlin/test/common/EmbeddedRealmObjectTests.kt index 8cccb2b527..fc9cfbaf2e 100644 --- a/packages/test-base/src/commonTest/kotlin/io/realm/kotlin/test/common/EmbeddedRealmObjectTests.kt +++ b/packages/test-base/src/commonTest/kotlin/io/realm/kotlin/test/common/EmbeddedRealmObjectTests.kt @@ -60,6 +60,9 @@ class EmbeddedRealmObjectTests { @AfterTest fun tearDown() { + if (this::realm.isInitialized) { + realm.close() + } PlatformUtils.deleteTempDir(tmpDir) } diff --git a/packages/test-base/src/commonTest/kotlin/io/realm/kotlin/test/common/FqNameImportTests.kt b/packages/test-base/src/commonTest/kotlin/io/realm/kotlin/test/common/FqNameImportTests.kt index 339dbce83d..541cf415d3 100644 --- a/packages/test-base/src/commonTest/kotlin/io/realm/kotlin/test/common/FqNameImportTests.kt +++ b/packages/test-base/src/commonTest/kotlin/io/realm/kotlin/test/common/FqNameImportTests.kt @@ -28,6 +28,9 @@ class FqNameImportTests { @AfterTest fun tearDown() { + if (this::realm.isInitialized) { + realm.close() + } PlatformUtils.deleteTempDir(tmpDir) } diff --git a/packages/test-base/src/commonTest/kotlin/io/realm/kotlin/test/common/ImportTests.kt b/packages/test-base/src/commonTest/kotlin/io/realm/kotlin/test/common/ImportTests.kt index 6cf86459b5..1e8e79bf77 100644 --- a/packages/test-base/src/commonTest/kotlin/io/realm/kotlin/test/common/ImportTests.kt +++ b/packages/test-base/src/commonTest/kotlin/io/realm/kotlin/test/common/ImportTests.kt @@ -61,6 +61,9 @@ class ImportTests { @AfterTest fun tearDown() { + if (this::realm.isInitialized) { + realm.close() + } PlatformUtils.deleteTempDir(tmpDir) } diff --git a/packages/test-base/src/commonTest/kotlin/io/realm/kotlin/test/common/LinkTests.kt b/packages/test-base/src/commonTest/kotlin/io/realm/kotlin/test/common/LinkTests.kt index 3527729691..2097bce4c1 100644 --- a/packages/test-base/src/commonTest/kotlin/io/realm/kotlin/test/common/LinkTests.kt +++ b/packages/test-base/src/commonTest/kotlin/io/realm/kotlin/test/common/LinkTests.kt @@ -45,6 +45,9 @@ class LinkTests { @AfterTest fun tearDown() { + if (this::realm.isInitialized) { + realm.close() + } PlatformUtils.deleteTempDir(tmpDir) } diff --git a/packages/test-base/src/commonTest/kotlin/io/realm/kotlin/test/common/NullabilityTests.kt b/packages/test-base/src/commonTest/kotlin/io/realm/kotlin/test/common/NullabilityTests.kt index 29d7ce2295..5917acd8bf 100644 --- a/packages/test-base/src/commonTest/kotlin/io/realm/kotlin/test/common/NullabilityTests.kt +++ b/packages/test-base/src/commonTest/kotlin/io/realm/kotlin/test/common/NullabilityTests.kt @@ -54,6 +54,9 @@ class NullabilityTests { @AfterTest fun tearDown() { + if (this::realm.isInitialized) { + realm.close() + } PlatformUtils.deleteTempDir(tmpDir) } diff --git a/packages/test-base/src/commonTest/kotlin/io/realm/kotlin/test/common/ReadMeTests.kt b/packages/test-base/src/commonTest/kotlin/io/realm/kotlin/test/common/ReadMeTests.kt index 6bede4e31e..0fe9c7ecdf 100644 --- a/packages/test-base/src/commonTest/kotlin/io/realm/kotlin/test/common/ReadMeTests.kt +++ b/packages/test-base/src/commonTest/kotlin/io/realm/kotlin/test/common/ReadMeTests.kt @@ -41,6 +41,7 @@ import io.realm.kotlin.notifications.UpdatedResults import io.realm.kotlin.test.platform.PlatformUtils import io.realm.kotlin.types.RealmList import io.realm.kotlin.types.RealmObject +import kotlinx.coroutines.CloseableCoroutineDispatcher import kotlinx.coroutines.CoroutineDispatcher import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.async @@ -57,7 +58,7 @@ import kotlin.test.Test */ class ReadMeTests { private lateinit var scope: CoroutineScope - private lateinit var context: CoroutineDispatcher + private lateinit var context: CloseableCoroutineDispatcher lateinit var tmpDir: String lateinit var realm: Realm @@ -79,6 +80,7 @@ class ReadMeTests { scope.cancel() context.cancel() realm.close() + context.close() PlatformUtils.deleteTempDir(tmpDir) } diff --git a/packages/test-base/src/commonTest/kotlin/io/realm/kotlin/test/common/RealmConfigurationTests.kt b/packages/test-base/src/commonTest/kotlin/io/realm/kotlin/test/common/RealmConfigurationTests.kt index cc9c22f728..b84b0226d6 100644 --- a/packages/test-base/src/commonTest/kotlin/io/realm/kotlin/test/common/RealmConfigurationTests.kt +++ b/packages/test-base/src/commonTest/kotlin/io/realm/kotlin/test/common/RealmConfigurationTests.kt @@ -119,7 +119,7 @@ class RealmConfigurationTests { val configFromBuilderWithCurrentDir: RealmConfiguration = RealmConfiguration.Builder(schema = setOf(Sample::class)) - .directory("./my_dir") + .directory(pathOf(".", "my_dir")) .name("foo.realm") .build() assertEquals( diff --git a/packages/test-base/src/commonTest/kotlin/io/realm/kotlin/test/common/RealmInMemoryTests.kt b/packages/test-base/src/commonTest/kotlin/io/realm/kotlin/test/common/RealmInMemoryTests.kt index 1369c3e4ad..c6d79f1392 100644 --- a/packages/test-base/src/commonTest/kotlin/io/realm/kotlin/test/common/RealmInMemoryTests.kt +++ b/packages/test-base/src/commonTest/kotlin/io/realm/kotlin/test/common/RealmInMemoryTests.kt @@ -43,10 +43,10 @@ class RealmInMemoryTests { @AfterTest fun tearDown() { - PlatformUtils.deleteTempDir(tmpDir) if (this::realm.isInitialized && !realm.isClosed()) { realm.close() } + PlatformUtils.deleteTempDir(tmpDir) } @Test diff --git a/packages/test-base/src/commonTest/kotlin/io/realm/kotlin/test/common/migration/RealmMigrationTests.kt b/packages/test-base/src/commonTest/kotlin/io/realm/kotlin/test/common/migration/RealmMigrationTests.kt index 090402e387..2d8695389d 100644 --- a/packages/test-base/src/commonTest/kotlin/io/realm/kotlin/test/common/migration/RealmMigrationTests.kt +++ b/packages/test-base/src/commonTest/kotlin/io/realm/kotlin/test/common/migration/RealmMigrationTests.kt @@ -89,7 +89,7 @@ class RealmMigrationTests { assertNull(newSchema["SchemaVariations"]) } } - ) + ).close() } // TODO Test all schema modifications (theoretically test core behavior, so postponed for now) diff --git a/packages/test-base/src/commonTest/kotlin/io/realm/kotlin/test/common/notifications/RealmNotificationsTests.kt b/packages/test-base/src/commonTest/kotlin/io/realm/kotlin/test/common/notifications/RealmNotificationsTests.kt index 26f85807f2..6456955183 100644 --- a/packages/test-base/src/commonTest/kotlin/io/realm/kotlin/test/common/notifications/RealmNotificationsTests.kt +++ b/packages/test-base/src/commonTest/kotlin/io/realm/kotlin/test/common/notifications/RealmNotificationsTests.kt @@ -220,7 +220,7 @@ class RealmNotificationsTests : FlowableTests { runBlocking { val listener = async { - withTimeout(10.seconds) { + withTimeout(30.seconds) { assertFailsWith { flow.collect { delay(1000.milliseconds) diff --git a/packages/test-base/src/commonTest/kotlin/io/realm/kotlin/test/common/notifications/SystemNotificationTests.kt b/packages/test-base/src/commonTest/kotlin/io/realm/kotlin/test/common/notifications/SystemNotificationTests.kt index b43ba6c9a6..f5bcecb227 100644 --- a/packages/test-base/src/commonTest/kotlin/io/realm/kotlin/test/common/notifications/SystemNotificationTests.kt +++ b/packages/test-base/src/commonTest/kotlin/io/realm/kotlin/test/common/notifications/SystemNotificationTests.kt @@ -76,5 +76,9 @@ class SystemNotificationTests { writer1.write { copyToRealm(Sample()) } writer2.write { copyToRealm(Sample()) } } + writer1.close() + writer2.close() + liveRealmContext.close() + baseRealm.close() } } diff --git a/packages/test-base/src/jvmMain/kotlin/io/realm/kotlin/test/platform/PlatformUtils.kt b/packages/test-base/src/jvmMain/kotlin/io/realm/kotlin/test/platform/PlatformUtils.kt index a9e39b7feb..b4e5a1d889 100644 --- a/packages/test-base/src/jvmMain/kotlin/io/realm/kotlin/test/platform/PlatformUtils.kt +++ b/packages/test-base/src/jvmMain/kotlin/io/realm/kotlin/test/platform/PlatformUtils.kt @@ -19,7 +19,9 @@ package io.realm.kotlin.test.platform import java.io.File import java.nio.file.Files import java.nio.file.Path +import java.nio.file.Paths import java.nio.file.attribute.PosixFilePermission +import java.util.stream.Collectors import kotlin.io.path.absolutePathString import kotlin.time.Duration @@ -40,7 +42,22 @@ actual object PlatformUtils { } actual fun deleteTempDir(path: String) { - File(path).deleteRecursively() + val rootPath: Path = Paths.get(path) + val pathsToDelete: List = + Files.walk(rootPath).sorted(Comparator.reverseOrder()).collect(Collectors.toList()) + for (p in pathsToDelete) { + try { + Files.deleteIfExists(p) + } catch (e: java.nio.file.FileSystemException) { + // Sometimes (on Windows) we need the give a GC a chance to run and close all native pointers + // before we can delete the Realm, otherwise delete will fail with " The process cannot access the + // file because it is being used by another process". + // + // We try to trigger the GC once then retry the delete. + triggerGC() + Files.deleteIfExists(p) + } + } } actual fun sleep(duration: Duration) { diff --git a/packages/test-base/src/jvmTest/kotlin/io/realm/kotlin/test/jvm/RealmTests.kt b/packages/test-base/src/jvmTest/kotlin/io/realm/kotlin/test/jvm/RealmTests.kt index 8735682386..099caf3c3f 100644 --- a/packages/test-base/src/jvmTest/kotlin/io/realm/kotlin/test/jvm/RealmTests.kt +++ b/packages/test-base/src/jvmTest/kotlin/io/realm/kotlin/test/jvm/RealmTests.kt @@ -81,12 +81,13 @@ class RealmTests { // Closing a Realm should also cleanup our default (internal) dispatchers. // The core notifier and the finalizer thread will never be closed. val expectedThreadCount = initialThreads.size + 1 /* core-notifier */ + if (finalizerRunning) 0 else 1 - var counter = 5 // Wait 5 seconds for threads to settle - while (totalThreadCount() != expectedThreadCount && counter > 0) { + var counter = 10 // Wait 5 seconds for threads to settle + while (newThreads().any { !it.isDaemon } && counter > 0) { delay(1000) counter-- } - assertEquals(expectedThreadCount, totalThreadCount(), "Unexpected thread count after closing realm: ${newThreads()}") + val totalThreadCount = totalThreadCount() + assertTrue(totalThreadCount <= expectedThreadCount, "Unexpected thread count after closing realm: $expectedThreadCount <= $totalThreadCount. New threads: ${newThreads()}. Threads: ${threadTrace()}") // Verify that all remaining threads are daemon threads, so that we don't keep the JVM alive newThreads().filter { !it.isDaemon }.let { @@ -122,4 +123,18 @@ class RealmTests { Unit } } + + private fun threadTrace(): String { + val sb = StringBuilder() + sb.appendLine("--------------------------------") + val stack = Thread.getAllStackTraces() + stack.keys + .sortedBy { it.name } + .forEach { t: Thread -> + sb.appendLine("${t.name} - Is Daemon ${t.isDaemon} - Is Alive ${t.isAlive}") + } + sb.appendLine("All threads: ${stack.keys.size}") + sb.appendLine("Active threads: ${Thread.activeCount()}") + return sb.toString() + } } From d0959b398f7abde81e1168a9f9e30cfb7a349ca4 Mon Sep 17 00:00:00 2001 From: Christian Melchior Date: Tue, 28 Nov 2023 07:44:13 +0100 Subject: [PATCH 2/3] Formatting --- .../commonTest/kotlin/io/realm/kotlin/test/common/ReadMeTests.kt | 1 - .../kotlin/io/realm/kotlin/test/platform/PlatformUtils.kt | 1 - 2 files changed, 2 deletions(-) diff --git a/packages/test-base/src/commonTest/kotlin/io/realm/kotlin/test/common/ReadMeTests.kt b/packages/test-base/src/commonTest/kotlin/io/realm/kotlin/test/common/ReadMeTests.kt index 0fe9c7ecdf..2b3d1a912f 100644 --- a/packages/test-base/src/commonTest/kotlin/io/realm/kotlin/test/common/ReadMeTests.kt +++ b/packages/test-base/src/commonTest/kotlin/io/realm/kotlin/test/common/ReadMeTests.kt @@ -42,7 +42,6 @@ import io.realm.kotlin.test.platform.PlatformUtils import io.realm.kotlin.types.RealmList import io.realm.kotlin.types.RealmObject import kotlinx.coroutines.CloseableCoroutineDispatcher -import kotlinx.coroutines.CoroutineDispatcher import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.async import kotlinx.coroutines.cancel diff --git a/packages/test-base/src/jvmMain/kotlin/io/realm/kotlin/test/platform/PlatformUtils.kt b/packages/test-base/src/jvmMain/kotlin/io/realm/kotlin/test/platform/PlatformUtils.kt index b4e5a1d889..a20938ed2c 100644 --- a/packages/test-base/src/jvmMain/kotlin/io/realm/kotlin/test/platform/PlatformUtils.kt +++ b/packages/test-base/src/jvmMain/kotlin/io/realm/kotlin/test/platform/PlatformUtils.kt @@ -16,7 +16,6 @@ package io.realm.kotlin.test.platform -import java.io.File import java.nio.file.Files import java.nio.file.Path import java.nio.file.Paths From 910f57d8ec2fad5bcb9dc3291d685cfeaee8f373 Mon Sep 17 00:00:00 2001 From: Christian Melchior Date: Tue, 28 Nov 2023 17:41:47 +0100 Subject: [PATCH 3/3] PR feedback --- .../src/commonMain/kotlin/io/realm/kotlin/Configuration.kt | 2 +- .../src/jvmTest/kotlin/io/realm/kotlin/test/jvm/RealmTests.kt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/library-base/src/commonMain/kotlin/io/realm/kotlin/Configuration.kt b/packages/library-base/src/commonMain/kotlin/io/realm/kotlin/Configuration.kt index d16f2e2eab..daf8e6a42f 100644 --- a/packages/library-base/src/commonMain/kotlin/io/realm/kotlin/Configuration.kt +++ b/packages/library-base/src/commonMain/kotlin/io/realm/kotlin/Configuration.kt @@ -302,7 +302,7 @@ public interface Configuration { /** * Dispatcher on which Realm notifications are run. It is possible to listen for changes to * Realm objects from any thread, but the underlying logic will run on this dispatcher - * before any changes are returned to the caller thread. + * before any changes are returned to the receiving context. * * Defaults to a single threaded dispatcher started when the configuration is built. * diff --git a/packages/test-base/src/jvmTest/kotlin/io/realm/kotlin/test/jvm/RealmTests.kt b/packages/test-base/src/jvmTest/kotlin/io/realm/kotlin/test/jvm/RealmTests.kt index 099caf3c3f..a3770f43ac 100644 --- a/packages/test-base/src/jvmTest/kotlin/io/realm/kotlin/test/jvm/RealmTests.kt +++ b/packages/test-base/src/jvmTest/kotlin/io/realm/kotlin/test/jvm/RealmTests.kt @@ -81,7 +81,7 @@ class RealmTests { // Closing a Realm should also cleanup our default (internal) dispatchers. // The core notifier and the finalizer thread will never be closed. val expectedThreadCount = initialThreads.size + 1 /* core-notifier */ + if (finalizerRunning) 0 else 1 - var counter = 10 // Wait 5 seconds for threads to settle + var counter = 10 // Wait 10 seconds for threads to settle while (newThreads().any { !it.isDaemon } && counter > 0) { delay(1000) counter--