This is an automated email from the ASF dual-hosted git repository.

zhuzh pushed a commit to branch release-1.9
in repository https://gitbox.apache.org/repos/asf/flink.git

commit b935c526aea5952bd6406e09ca12829c69bcffe8
Author: Zhu Zhu <reed...@gmail.com>
AuthorDate: Fri Jan 10 16:33:02 2020 +0800

    [hotfix][runtime] ExecutionGraph failure cause cannot be null if job is 
FAILED
---
 .../main/java/org/apache/flink/runtime/jobmaster/JobResult.java  | 6 +++---
 .../java/org/apache/flink/runtime/jobmaster/JobResultTest.java   | 9 +++++++++
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git 
a/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/JobResult.java 
b/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/JobResult.java
index 3dc63ff..57183e6 100644
--- 
a/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/JobResult.java
+++ 
b/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/JobResult.java
@@ -43,6 +43,7 @@ import java.util.Optional;
 
 import static java.util.Objects.requireNonNull;
 import static org.apache.flink.util.Preconditions.checkArgument;
+import static org.apache.flink.util.Preconditions.checkNotNull;
 
 /**
  * Similar to {@link org.apache.flink.api.common.JobExecutionResult} but with 
an optional
@@ -234,10 +235,9 @@ public class JobResult implements Serializable {
 
                if (jobStatus == JobStatus.FAILED) {
                        final ErrorInfo errorInfo = 
accessExecutionGraph.getFailureInfo();
+                       checkNotNull(errorInfo, "No root cause is found for the 
job failure.");
 
-                       if (errorInfo != null) {
-                               
builder.serializedThrowable(errorInfo.getException());
-                       }
+                       builder.serializedThrowable(errorInfo.getException());
                }
 
                return builder.build();
diff --git 
a/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/JobResultTest.java
 
b/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/JobResultTest.java
index 635df92..d7a2f4a 100644
--- 
a/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/JobResultTest.java
+++ 
b/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/JobResultTest.java
@@ -133,4 +133,13 @@ public class JobResultTest extends TestLogger {
                        assertThat(expected.getCause(), is(equalTo(cause)));
                }
        }
+
+       @Test(expected = NullPointerException.class)
+       public void testFailureResultRequiresFailureCause() {
+               JobResult.createFrom(
+                       new ArchivedExecutionGraphBuilder()
+                               .setJobID(new JobID())
+                               .setState(JobStatus.FAILED)
+                               .build());
+       }
 }

Reply via email to