File tree 1 file changed +3
-1
lines changed
kotlinx-coroutines-core/common/src/selects
1 file changed +3
-1
lines changed Original file line number Diff line number Diff line change @@ -569,7 +569,7 @@ internal open class SelectImplementation<R> constructor(
569
569
when (val curState = state.value) {
570
570
// Perform a rendezvous with this select if it is in WAITING state.
571
571
is CancellableContinuation <* > -> {
572
- val clause = findClause(clauseObject) ? : continue
572
+ val clause = findClause(clauseObject) ? : continue // retry if `clauses` is already `null`
573
573
val onCancellation = clause.createOnCancellationAction(this @SelectImplementation, internalResult)
574
574
if (state.compareAndSet(curState, clause)) {
575
575
@Suppress(" UNCHECKED_CAST" )
@@ -604,6 +604,8 @@ internal open class SelectImplementation<R> constructor(
604
604
605
605
/* *
606
606
* Finds the clause with the corresponding [clause object][SelectClause.clauseObject].
607
+ * If the reference to the list of clauses is already cleared due to completion/cancellation,
608
+ * this function returns `null`
607
609
*/
608
610
private fun findClause (clauseObject : Any ) = clauses?.run {
609
611
find { it.clauseObject == = clauseObject } ? : error(" Clause with object $clauseObject is not found" )
You can’t perform that action at this time.
0 commit comments