diff options
author | Paul Phillips <paulp@improving.org> | 2013-01-25 07:57:48 -0800 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2013-01-25 07:57:48 -0800 |
commit | 417304514b664e5f66bfc06fb2b0e86b99d23a63 (patch) | |
tree | e4b4b5516667615567ac65ed4bb6a498399b43d0 /test/files/run | |
parent | 4e27a23082cc0fefa1b73c9b1f180547794aa5ff (diff) | |
parent | 0d01cc1c300b718afd1fe69d5030d36d8000e0cd (diff) | |
download | scala-417304514b664e5f66bfc06fb2b0e86b99d23a63.tar.gz scala-417304514b664e5f66bfc06fb2b0e86b99d23a63.tar.bz2 scala-417304514b664e5f66bfc06fb2b0e86b99d23a63.zip |
Merge pull request #1902 from paulp/issue/6969
SI-6969, mishandling of SoftReferences in method cache.
Diffstat (limited to 'test/files/run')
-rw-r--r-- | test/files/run/t6969.check | 1 | ||||
-rw-r--r-- | test/files/run/t6969.scala | 28 |
2 files changed, 29 insertions, 0 deletions
diff --git a/test/files/run/t6969.check b/test/files/run/t6969.check new file mode 100644 index 0000000000..78297812c9 --- /dev/null +++ b/test/files/run/t6969.check @@ -0,0 +1 @@ +All threads completed. diff --git a/test/files/run/t6969.scala b/test/files/run/t6969.scala new file mode 100644 index 0000000000..8cfc28c1e5 --- /dev/null +++ b/test/files/run/t6969.scala @@ -0,0 +1,28 @@ +object Test { + private type Clearable = { def clear(): Unit } + private def choke() = { + try new Array[Object]((Runtime.getRuntime().maxMemory min Int.MaxValue).toInt) + catch { + case _: OutOfMemoryError => // what do you mean, out of memory? + case t: Throwable => println(t) + } + } + private def f(x: Clearable) = x.clear() + class Choker(id: Int) extends Thread { + private def g(iteration: Int) = { + val map = scala.collection.mutable.Map[Int, Int](1 -> 2) + try f(map) catch { case t: NullPointerException => println(s"Failed at $id/$iteration") ; throw t } + choke() + } + override def run() { + 1 to 50 foreach g + } + } + + def main(args: Array[String]): Unit = { + val threads = 1 to 3 map (id => new Choker(id)) + threads foreach (_.start()) + threads foreach (_.join()) + println("All threads completed.") + } +} |