File tree Expand file tree Collapse file tree 3 files changed +8
-8
lines changed
kotlinx-coroutines-core/jvm Expand file tree Collapse file tree 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.*
1010
1111// This is very limited implementation, not suitable as a generic map replacement.
1212// It has lock-free get and put with synchronized rehash for simplicity (and better CPU usage on contention)
13- @OptIn(ExperimentalStdlibApi ::class )
1413@Suppress(" UNCHECKED_CAST" )
1514internal class ConcurrentWeakMap <K : Any , V : Any >(
1615 /* *
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
1817 * reference to the value when the key was already disposed.
1918 */
2019 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) {
236236 if (expected != null ) {
237237 if (! expected(e))
238238 error(" Unexpected exception: $e " , e)
239- } else
239+ } else {
240240 throw e
241+ }
241242 } finally {
242243 if (ex == null && expected != null ) error(" Exception was expected but none produced" )
243244 }
Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ class ConcurrentWeakMapOperationStressTest : TestBase() {
3434 var generationOffset = 0L
3535 while (! stop.value) {
3636 val kvs = (generationOffset + batchSize * index until generationOffset + batchSize * (index + 1 ))
37- .associateBy({ Key (it) }, { it * it })
37+ .associateBy({ Key (it) }, { it * it })
3838 generationOffset + = batchSize * nThreads
3939 for ((k, v) in kvs) {
4040 assertEquals(null , m.put(k, v))
@@ -45,8 +45,8 @@ class ConcurrentWeakMapOperationStressTest : TestBase() {
4545 for ((k, v) in kvs) {
4646 assertEquals(v, m.remove(k))
4747 }
48- for ((k, v ) in kvs) {
49- assertEquals(null , m.get(k) )
48+ for ((k, _ ) in kvs) {
49+ assertEquals(null , m[k] )
5050 }
5151 count.incrementAndGet()
5252 }
@@ -68,6 +68,6 @@ class ConcurrentWeakMapOperationStressTest : TestBase() {
6868 }
6969 stop.value = true
7070 threads.forEach { it.join() }
71- assertEquals(0 , m.size)
71+ assertEquals(0 , m.size, " Unexpected map state: $m " )
7272 }
73- }
73+ }
You can’t perform that action at this time.
0 commit comments