From 33c800a2354829b1c313257cb59b285a73286900 Mon Sep 17 00:00:00 2001 From: Andre Dietisheim Date: Mon, 15 Sep 2025 21:16:54 +0200 Subject: [PATCH] replaced String.format() by kotlin string templates Signed-off-by: Andre Dietisheim --- .../devtools/gateway/DevSpacesConnection.kt | 2 +- .../gateway/openshift/DevWorkspaces.kt | 2 +- .../gateway/server/RemoteIDEServer.kt | 20 ++++--------------- 3 files changed, 6 insertions(+), 18 deletions(-) diff --git a/src/main/kotlin/com/redhat/devtools/gateway/DevSpacesConnection.kt b/src/main/kotlin/com/redhat/devtools/gateway/DevSpacesConnection.kt index e57b2bf9..4b2fa601 100644 --- a/src/main/kotlin/com/redhat/devtools/gateway/DevSpacesConnection.kt +++ b/src/main/kotlin/com/redhat/devtools/gateway/DevSpacesConnection.kt @@ -30,7 +30,7 @@ class DevSpacesConnection(private val devSpacesContext: DevSpacesContext) { onDevWorkspaceStopped: () -> Unit, ): ThinClientHandle { if (devSpacesContext.isConnected) - throw IOException(String.format("Already connected to %s", devSpacesContext.devWorkspace.name)) + throw IOException("Already connected to ${devSpacesContext.devWorkspace.name}") devSpacesContext.isConnected = true try { diff --git a/src/main/kotlin/com/redhat/devtools/gateway/openshift/DevWorkspaces.kt b/src/main/kotlin/com/redhat/devtools/gateway/openshift/DevWorkspaces.kt index 17dd52b5..db7db902 100644 --- a/src/main/kotlin/com/redhat/devtools/gateway/openshift/DevWorkspaces.kt +++ b/src/main/kotlin/com/redhat/devtools/gateway/openshift/DevWorkspaces.kt @@ -100,7 +100,7 @@ class DevWorkspaces(private val client: ApiClient) { ): Boolean { var phaseIsDesiredState = false - val watcher = createWatcher(namespace, String.format("metadata.name=%s", name)) + val watcher = createWatcher(namespace, "metadata.name=$name") val executor = Executors.newSingleThreadScheduledExecutor() executor.schedule( { diff --git a/src/main/kotlin/com/redhat/devtools/gateway/server/RemoteIDEServer.kt b/src/main/kotlin/com/redhat/devtools/gateway/server/RemoteIDEServer.kt index 2f2e5f45..31d5dee9 100644 --- a/src/main/kotlin/com/redhat/devtools/gateway/server/RemoteIDEServer.kt +++ b/src/main/kotlin/com/redhat/devtools/gateway/server/RemoteIDEServer.kt @@ -72,10 +72,7 @@ class RemoteIDEServer(private val devSpacesContext: DevSpacesContext) { doWaitServerState(true) .also { if (!it) throw IOException( - String.format( - "Remote IDE server is not ready after %d seconds.", - readyTimeout - ) + "Remote IDE server is not ready after $readyTimeout seconds.", ) } } @@ -98,21 +95,14 @@ class RemoteIDEServer(private val devSpacesContext: DevSpacesContext) { @Throws(IOException::class) private fun findPod(): V1Pod { - val selector = - String.format( - "controller.devfile.io/devworkspace_name=%s", - devSpacesContext.devWorkspace.name - ) + val selector = "controller.devfile.io/devworkspace_name=${devSpacesContext.devWorkspace.name}" return Pods(devSpacesContext.client) .findFirst( devSpacesContext.devWorkspace.namespace, selector ) ?: throw IOException( - String.format( - "DevWorkspace '%s' is not running.", - devSpacesContext.devWorkspace.name - ) + "DevWorkspace '${devSpacesContext.devWorkspace.name}' is not running.", ) } @@ -120,9 +110,7 @@ class RemoteIDEServer(private val devSpacesContext: DevSpacesContext) { private fun findContainer(): V1Container { return pod.spec!!.containers.find { container -> container.ports?.any { port -> port.name == "idea-server" } != null } ?: throw IOException( - String.format( - "Remote server container not found in the Pod: %s", pod.metadata?.name - ) + "Remote server container not found in the Pod: ${pod.metadata?.name}" ) } }