diff --git a/runners/flink/runner/src/main/java/org/apache/beam/runners/flink/TestFlinkRunner.java b/runners/flink/runner/src/main/java/org/apache/beam/runners/flink/TestFlinkRunner.java
index ef56b55dc9bd..8f50105a55b9 100644
--- a/runners/flink/runner/src/main/java/org/apache/beam/runners/flink/TestFlinkRunner.java
+++ b/runners/flink/runner/src/main/java/org/apache/beam/runners/flink/TestFlinkRunner.java
@@ -56,36 +56,23 @@ public static TestFlinkRunner create(boolean streaming) {
public PipelineResult run(Pipeline pipeline) {
try {
return delegate.run(pipeline);
- } catch (Throwable e) {
+ } catch (Throwable t) {
// Special case hack to pull out assertion errors from PAssert; instead there should
// probably be a better story along the lines of UserCodeException.
- Throwable cause = e;
- Throwable oldCause = e;
- PipelineExecutionException executionException = null;
- do {
-
- // find UserCodeException and throw PipelineExecutionException
- if (cause instanceof UserCodeException) {
- executionException = new PipelineExecutionException(cause.getCause());
- }
-
- if (cause.getCause() == null) {
- break;
- }
-
- oldCause = cause;
- cause = cause.getCause();
-
- } while (!oldCause.equals(cause));
- if (cause instanceof AssertionError) {
- throw (AssertionError) cause;
- } else {
- if (executionException != null) {
- throw executionException;
- } else {
- throw e;
+ UserCodeException innermostUserCodeException = null;
+ Throwable current = t;
+ for (; current.getCause() != null; current = current.getCause()) {
+ if (current instanceof UserCodeException) {
+ innermostUserCodeException = ((UserCodeException) current);
}
}
+ if (innermostUserCodeException != null) {
+ current = innermostUserCodeException.getCause();
+ }
+ if (current instanceof AssertionError) {
+ throw (AssertionError) current;
+ }
+ throw new PipelineExecutionException(current);
}
}
diff --git a/runners/google-cloud-dataflow-java/pom.xml b/runners/google-cloud-dataflow-java/pom.xml
index ff796815094e..255c32672e3b 100644
--- a/runners/google-cloud-dataflow-java/pom.xml
+++ b/runners/google-cloud-dataflow-java/pom.xml
@@ -33,7 +33,7 @@
jar
- beam-master-20170307
+ beam-master-20170314
6
diff --git a/sdks/java/core/src/main/java/org/apache/beam/sdk/testing/PAssert.java b/sdks/java/core/src/main/java/org/apache/beam/sdk/testing/PAssert.java
index 259633554b77..f6a409a3446b 100644
--- a/sdks/java/core/src/main/java/org/apache/beam/sdk/testing/PAssert.java
+++ b/sdks/java/core/src/main/java/org/apache/beam/sdk/testing/PAssert.java
@@ -286,7 +286,7 @@ public static IterableAssert that(PCollection actual) {
* with the specified reason.
*/
public static IterableAssert that(String reason, PCollection actual) {
- return new PCollectionContentsAssert<>(reason, actual);
+ return new PCollectionContentsAssert<>(actual, PAssertionSite.capture(reason));
}
/**
@@ -316,7 +316,8 @@ public static IterableAssert thatSingletonIterable(
@SuppressWarnings("unchecked") // Safe covariant cast
PCollection> actualIterables = (PCollection>) actual;
- return new PCollectionSingletonIterableAssert<>(reason, actualIterables);
+ return new PCollectionSingletonIterableAssert<>(
+ actualIterables, PAssertionSite.capture(reason));
}
/**
@@ -333,7 +334,9 @@ public static SingletonAssert thatSingleton(PCollection actual) {
* a singleton.
*/
public static SingletonAssert thatSingleton(String reason, PCollection actual) {
- return new PCollectionViewAssert<>(actual, View.asSingleton(), actual.getCoder(), reason);
+ return new PCollectionViewAssert<>(
+ actual, View.asSingleton(), actual.getCoder(), PAssertionSite.capture(reason)
+ );
}
/**
@@ -362,7 +365,7 @@ public static SingletonAssert