handle indefinite results in JsonPath transformations #4951
Conversation
...as JsonPath may return a List if multiple elements matched, even if they were correctly filtered down to a single element. fixes eclipse-archived#4862 Signed-off-by: Simon Kaufmann <simon.kfm@googlemail.com>
Hey Simon,
|
return list.get(0).toString(); | ||
} | ||
if (list.size() > 1) { | ||
logger.warn("The JsonPath expression yielded more than one result: {}", list); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Imho this error doesn't imply that NULL is returned... What's the end user supposed to do here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the end user supposed to do here?
Check out the code from github and try to understand the program's behavior? 😉
How about:
Returning NULL because the JsonPath expression yielded more than one result: {} - did you forget to add a filter expression?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A statement by a true developer 😁 How about
JsonPath expression with more than one result not allowed, please adapt your selector. Result: {}
(Result in the end because it could become nasty...)
Signed-off-by: Simon Kaufmann <simon.kfm@googlemail.com>
@ThomDietrich Would you like to approve that changes? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lgtm! Thanks @SJKA
…ed#4951) ...as JsonPath may return a List if multiple elements matched, even if they were correctly filtered down to a single element. fixes eclipse-archived#4862 Signed-off-by: Simon Kaufmann <simon.kfm@googlemail.com>
...as JsonPath may return a List if multiple elements matched,
even if they were correctly filtered down to a single element.
fixes #4862
Signed-off-by: Simon Kaufmann simon.kfm@googlemail.com