Do not allow using getOrPut on concurrent maps.
#KT-5800 In Progress
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package test.collections
|
||||
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
import kotlin.test.*
|
||||
import org.junit.Test as test
|
||||
|
||||
@@ -37,4 +38,15 @@ class MapJVMTest {
|
||||
assertEquals("A", prop.getProperty("a", "fail"))
|
||||
assertEquals("B", prop.getProperty("b", "fail"))
|
||||
}
|
||||
|
||||
test fun getOrPutFailsOnConcurrentMap() {
|
||||
val map = ConcurrentHashMap<String, Int>()
|
||||
|
||||
fails {
|
||||
map.getOrPut("x") { 1 }
|
||||
}
|
||||
expect(1) {
|
||||
(map as MutableMap<String, Int>).getOrPut("x") { 1 }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user