Browse Source

Rest tests: More defense around stashing body

Integration tests failed:
https://elasticsearch-ci.elastic.co/job/elastic+elasticsearch+master+multijob-intake/483/console

We'll see if the rest tests were hiding some other failure.
Nik Everett 9 years ago
parent
commit
ef2e3a8c39

+ 3 - 0
test/framework/src/main/java/org/elasticsearch/test/rest/Stash.java

@@ -88,6 +88,9 @@ public class Stash implements ToXContent {
      */
     public Object unstashValue(String value) throws IOException {
         if (value.startsWith("$body.")) {
+            if (response == null) {
+                return null;
+            }
             return response.evaluate(value.substring("$body".length()), this);
         }
         Object stashedValue = stash.get(value.substring(1));

+ 5 - 1
test/framework/src/main/java/org/elasticsearch/test/rest/client/RestResponse.java

@@ -51,7 +51,11 @@ public class RestResponse {
      */
     public Object getBody() throws IOException {
         if (isJson()) {
-            return parsedResponse().evaluate("");
+            JsonPath parsedResponse = parsedResponse();
+            if (parsedResponse == null) {
+                return null;
+            }
+            return parsedResponse.evaluate("");
         }
         return response.getBody();
     }