Filtering a wrapped Java map throws ConcurrentModificationException. This did not happen in Scala 2.9, but happens in 2.10, including 2.10.1. In the example below call to retain results in exception.
package issues.issueXX
import org.scalatest.FlatSpec
import scala.collection.JavaConversions._
import scala.collection.mutable
class MapRetainSpec extends FlatSpec {
"Scala Map conversion" should "support 'retain'" in {
val mapJ = new java.util.HashMap[Int, String]
val mapS: mutable.Map[Int, String] = mapJ
(10 to 20).foreach(i => mapS += ((i, i.toString)))
assert(11 === mapS.size)
// ConcurrentModificationException thrown in the following line
mapS.retain((i, str) => i % 2 == 0)
assert(6 === mapS.size)
}
}
Filtering a wrapped Java map throws ConcurrentModificationException. This did not happen in Scala 2.9, but happens in 2.10, including 2.10.1. In the example below call to
retainresults in exception.