Skip to content

Commit

Permalink
Fix constant Gitpod Plugin exception on Gateway startup (#20291)
Browse files Browse the repository at this point in the history
  • Loading branch information
mustard-mh authored Oct 11, 2024
1 parent 41b6404 commit 5491c82
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import org.jetbrains.io.response
import java.nio.charset.StandardCharsets

internal class GitpodAuthCallbackHandler : RestService() {
private val service = GitpodAuthService.instance
private val service = GitpodAuthService.instance.get()

override fun getServiceName(): String = service.name

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ import com.intellij.credentialStore.CredentialAttributes
import com.intellij.credentialStore.generateServiceName
import com.intellij.ide.passwordSafe.PasswordSafe
import com.intellij.openapi.Disposable
import com.intellij.openapi.application.CachedSingletonsRegistry
import com.intellij.openapi.components.Service
import com.intellij.openapi.components.service
import com.intellij.openapi.diagnostic.thisLogger
import com.intellij.util.EventDispatcher
import com.intellij.util.Url
import com.intellij.util.Urls.encodeParameters
Expand All @@ -35,6 +37,7 @@ import java.net.http.HttpResponse
import java.security.SecureRandom
import java.util.*
import java.util.concurrent.CompletableFuture
import java.util.function.Supplier
import kotlin.math.absoluteValue

@Service
Expand Down Expand Up @@ -148,7 +151,8 @@ internal class GitpodAuthService : OAuthServiceBase<Credentials>() {
}

companion object {
val instance: GitpodAuthService = service()
@Suppress("UnstableApiUsage")
val instance: Supplier<GitpodAuthService> = CachedSingletonsRegistry.lazy { service() }

private const val SERVICE_NAME = "gitpod/oauth"
private const val CLIENT_ID = "jetbrains-gateway-gitpod-plugin"
Expand Down Expand Up @@ -176,7 +180,7 @@ internal class GitpodAuthService : OAuthServiceBase<Credentials>() {
}

suspend fun authorize(gitpodHost: String): String {
val accessToken = instance.authorize(gitpodHost).await().accessToken
val accessToken = instance.get().authorize(gitpodHost).await().accessToken
setAccessToken(gitpodHost, accessToken)
return accessToken
}
Expand Down

0 comments on commit 5491c82

Please sign in to comment.