summaryrefslogtreecommitdiff
path: root/test/files/run/t7775.scala
diff options
context:
space:
mode:
Diffstat (limited to 'test/files/run/t7775.scala')
-rw-r--r--test/files/run/t7775.scala43
1 files changed, 43 insertions, 0 deletions
diff --git a/test/files/run/t7775.scala b/test/files/run/t7775.scala
index 48b0d89974..bc69064e17 100644
--- a/test/files/run/t7775.scala
+++ b/test/files/run/t7775.scala
@@ -1,3 +1,45 @@
+import scala.concurrent._, duration._
+import ExecutionContext.Implicits.global
+import scala.tools.reflect.WrappedProperties.AccessControl._
+import java.util.concurrent.CyclicBarrier
+
+object Test extends App {
+ @volatile var done = false
+ val barrier = new CyclicBarrier(2)
+
+ val probe = Future {
+ val attempts = 1024 // previously, failed after a few
+ def fail(i: Int) = s"Failed at $i"
+ barrier.await()
+ for (i <- 1 to attempts ; p <- systemProperties)
+ p match { case (k, v) => assert (k != null && v != null, fail(i)) }
+ }
+ probe onComplete {
+ case _ => done = true
+ }
+
+ System.setProperty("foo", "fooz")
+ System.setProperty("bar", "barz")
+ barrier.await() // just for fun, wait to start mucking with properties
+
+ // continually modify properties trying to break live iteration over sys props
+ // hint: don't iterate lively over sys props
+ var alt = true
+ while (!done) {
+ if (alt) {
+ System.getProperties.remove("foo")
+ System.setProperty("bar", "barz")
+ alt = false
+ } else {
+ System.getProperties.remove("bar")
+ System.setProperty("foo", "fooz")
+ alt = true
+ }
+ }
+ Await.result(probe, Duration.Inf)
+}
+
+/*
import scala.concurrent.{duration, Future, Await, ExecutionContext}
import scala.tools.nsc.Settings
import ExecutionContext.Implicits.global
@@ -15,3 +57,4 @@ object Test {
Await.result(compiler, duration.Duration.Inf)
}
}
+*/