From afdb7a4a9a31ac234e782816ad074294c73dfb30 Mon Sep 17 00:00:00 2001 From: Andre Dietisheim Date: Tue, 14 Nov 2023 10:27:08 +0100 Subject: [PATCH] handle null file configs (when removed) when notified of changes this change is required by the change in ConfigWatcher at https://github.com/redhat-developer/intellij-common/pull/202 Signed-off-by: Andre Dietisheim --- gradle.properties | 2 +- .../redhat/devtools/intellij/kubernetes/model/AllContexts.kt | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/gradle.properties b/gradle.properties index 6613acdc2..bcaa15b17 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,7 +5,7 @@ sinceIdeaBuild=232 projectVersion=1.2.1-SNAPSHOT jetBrainsToken=invalid jetBrainsChannel=stable -intellijPluginVersion=1.15.0 +intellijPluginVersion=1.16.0 intellijCommonVersion=1.9.3-SNAPSHOT telemetryPluginVersion=1.0.0.44 kotlin.stdlib.default.dependency = false 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 9eddc46f2..d3440bf58 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 @@ -245,12 +245,13 @@ open class AllContexts( * The latter gets closed/recreated whenever the context changes in * [com.redhat.devtools.intellij.kubernetes.model.client.KubeConfigAdapter]. */ - val watcher = ConfigWatcher(path) { _, config -> onKubeConfigChanged(config) } + val watcher = ConfigWatcher(path) { _, config: io.fabric8.kubernetes.api.model.Config? -> onKubeConfigChanged(config) } runAsync(watcher::run) } - protected open fun onKubeConfigChanged(fileConfig: io.fabric8.kubernetes.api.model.Config) { + protected open fun onKubeConfigChanged(fileConfig: io.fabric8.kubernetes.api.model.Config?) { synchronized(this) { + fileConfig ?: return val client = client.get() ?: return val clientConfig = client.config.configuration if (ConfigHelper.areEqual(fileConfig, clientConfig)) {