summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/library/scala/collection/parallel/Tasks.scala12
-rw-r--r--src/library/scala/collection/parallel/package.scala7
-rw-r--r--test/files/run/t5375.check2
-rw-r--r--test/files/run/t5375.scala23
4 files changed, 18 insertions, 26 deletions
diff --git a/src/library/scala/collection/parallel/Tasks.scala b/src/library/scala/collection/parallel/Tasks.scala
index b23131c773..4aa11b25da 100644
--- a/src/library/scala/collection/parallel/Tasks.scala
+++ b/src/library/scala/collection/parallel/Tasks.scala
@@ -72,11 +72,13 @@ trait Task[R, +Tp] {
}
private[parallel] def mergeThrowables(that: Task[_, _]) {
- if (this.throwable != null && that.throwable != null) {
- // merge exceptions, since there were multiple exceptions
- this.throwable = this.throwable alongWith that.throwable
- } else if (that.throwable != null) this.throwable = that.throwable
- else this.throwable = this.throwable
+ // TODO: As soon as we target Java >= 7, use Throwable#addSuppressed
+ // to pass additional Throwables to the caller, e. g.
+ // if (this.throwable != null && that.throwable != null)
+ // this.throwable.addSuppressed(that.throwable)
+ // For now, we just use whatever Throwable comes across “first”.
+ if (this.throwable == null && that.throwable != null)
+ this.throwable = that.throwable
}
// override in concrete task implementations to signal abort to other tasks
diff --git a/src/library/scala/collection/parallel/package.scala b/src/library/scala/collection/parallel/package.scala
index 66fbad7643..b25553d2c8 100644
--- a/src/library/scala/collection/parallel/package.scala
+++ b/src/library/scala/collection/parallel/package.scala
@@ -114,7 +114,9 @@ package parallel {
def toParArray: ParArray[T]
}
+ @deprecated("This trait will be removed.", "2.11.0")
trait ThrowableOps {
+ @deprecated("This method will be removed.", "2.11.0")
def alongWith(that: Throwable): Throwable
}
@@ -133,9 +135,8 @@ package parallel {
}
/** Composite throwable - thrown when multiple exceptions are thrown at the same time. */
- final case class CompositeThrowable(
- throwables: Set[Throwable]
- ) extends Exception(
+ @deprecated("This class will be removed.", "2.11.0")
+ final case class CompositeThrowable(throwables: Set[Throwable]) extends Exception(
"Multiple exceptions thrown during a parallel computation: " +
throwables.map(t => t + "\n" + t.getStackTrace.take(10).++("...").mkString("\n")).mkString("\n\n")
)
diff --git a/test/files/run/t5375.check b/test/files/run/t5375.check
index 7d3002ffda..b1a57eeeec 100644
--- a/test/files/run/t5375.check
+++ b/test/files/run/t5375.check
@@ -1 +1 @@
-Composite throwable \ No newline at end of file
+Runtime exception
diff --git a/test/files/run/t5375.scala b/test/files/run/t5375.scala
index fa5932ff89..826ecd841e 100644
--- a/test/files/run/t5375.scala
+++ b/test/files/run/t5375.scala
@@ -1,19 +1,8 @@
-
-
-
-import collection.parallel.CompositeThrowable
-
-
-
-object Test {
-
- def main(args: Array[String]) {
- val foos = (1 to 1000).toSeq
- try {
- foos.par.map(i => if (i % 37 == 0) sys.error("i div 37") else i)
- } catch {
- case CompositeThrowable(thr) => println("Composite throwable")
- }
+object Test extends App {
+ val foos = (1 to 1000).toSeq
+ try
+ foos.par.map(i => if (i % 37 == 0) sys.error("i div 37") else i)
+ catch {
+ case ex: RuntimeException => println("Runtime exception")
}
-
}