Skip to content

Commit 8d1593f

Browse files
nerzhulartintellij-monorepo-bot
authored andcommitted
IJPL-165683 Ignore ClientId assertion for one more case. Add deprecation for *PreserveClientId overloads
GitOrigin-RevId: f5699fe040ed9221b6e65e4077738db8906a7ea3
1 parent ab6818c commit 8d1593f

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

platform/rd-platform-community/src/com/intellij/openapi/rd/util/coroutineHelpers.kt

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import kotlin.coroutines.EmptyCoroutineContext
2525
* Coroutine dispatcher is being chosen in the following order: handlerScheduler (if not null) -> coroutineContext (if it has) -> this.protocol.scheduler (if not null) -> SynchronousScheduler
2626
*/
2727
@ApiStatus.Internal
28-
@DelicateCoroutinesApi
2928
fun <TReq, TRes> IRdEndpoint<TReq, TRes>.setSuspend(
3029
coroutineContext: CoroutineContext = EmptyCoroutineContext,
3130
coroutineStart: CoroutineStart = CoroutineStart.DEFAULT,
@@ -47,6 +46,7 @@ fun <TReq, TRes> IRdEndpoint<TReq, TRes>.setSuspend(
4746
* The same as [setSuspend] but add [ClientId] into [coroutineContext] to restore it in [handler]
4847
*/
4948
@ApiStatus.Internal
49+
@Deprecated("Use `setSuspend` instead`", ReplaceWith("setSuspend(coroutineContext, coroutineStart, handler)"))
5050
fun <TReq, TRes> IRdEndpoint<TReq, TRes>.setSuspendPreserveClientId(
5151
coroutineContext: CoroutineContext = EmptyCoroutineContext,
5252
coroutineStart: CoroutineStart = CoroutineStart.DEFAULT,
@@ -66,14 +66,15 @@ fun <TReq, TRes> IRdEndpoint<TReq, TRes>.setSuspendPreserveClientId(
6666
* Coroutine dispatcher is being chosen in the following order: handlerScheduler (if not null) -> coroutineContext (if it has) -> this.protocol.scheduler (if not null) -> SynchronousScheduler
6767
*/
6868
@ApiStatus.Internal
69-
@DelicateCoroutinesApi
7069
fun<T> ISource<T>.adviseSuspend(lifetime: Lifetime, coroutineContext: CoroutineContext = EmptyCoroutineContext, coroutineStart: CoroutineStart = CoroutineStart.DEFAULT, handler: suspend (T) -> Unit) {
7170
val beforeAdviseClientId = currentThreadClientId
7271
advise(lifetime) {
73-
// TODO: very very temporary hack to avoid assert until the code in RdSettingsStorageService is rewritten
74-
// TODO Moklev IJPL-173291 Dependency between RdSettingsStorageService and
72+
// TODO: very very temporary hack to avoid assertions in some cases
73+
// 1) TODO Moklev IJPL-173291 Dependency between RdSettingsStorageService and
7574
// settingsModel should be inversed to provide proper coroutine scopes where model operations are done
76-
if (!this.toString().contains("ThinClient.SettingsModel.settingsChanges")) {
75+
// 2) TODO: Dubov IJPL-173492 Inconsistent ClientId in `adviseSuspend` on a signal in `ConnectionStateProperty`
76+
if (!this.toString().contains("ThinClient.SettingsModel.settingsChanges")
77+
&& !this.toString().contains("RdOptionalProperty: `<<not bound>>`")) {
7778
// use ?. to skip cases when beforeAdviseClientId == null, it's likely valid
7879
beforeAdviseClientId?.assertClientIdConsistency("Inside advise ($this)", fallbackToLocal = false)
7980
}
@@ -89,6 +90,7 @@ fun<T> ISource<T>.adviseSuspend(lifetime: Lifetime, coroutineContext: CoroutineC
8990
* The same as [adviseSuspend] but adds ClientId into [coroutineContext] to restore it in [handler]
9091
*/
9192
@ApiStatus.Internal
93+
@Deprecated("Use `adviseSuspend` instead", ReplaceWith("adviseSuspend(lifetime, coroutineContext, coroutineStart, handler)"))
9294
fun<T> ISource<T>.adviseSuspendPreserveClientId(lifetime: Lifetime, coroutineContext: CoroutineContext = EmptyCoroutineContext, coroutineStart: CoroutineStart = CoroutineStart.DEFAULT, handler: suspend (T) -> Unit) {
9395
@OptIn(DelicateCoroutinesApi::class)
9496
adviseSuspend(lifetime, coroutineContext, coroutineStart, handler)

0 commit comments

Comments
 (0)