From 194328a60fcc3507796d3a6572b7c96dee2ca077 Mon Sep 17 00:00:00 2001 From: Jack Yun Date: Thu, 14 Sep 2023 14:52:37 +0900 Subject: [PATCH] feat : handle thread safe issue for getCurrentFutures(#1843) (#1844) cherry pick #1843 --- .../graphql/dataloader/KotlinDataLoaderRegistry.kt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/executions/graphql-kotlin-dataloader/src/main/kotlin/com/expediagroup/graphql/dataloader/KotlinDataLoaderRegistry.kt b/executions/graphql-kotlin-dataloader/src/main/kotlin/com/expediagroup/graphql/dataloader/KotlinDataLoaderRegistry.kt index 1d28bdfcf1..42ce4df4bc 100644 --- a/executions/graphql-kotlin-dataloader/src/main/kotlin/com/expediagroup/graphql/dataloader/KotlinDataLoaderRegistry.kt +++ b/executions/graphql-kotlin-dataloader/src/main/kotlin/com/expediagroup/graphql/dataloader/KotlinDataLoaderRegistry.kt @@ -61,11 +61,11 @@ class KotlinDataLoaderRegistry( * @return list of current completable futures. */ fun getCurrentFutures(): List> = - synchronized(registry.dataLoaders) { - registry.dataLoaders.map { dataLoader -> - dataLoader.cacheMap.all - }.flatten() - } + registry.dataLoaders.map { dataLoader -> + synchronized(dataLoader) { + dataLoader.cacheMap.all.toList() + } + }.flatten() /** * This will invoke [DataLoader.dispatch] on each of the registered [DataLoader]s,