From 3e46d80b62ba6b910e5fae29db79d4240eff7a8b Mon Sep 17 00:00:00 2001 From: Kalle Stenflo Date: Fri, 23 Aug 2013 13:50:48 +0200 Subject: [PATCH] Reverted exception in ArrayIndexFilter and fixed tests. --- .../com/jayway/jsonpath/internal/filter/ArrayIndexFilter.java | 3 ++- json-path/src/test/java/com/jayway/jsonpath/IssuesTest.java | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/json-path/src/main/java/com/jayway/jsonpath/internal/filter/ArrayIndexFilter.java b/json-path/src/main/java/com/jayway/jsonpath/internal/filter/ArrayIndexFilter.java index 0319d21f..83d252bf 100644 --- a/json-path/src/main/java/com/jayway/jsonpath/internal/filter/ArrayIndexFilter.java +++ b/json-path/src/main/java/com/jayway/jsonpath/internal/filter/ArrayIndexFilter.java @@ -97,7 +97,8 @@ public class ArrayIndexFilter extends PathTokenFilter { String[] indexArr = COMMA.split(trimmedCondition); if(obj == null || jsonProvider.length(obj) == 0){ - throw new PathNotFoundException("Failed to access array index: '" + condition + "' since the array is null or empty"); + //throw new PathNotFoundException("Failed to access array index: '" + condition + "' since the array is null or empty"); + return result; } if (indexArr.length == 1) { diff --git a/json-path/src/test/java/com/jayway/jsonpath/IssuesTest.java b/json-path/src/test/java/com/jayway/jsonpath/IssuesTest.java index eb805976..93ad00ae 100644 --- a/json-path/src/test/java/com/jayway/jsonpath/IssuesTest.java +++ b/json-path/src/test/java/com/jayway/jsonpath/IssuesTest.java @@ -23,7 +23,8 @@ import static org.junit.Assert.assertThat; */ public class IssuesTest { - @Test + //@Test(expected = PathNotFoundException.class) + @Test() public void issue_11() throws Exception { String json = "{ \"foo\" : [] }"; List result = JsonPath.read(json, "$.foo[?(@.rel= 'item')][0].uri");