Переглянути джерело

[TEST] fix possible NPE in ClientYamlTestExecutionContext

Simon Willnauer 9 роки тому
батько
коміт
825b80f2a6

+ 3 - 1
test/framework/src/main/java/org/elasticsearch/test/rest/yaml/ClientYamlTestExecutionContext.java

@@ -75,8 +75,10 @@ public class ClientYamlTestExecutionContext {
             response = e.getRestTestResponse();
             throw e;
         } finally {
+            // if we hit a bad exception the response is null
+            Object repsponseBody = response != null ? response.getBody() : null;
             //we always stash the last response body
-            stash.stashValue("body", response.getBody());
+            stash.stashValue("body", repsponseBody);
         }
     }