From 57604c86cd3d4d4dadb935a0d755535afa37918c Mon Sep 17 00:00:00 2001 From: Claus Ibsen Date: Mon, 5 Mar 2018 17:32:58 +0100 Subject: [PATCH] Fixes #447: To report correct index of invalid jsonpath failure. This should add 1 to the position instead of appending 1 to its text value. Signed-off-by: Claus Ibsen --- .../java/com/jayway/jsonpath/internal/path/PathCompiler.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/json-path/src/main/java/com/jayway/jsonpath/internal/path/PathCompiler.java b/json-path/src/main/java/com/jayway/jsonpath/internal/path/PathCompiler.java index 0317311e..cc6189b8 100644 --- a/json-path/src/main/java/com/jayway/jsonpath/internal/path/PathCompiler.java +++ b/json-path/src/main/java/com/jayway/jsonpath/internal/path/PathCompiler.java @@ -484,7 +484,8 @@ public class PathCompiler { if (inBracket) { int wildCardIndex = path.indexOfNextSignificantChar(WILDCARD); if (!path.nextSignificantCharIs(wildCardIndex, CLOSE_SQUARE_BRACKET)) { - throw new InvalidPathException("Expected wildcard token to end with ']' on position " + wildCardIndex + 1); + int offset = wildCardIndex + 1; + throw new InvalidPathException("Expected wildcard token to end with ']' on position " + offset); } int bracketCloseIndex = path.indexOfNextSignificantChar(wildCardIndex, CLOSE_SQUARE_BRACKET); path.setPosition(bracketCloseIndex + 1);