From ba2a0926548ea20d340cc291c6f1d12377723ecd Mon Sep 17 00:00:00 2001 From: "Artem.Bukhonov" Date: Wed, 11 Sep 2024 18:18:15 +0200 Subject: [PATCH] RDCT-1695 Fallback to the local session when a service is not resolved in a frontend session GitOrigin-RevId: 5622745a9f21cad0b24c49378e84c54f453a8e2f --- .../intellij/openapi/client/ClientAwareComponentManager.kt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/platform/platform-impl/src/com/intellij/openapi/client/ClientAwareComponentManager.kt b/platform/platform-impl/src/com/intellij/openapi/client/ClientAwareComponentManager.kt index eb40f8b1dde4..a45daa4d19b5 100644 --- a/platform/platform-impl/src/com/intellij/openapi/client/ClientAwareComponentManager.kt +++ b/platform/platform-impl/src/com/intellij/openapi/client/ClientAwareComponentManager.kt @@ -48,6 +48,13 @@ abstract class ClientAwareComponentManager: ComponentManagerImpl { "Host implementation will be returned, but calling code has to be fixed: either set/promote ClientId " + "or mark the service as non per-client") } + if (service == null && session?.type == ClientType.FRONTEND) { + // if current ClientId is a frontend one and Frontend session doesn't have the service, + // we need to try looking in the local session as a fallback + // use case: coroutine has a frontend ClientId -> some code requests for a service registered as 'local' in the xml + val localSession = sessionManager.getSession(ClientId.localId) as? ClientSessionImpl ?: return null + localSession.doGetService(serviceClass = serviceClass, createIfNeeded = createIfNeeded, fallbackToShared = false) + } return service }