File tree 2 files changed +28
-2
lines changed
2 files changed +28
-2
lines changed Original file line number Diff line number Diff line change @@ -123,4 +123,19 @@ class ChannelUndeliveredElementTest : TestBase() {
123
123
check(! _cancelled .getAndSet(true )) { " Already cancelled" }
124
124
}
125
125
}
126
+
127
+ @Test
128
+ fun testHandlerIsNotInvoked () = runTest { // #2826
129
+ val channel = Channel <Unit > {
130
+ expectUnreached()
131
+ }
132
+
133
+ expect(1 )
134
+ launch {
135
+ expect(2 )
136
+ channel.receive()
137
+ }
138
+ channel.send(Unit )
139
+ finish(3 )
140
+ }
126
141
}
Original file line number Diff line number Diff line change @@ -32,7 +32,18 @@ public open class LinkedListNode {
32
32
this ._prev = node
33
33
}
34
34
35
+ /*
36
+ * Remove that is invoked as a virtual function with a
37
+ * potentially augmented behaviour.
38
+ * I.g. `LockFreeLinkedListHead` throws, while `SendElementWithUndeliveredHandler`
39
+ * invokes handler on remove
40
+ */
35
41
public open fun remove (): Boolean {
42
+ return removeImpl()
43
+ }
44
+
45
+ @PublishedApi
46
+ internal fun removeImpl (): Boolean {
36
47
if (_removed ) return false
37
48
val prev = this ._prev
38
49
val next = this ._next
@@ -76,7 +87,7 @@ public open class LinkedListNode {
76
87
public fun removeFirstOrNull (): Node ? {
77
88
val next = _next
78
89
if (next == = this ) return null
79
- check(next.remove ()) { " Should remove" }
90
+ check(next.removeImpl ()) { " Should remove" }
80
91
return next
81
92
}
82
93
@@ -85,7 +96,7 @@ public open class LinkedListNode {
85
96
if (next == = this ) return null
86
97
if (next !is T ) return null
87
98
if (predicate(next)) return next
88
- check(next.remove ()) { " Should remove" }
99
+ check(next.removeImpl ()) { " Should remove" }
89
100
return next
90
101
}
91
102
}
You can’t perform that action at this time.
0 commit comments