INT-3585: JsonPropertyAccessor: skip failed parse

JIRA: https://jira.spring.io/browse/INT-3585

Even if this fix doesn't provide an order support,
it does cover an original premise of an issue
With this fix the order of accessors doesn't matter.

* Catch an `AccessException` in the `JsonPropertyAccessor.canRead()` and return `false`
to let the rest accessors to deal with the property requested
This commit is contained in:
Artem Bilan
2021-02-24 17:09:00 -05:00
committed by Gary Russell
parent eef31d4b34
commit 51b6ba8de8
3 changed files with 35 additions and 11 deletions

View File

@@ -70,7 +70,14 @@ public class JsonPropertyAccessor implements PropertyAccessor {
@Override
public boolean canRead(EvaluationContext context, Object target, String name) throws AccessException {
JsonNode node = asJson(target);
JsonNode node;
try {
node = asJson(target);
}
catch (AccessException e) {
// Cannot parse - treat as not a JSON
return false;
}
Integer index = maybeIndex(name);
if (node instanceof ArrayNode) {
return index != null;