Skip to content

Commit deb3093

Browse files
authored
[JetBrains] wait for the file to be closed before returning (#20540)
* TRY IT OUT * Remove irrelevant code
1 parent 65707de commit deb3093

File tree

2 files changed

+11
-14
lines changed

2 files changed

+11
-14
lines changed

.idea/misc.xml

+3-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

components/ide/jetbrains/backend-plugin/src/main/kotlin/io/gitpod/jetbrains/remote/GitpodCLIService.kt

+8-12
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
package io.gitpod.jetbrains.remote
66

77
import com.intellij.codeWithMe.ClientId
8+
import com.intellij.codeWithMe.asContextElement
89
import com.intellij.ide.BrowserUtil
910
import com.intellij.ide.CommandLineProcessor
1011
import com.intellij.openapi.client.ClientKind
@@ -27,10 +28,7 @@ import io.netty.channel.ChannelHandlerContext
2728
import io.netty.handler.codec.http.FullHttpRequest
2829
import io.netty.handler.codec.http.QueryStringDecoder
2930
import io.prometheus.client.exporter.common.TextFormat
30-
import kotlinx.coroutines.GlobalScope
31-
import kotlinx.coroutines.delay
32-
import kotlinx.coroutines.launch
33-
import kotlinx.coroutines.runBlocking
31+
import kotlinx.coroutines.*
3432
import org.jetbrains.ide.RestService
3533
import org.jetbrains.io.response
3634
import java.io.OutputStreamWriter
@@ -113,14 +111,12 @@ class GitpodCLIService : RestService() {
113111
}
114112

115113
private fun withClient(request: FullHttpRequest, context: ChannelHandlerContext, action: suspend (project: Project?) -> Unit): String? {
116-
GlobalScope.launch {
117-
getClientSessionAndProjectAsync().let { (session, project) ->
118-
ClientId.withClientId(session.clientId) {
119-
runBlocking {
120-
action(project)
121-
}
122-
sendOk(request, context)
123-
}
114+
val scope = CoroutineScope(Dispatchers.Default)
115+
scope.launch {
116+
val (session, project) = getClientSessionAndProjectAsync()
117+
withContext(session.clientId.asContextElement()) {
118+
action(project)
119+
sendOk(request, context)
124120
}
125121
}
126122
return null

0 commit comments

Comments
 (0)