From d40f1b81372e1cdb101790d14c5bc8c7c304c128 Mon Sep 17 00:00:00 2001 From: Jason Zaugg Date: Tue, 29 Mar 2016 10:01:24 +1000 Subject: SI-7474 Record extra errors in Throwable#suppressedExceptions ... in parallel collection operations. Followup to bcbe38d18, which did away with the the approach to use a composite exception when more than one error happened. --- src/library/scala/collection/parallel/Tasks.scala | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'src/library') diff --git a/src/library/scala/collection/parallel/Tasks.scala b/src/library/scala/collection/parallel/Tasks.scala index c9a75752df..2a4e40dd16 100644 --- a/src/library/scala/collection/parallel/Tasks.scala +++ b/src/library/scala/collection/parallel/Tasks.scala @@ -66,13 +66,10 @@ trait Task[R, +Tp] { } private[parallel] def mergeThrowables(that: Task[_, _]) { - // 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 + if (this.throwable != null && that.throwable != null) + this.throwable.addSuppressed(that.throwable) + else if (this.throwable == null && that.throwable != null) + this.throwable = that.throwable } // override in concrete task implementations to signal abort to other tasks -- cgit v1.2.3