Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Simplifying test

  • Loading branch information...
commit 43a33350904ffffabe149fb7d6b3dad00ddc2542 1 parent 7449ecf
@mateiz mateiz authored
Showing with 7 additions and 15 deletions.
  1. +7 −15 core/src/test/scala/spark/FailureSuite.scala
View
22 core/src/test/scala/spark/FailureSuite.scala
@@ -14,7 +14,7 @@ object FailureSuiteState {
var tasksRun = 0
var tasksFailed = 0
- def clear() {
+ def clear(): Unit = synchronized {
tasksRun = 0
tasksFailed = 0
}
@@ -28,13 +28,9 @@ class FailureSuite extends FunSuite {
val results = sc.makeRDD(1 to 3, 3).map { x =>
FailureSuiteState.synchronized {
FailureSuiteState.tasksRun += 1
- }
- if (x == 1) {
- FailureSuiteState.synchronized {
- if (FailureSuiteState.tasksFailed == 0) {
- FailureSuiteState.tasksFailed += 1
- throw new Exception("Intentional task failure")
- }
+ if (x == 1 && FailureSuiteState.tasksFailed == 0) {
+ FailureSuiteState.tasksFailed += 1
+ throw new Exception("Intentional task failure")
}
}
x * x
@@ -54,13 +50,9 @@ class FailureSuite extends FunSuite {
case (k, v) =>
FailureSuiteState.synchronized {
FailureSuiteState.tasksRun += 1
- }
- if (k == 1) {
- FailureSuiteState.synchronized {
- if (FailureSuiteState.tasksFailed == 0) {
- FailureSuiteState.tasksFailed += 1
- throw new Exception("Intentional task failure")
- }
+ if (k == 1 && FailureSuiteState.tasksFailed == 0) {
+ FailureSuiteState.tasksFailed += 1
+ throw new Exception("Intentional task failure")
}
}
(k, v(0) * v(0))
Please sign in to comment.
Something went wrong with that request. Please try again.