From a73f766b1fc961948cd74686ac1078ee03dfa2cf Mon Sep 17 00:00:00 2001 From: Andre Dietisheim Date: Mon, 24 Jul 2023 14:42:17 +0200 Subject: [PATCH] correctly synchronize accessing client when config changes (#640) Signed-off-by: Andre Dietisheim --- .../intellij/kubernetes/model/AllContexts.kt | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/main/kotlin/com/redhat/devtools/intellij/kubernetes/model/AllContexts.kt b/src/main/kotlin/com/redhat/devtools/intellij/kubernetes/model/AllContexts.kt index 99e9d64c7..e75936b44 100644 --- a/src/main/kotlin/com/redhat/devtools/intellij/kubernetes/model/AllContexts.kt +++ b/src/main/kotlin/com/redhat/devtools/intellij/kubernetes/model/AllContexts.kt @@ -247,14 +247,16 @@ open class AllContexts( } protected open fun onKubeConfigChanged(fileConfig: io.fabric8.kubernetes.api.model.Config) { - val client = client.get() ?: return - val clientConfig = client.config.configuration - if (ConfigHelper.areEqual(fileConfig, clientConfig)) { - return + synchronized(this) { + val client = client.get() ?: return + val clientConfig = client.config.configuration + if (ConfigHelper.areEqual(fileConfig, clientConfig)) { + return + } + this.client.reset() // create new client when accessed + client.close() + refresh() } - client.close() - this.client.reset() // create new client when accessed - refresh() } /** for testing purposes */