Scala Programming Language
  1. Scala Programming Language
  2. SI-7269

ConcurrentModificationException when filtering converted Java HashMap - regression

    Details

      Description

      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)
        }
      }
      

        Issue Links

          Activity

          Hide
          Jason Zaugg added a comment -

          Thanks for the great test case:

          I have a fix in progress: https://github.com/retronym/scala/compare/scala:2.10.x...ticket/7269?expand=1

          The commit message explains the root cause.

          Show
          Jason Zaugg added a comment - Thanks for the great test case: I have a fix in progress: https://github.com/retronym/scala/compare/scala:2.10.x...ticket/7269?expand=1 The commit message explains the root cause.
          Show
          Jason Zaugg added a comment - https://github.com/scala/scala/pull/2866

            People

            • Assignee:
              Jason Zaugg
              Reporter:
              Jarek Sacha
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development