Skip to content

Commit a49dbc5

Browse files
committed
handle null file configs (when removed) when notified of changes
this change is required by the change in ConfigWatcher at redhat-developer/intellij-common#202 Signed-off-by: Andre Dietisheim <[email protected]>
1 parent 3e1cf9e commit a49dbc5

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

gradle.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ sinceIdeaBuild=232
55
projectVersion=1.2.1-SNAPSHOT
66
jetBrainsToken=invalid
77
jetBrainsChannel=stable
8-
intellijPluginVersion=1.15.0
8+
intellijPluginVersion=1.16.0
99
intellijCommonVersion=1.9.3-SNAPSHOT
1010
telemetryPluginVersion=1.0.0.44
1111
kotlin.stdlib.default.dependency = false

src/main/kotlin/com/redhat/devtools/intellij/kubernetes/model/AllContexts.kt

+3-2
Original file line numberDiff line numberDiff line change
@@ -245,12 +245,13 @@ open class AllContexts(
245245
* The latter gets closed/recreated whenever the context changes in
246246
* [com.redhat.devtools.intellij.kubernetes.model.client.KubeConfigAdapter].
247247
*/
248-
val watcher = ConfigWatcher(path) { _, config -> onKubeConfigChanged(config) }
248+
val watcher = ConfigWatcher(path) { _, config: io.fabric8.kubernetes.api.model.Config? -> onKubeConfigChanged(config) }
249249
runAsync(watcher::run)
250250
}
251251

252-
protected open fun onKubeConfigChanged(fileConfig: io.fabric8.kubernetes.api.model.Config) {
252+
protected open fun onKubeConfigChanged(fileConfig: io.fabric8.kubernetes.api.model.Config?) {
253253
synchronized(this) {
254+
fileConfig ?: return
254255
val client = client.get() ?: return
255256
val clientConfig = client.config.configuration
256257
if (ConfigHelper.areEqual(fileConfig, clientConfig)) {

src/test/kotlin/com/redhat/devtools/intellij/kubernetes/model/AllContextsTest.kt

+10-1
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,15 @@ class AllContextsTest {
398398
verify(modelChange, never()).fireCurrentNamespaceChanged(anyOrNull(), anyOrNull())
399399
}
400400

401+
@Test
402+
fun `#onKubeConfigChanged() should NOT fire if new config is null`() {
403+
// given
404+
// when
405+
allContexts.onKubeConfigChanged(null)
406+
// then
407+
verify(modelChange, never()).fireAllContextsChanged()
408+
}
409+
401410
@Test
402411
fun `#onKubeConfigChanged() should NOT fire if existing config and given config are equal`() {
403412
// given
@@ -550,7 +559,7 @@ class AllContextsTest {
550559
}
551560

552561
/** override with public method so that it can be tested**/
553-
public override fun onKubeConfigChanged(fileConfig: Config) {
562+
public override fun onKubeConfigChanged(fileConfig: Config?) {
554563
super.onKubeConfigChanged(fileConfig)
555564
}
556565

0 commit comments

Comments
 (0)