Skip to content

Commit 8f7a487

Browse files
committed
Fix gateway detekt issues: replace deprecated launchIOBackground with coroutines
- Replace launchIOBackground with CoroutineScope and getCoroutineBgContext() - Fix BannedImports rule by using contexts.kt utilities instead of Dispatchers - Fix import ordering and remove unused imports - Resolves gateway detekt failures for 2025.3 compatibility
1 parent 59b9487 commit 8f7a487

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

plugins/toolkit/jetbrains-gateway/src/software/aws/toolkits/jetbrains/gateway/CawsConnectionProvider.kt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ import com.intellij.openapi.components.service
1111
import com.intellij.openapi.progress.ProcessCanceledException
1212
import com.intellij.openapi.progress.ProgressIndicator
1313
import com.intellij.openapi.rd.createNestedDisposable
14-
import kotlinx.coroutines.Dispatchers
15-
import kotlinx.coroutines.launch
1614
import com.intellij.openapi.rd.util.launchOnUi
1715
import com.intellij.openapi.rd.util.startUnderBackgroundProgressAsync
1816
import com.intellij.openapi.rd.util.startUnderModalProgressAsync
@@ -36,6 +34,8 @@ import com.jetbrains.rd.framework.util.launch
3634
import com.jetbrains.rd.util.lifetime.Lifetime
3735
import com.jetbrains.rd.util.lifetime.LifetimeDefinition
3836
import kotlinx.coroutines.CancellationException
37+
import kotlinx.coroutines.CoroutineScope
38+
import kotlinx.coroutines.SupervisorJob
3939
import kotlinx.coroutines.coroutineScope
4040
import org.jetbrains.concurrency.AsyncPromise
4141
import org.jetbrains.concurrency.await
@@ -92,6 +92,8 @@ import software.aws.toolkits.telemetry.Result as TelemetryResult
9292

9393
@ExperimentalTime
9494
class CawsConnectionProvider : GatewayConnectionProvider {
95+
private val scope = CoroutineScope(getCoroutineBgContext() + SupervisorJob())
96+
9597
companion object {
9698
val CAWS_CONNECTION_PARAMETERS = AttributeBagKey.create<Map<String, String>>("CAWS_CONNECTION_PARAMETERS")
9799
private val LOG = getLogger<CawsConnectionProvider>()
@@ -199,7 +201,7 @@ class CawsConnectionProvider : GatewayConnectionProvider {
199201
)
200202
}
201203

202-
lifetime.launch(Dispatchers.IO) {
204+
scope.launch {
203205
ApplicationManager.getApplication().messageBus.syncPublisher(WorkspaceNotifications.TOPIC)
204206
.environmentStarted(
205207
WorkspaceListStateChangeContext(
@@ -249,7 +251,7 @@ class CawsConnectionProvider : GatewayConnectionProvider {
249251
duration = timeTakenToCheckInstallation.toDouble()
250252
)
251253

252-
lifetime.launch(Dispatchers.IO) {
254+
scope.launch {
253255
environmentActions.stopEnvironment()
254256
GatewayUI.getInstance().connect(parameters)
255257
}

plugins/toolkit/jetbrains-gateway/src/software/aws/toolkits/jetbrains/gateway/CawsConnectorViewPanels.kt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory
99
import com.intellij.openapi.observable.properties.PropertyGraph
1010
import com.intellij.openapi.rd.createNestedDisposable
1111
import com.intellij.openapi.rd.util.launchOnUi
12-
import kotlinx.coroutines.Dispatchers
13-
import kotlinx.coroutines.launch
1412
import com.intellij.openapi.rd.util.startWithModalProgressAsync
1513
import com.intellij.openapi.rd.util.withUiContext
1614
import com.intellij.openapi.ui.DialogPanel
@@ -47,6 +45,9 @@ import com.jetbrains.gateway.welcomeScreen.MultistagePanel
4745
import com.jetbrains.gateway.welcomeScreen.MultistagePanelContainer
4846
import com.jetbrains.gateway.welcomeScreen.MultistagePanelDelegate
4947
import com.jetbrains.rd.util.lifetime.Lifetime
48+
import kotlinx.coroutines.CoroutineScope
49+
import kotlinx.coroutines.SupervisorJob
50+
import kotlinx.coroutines.launch
5051
import software.amazon.awssdk.services.codecatalyst.CodeCatalystClient
5152
import software.amazon.awssdk.services.codecatalyst.model.InstanceType
5253
import software.aws.toolkits.core.ClientConnectionSettings
@@ -55,6 +56,7 @@ import software.aws.toolkits.core.utils.getLogger
5556
import software.aws.toolkits.jetbrains.core.AwsClientManager
5657
import software.aws.toolkits.jetbrains.core.AwsResourceCache
5758
import software.aws.toolkits.jetbrains.core.awsClient
59+
import software.aws.toolkits.jetbrains.core.coroutines.getCoroutineBgContext
5860
import software.aws.toolkits.jetbrains.core.credentials.AwsBearerTokenConnection
5961
import software.aws.toolkits.jetbrains.core.credentials.ToolkitConnectionManager
6062
import software.aws.toolkits.jetbrains.core.credentials.pinning.CodeCatalystConnection
@@ -473,7 +475,7 @@ class EnvironmentDetailsPanel(private val context: CawsSettings, lifetime: Lifet
473475
lifetime.launchOnUi {
474476
loadingPanel.startLoading()
475477
var panel: JComponent? = null
476-
lifetime.launch(Dispatchers.IO) {
478+
CoroutineScope(getCoroutineBgContext() + SupervisorJob()).launch {
477479
panel = content(project?.space)
478480
}
479481
panel?.let { wrapper.setContent(it) }

0 commit comments

Comments
 (0)