File tree 4 files changed +18
-26
lines changed
src/library/scala/collection/parallel 4 files changed +18
-26
lines changed Original file line number Diff line number Diff line change @@ -72,11 +72,13 @@ trait Task[R, +Tp] {
72
72
}
73
73
74
74
private [parallel] def mergeThrowables (that : Task [_, _]) {
75
- if (this .throwable != null && that.throwable != null ) {
76
- // merge exceptions, since there were multiple exceptions
77
- this .throwable = this .throwable alongWith that.throwable
78
- } else if (that.throwable != null ) this .throwable = that.throwable
79
- else this .throwable = this .throwable
75
+ // TODO: As soon as we target Java >= 7, use Throwable#addSuppressed
76
+ // to pass additional Throwables to the caller, e. g.
77
+ // if (this.throwable != null && that.throwable != null)
78
+ // this.throwable.addSuppressed(that.throwable)
79
+ // For now, we just use whatever Throwable comes across “first”.
80
+ if (this .throwable == null && that.throwable != null )
81
+ this .throwable = that.throwable
80
82
}
81
83
82
84
// override in concrete task implementations to signal abort to other tasks
Original file line number Diff line number Diff line change @@ -114,7 +114,9 @@ package parallel {
114
114
def toParArray : ParArray [T ]
115
115
}
116
116
117
+ @ deprecated(" This trait will be removed." , " 2.11.0" )
117
118
trait ThrowableOps {
119
+ @ deprecated(" This method will be removed." , " 2.11.0" )
118
120
def alongWith (that : Throwable ): Throwable
119
121
}
120
122
@@ -133,9 +135,8 @@ package parallel {
133
135
}
134
136
135
137
/** Composite throwable - thrown when multiple exceptions are thrown at the same time. */
136
- final case class CompositeThrowable (
137
- throwables : Set [Throwable ]
138
- ) extends Exception (
138
+ @ deprecated(" This class will be removed." , " 2.11.0" )
139
+ final case class CompositeThrowable (throwables : Set [Throwable ]) extends Exception (
139
140
" Multiple exceptions thrown during a parallel computation: " +
140
141
throwables.map(t => t + " \n " + t.getStackTrace.take(10 ).++ (" ..." ).mkString(" \n " )).mkString(" \n\n " )
141
142
)
Original file line number Diff line number Diff line change 1
- Composite throwable
1
+ Runtime exception
Original file line number Diff line number Diff line change 1
-
2
-
3
-
4
- import collection .parallel .CompositeThrowable
5
-
6
-
7
-
8
- object Test {
9
-
10
- def main (args : Array [String ]) {
11
- val foos = (1 to 1000 ).toSeq
12
- try {
13
- foos.par.map(i => if (i % 37 == 0 ) sys.error(" i div 37" ) else i)
14
- } catch {
15
- case CompositeThrowable (thr) => println(" Composite throwable" )
16
- }
1
+ object Test extends App {
2
+ val foos = (1 to 1000 ).toSeq
3
+ try
4
+ foos.par.map(i => if (i % 37 == 0 ) sys.error(" i div 37" ) else i)
5
+ catch {
6
+ case ex : RuntimeException => println(" Runtime exception" )
17
7
}
18
-
19
8
}
You can’t perform that action at this time.
0 commit comments