File tree 3 files changed +8
-8
lines changed
kotlinx-coroutines-core/jvm
3 files changed +8
-8
lines changed Original file line number Diff line number Diff line change @@ -10,11 +10,10 @@ import java.lang.ref.*
10
10
11
11
// This is very limited implementation, not suitable as a generic map replacement.
12
12
// It has lock-free get and put with synchronized rehash for simplicity (and better CPU usage on contention)
13
- @OptIn(ExperimentalStdlibApi ::class )
14
13
@Suppress(" UNCHECKED_CAST" )
15
14
internal class ConcurrentWeakMap <K : Any , V : Any >(
16
15
/* *
17
- * Weak reference queue is needed when a small key is mapped to a large value and we need to promptly release a
16
+ * Weak reference queue is needed when a small key is mapped to a large value, and we need to promptly release a
18
17
* reference to the value when the key was already disposed.
19
18
*/
20
19
weakRefQueue : Boolean = false
Original file line number Diff line number Diff line change @@ -236,8 +236,9 @@ public actual open class TestBase(private var disableOutCheck: Boolean) {
236
236
if (expected != null ) {
237
237
if (! expected(e))
238
238
error(" Unexpected exception: $e " , e)
239
- } else
239
+ } else {
240
240
throw e
241
+ }
241
242
} finally {
242
243
if (ex == null && expected != null ) error(" Exception was expected but none produced" )
243
244
}
Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ class ConcurrentWeakMapOperationStressTest : TestBase() {
34
34
var generationOffset = 0L
35
35
while (! stop.value) {
36
36
val kvs = (generationOffset + batchSize * index until generationOffset + batchSize * (index + 1 ))
37
- .associateBy({ Key (it) }, { it * it })
37
+ .associateBy({ Key (it) }, { it * it })
38
38
generationOffset + = batchSize * nThreads
39
39
for ((k, v) in kvs) {
40
40
assertEquals(null , m.put(k, v))
@@ -45,8 +45,8 @@ class ConcurrentWeakMapOperationStressTest : TestBase() {
45
45
for ((k, v) in kvs) {
46
46
assertEquals(v, m.remove(k))
47
47
}
48
- for ((k, v ) in kvs) {
49
- assertEquals(null , m.get(k) )
48
+ for ((k, _ ) in kvs) {
49
+ assertEquals(null , m[k] )
50
50
}
51
51
count.incrementAndGet()
52
52
}
@@ -68,6 +68,6 @@ class ConcurrentWeakMapOperationStressTest : TestBase() {
68
68
}
69
69
stop.value = true
70
70
threads.forEach { it.join() }
71
- assertEquals(0 , m.size)
71
+ assertEquals(0 , m.size, " Unexpected map state: $m " )
72
72
}
73
- }
73
+ }
You can’t perform that action at this time.
0 commit comments