Skip to content

@jrlemieux /composite.scala
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
CompositeThrowable inconsistency?
object Test {
def main(args: Array[String]) {
def process(animal: String, n: Int) = {
if (n % 13 == 0 && n > 0)
throw new Exception("My " + animal + " hates number " + n)
n
}
def show(what: String, messages: Seq[String]) {
println(what)
messages.foreach(m => println(" - " + m))
}
def test(u: () => Any) {
println
try {
u()
} catch {
case e: scala.collection.parallel.CompositeThrowable =>
show("Composite", e.throwables.toList.map(t => t.getClass.getName + ": " + t.getMessage))
case e =>
show("Simple", Seq(e.getMessage))
}
}
test(() => (0 until 20).map(process("hamster", _)))
test(() => (0 until 20).par.map(process("hamster", _)))
test(() => (0 until 50).map(process("rabbit", _)))
test(() => (0 until 50).par.map(process("rabbit", _)))
test(() => List("cat", "dog").map(a => (0 until 50).map(process(a, _))))
test(() => List("cat", "dog").map(a => (0 until 50).par.map(process(a, _))))
test(() => List("cat", "dog").par.map(a => (0 until 50).map(process(a, _))))
test(() => List("cat", "dog").par.map(a => (0 until 50).par.map(process(a, _))))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.