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

sbt reported "Exception in thread "AWT-EventQueue-0" java.util.ConcurrentModificationException: mutation occurred during iteration" with sample plot codes #845

Open
liang3zy22 opened this issue Jun 3, 2022 · 0 comments

Comments

@liang3zy22
Copy link

Steps:

  1. Use following build.sbt file:

    ThisBuild / scalaVersion := "2.13.7"

    libraryDependencies += "org.scalanlp" %% "breeze" % "2.0.1-RC2"

    libraryDependencies += "org.scalanlp" %% "breeze-viz" % "2.0.1-RC2"

  2. The main scala codes:
    implicit val randss = RandBasis.mt0
    val f = Figure()
    val p = f.subplot(0)
    val x = linspace(0.0,1.0)
    p += plot(x, x ^:^ 2.0)
    p += plot(x, x ^:^ 3.0, '.')
    p.xlabel = "x axis"
    p.ylabel = "y axis"
    f.saveas("lines.png")
    val p2 = f.subplot(2,1,1)
    val g = Gaussian(0,1)
    p2 += hist(g.sample(100000),100)
    p2.title = "A normal distribution"
    f.saveas("subplots.png")

  3. Compile and run the codes.

Problem:
The sbt reported following error:
Exception in thread "AWT-EventQueue-0" java.util.ConcurrentModificationException: mutation occurred during iteration
at scala.collection.mutable.MutationTracker$.checkMutations(MutationTracker.scala:43)
at scala.collection.mutable.CheckedIndexedSeqView$CheckedIterator.hasNext(CheckedIndexedSeqView.scala:47)
at scala.collection.IterableOnceOps.foreach(IterableOnce.scala:563)
at scala.collection.IterableOnceOps.foreach$(IterableOnce.scala:561)
at scala.collection.AbstractIterable.foreach(Iterable.scala:926)
at breeze.plot.Figure$$anon$1.run(Figure.scala:120)
at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:313)
at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:770)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:715)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:740)
at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)

Expected:
No error

NOTES:
From the codes, the following part may cause the issue:
for (plot <- plots) {
contents.add(plot match { case Some(plot) => plot.panel; case None => new JPanel() })
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant