Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ConcurrentModificationException when filtering converted Java HashMap - regression #7269

Closed
scabug opened this issue Mar 19, 2013 · 3 comments
Closed
Assignees
Milestone

Comments

@scabug
Copy link

@scabug scabug commented Mar 19, 2013

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)
  }
}
@scabug
Copy link
Author

@scabug scabug commented Mar 19, 2013

Imported From: https://issues.scala-lang.org/browse/SI-7269?orig=1
Reporter: Jarek Sacha (jpsacha)
Affected Versions: 2.10.0, 2.10.1

@scabug
Copy link
Author

@scabug scabug commented Aug 22, 2013

@retronym said:
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.

@scabug
Copy link
Author

@scabug scabug commented Aug 23, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants