From 24d2a2024bb4761ba5a9ec5b445c99e1340860c3 Mon Sep 17 00:00:00 2001 From: Allan Erskine Date: Sat, 28 Feb 2015 23:46:02 -0500 Subject: [PATCH 1/2] Fixes #1881. Clone SystemProperties defending against ConcurrentModificationException --- testing/src/main/scala/sbt/JUnitXmlTestsListener.scala | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/testing/src/main/scala/sbt/JUnitXmlTestsListener.scala b/testing/src/main/scala/sbt/JUnitXmlTestsListener.scala index 2611486ec..2b3d48334 100644 --- a/testing/src/main/scala/sbt/JUnitXmlTestsListener.scala +++ b/testing/src/main/scala/sbt/JUnitXmlTestsListener.scala @@ -2,6 +2,7 @@ package sbt import java.io.{ IOException, StringWriter, PrintWriter, File } import java.net.InetAddress +import java.util.Hashtable import scala.collection.mutable.ListBuffer import scala.util.DynamicVariable @@ -27,7 +28,9 @@ class JUnitXmlTestsListener(val outputDir: String) extends TestsListener { val properties = { - val iter = System.getProperties.entrySet.iterator + // create a clone, defending against [[ConcurrentModificationException]] + val clonedProperties = System.getProperties.clone.asInstanceOf[Hashtable[AnyRef, AnyRef]] + val iter = clonedProperties.entrySet.iterator val props: ListBuffer[XNode] = new ListBuffer() while (iter.hasNext) { val next = iter.next From df01851f0e87661e0e7542c04afe387fe6dd86a1 Mon Sep 17 00:00:00 2001 From: Allan Erskine Date: Mon, 2 Mar 2015 10:16:35 -0500 Subject: [PATCH 2/2] Adding note for #1881. --- .../clone-properties-in-junit-tests-listener.markdown | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 notes/0.13.8/clone-properties-in-junit-tests-listener.markdown diff --git a/notes/0.13.8/clone-properties-in-junit-tests-listener.markdown b/notes/0.13.8/clone-properties-in-junit-tests-listener.markdown new file mode 100644 index 000000000..ef93007d5 --- /dev/null +++ b/notes/0.13.8/clone-properties-in-junit-tests-listener.markdown @@ -0,0 +1,10 @@ + [@aerskine]: https://github.com/aerskine + [1881]: https://github.com/sbt/sbt/issues/1881 + +### Fixes with compatibility implications + +### Improvements + +### Bug fixes + +- Fixes sporadic ConcurrentModificationException from JUnitXmlTestsListener. [#1881][1881] by [@aerskine][@aerskine]