Created
January 24, 2012 21:03
-
-
Save jrlemieux/1672660 to your computer and use it in GitHub Desktop.
CompositeThrowable inconsistency?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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