We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
This error occurs when predicatevisitor is used as the visitor of AST
Predicate<Element> predicate = condition.query(new PredicateVisitor<>());
I have a collection like this
[ { "_id": "604da82b13b1687602fd97e5", "author": [ { "_VALUE": "Frank Piessens" } ] }, { "_id": "604da89613b1687602141823", "author": null } ]
The RSQL query will process
author._VALUE=="Frank Piessens"
Then the error happended.The log is very simple.
java.lang.NullPointerException: null at com.github.rutledgepaulv.qbuilders.visitors.PredicateVisitor.recurseSingle(PredicateVisitor.java:232) ~[q-builders-1.5.jar:na] ...
I found out that the code in PredicateVisitor.recurseSingle isn't null safe.The if statement will throw a exception,when parameter root is null.So I override the method PredicateVisitor.recurseSingle in q-builder https://github.com/RutledgePaulV/q-builders/blob/develop/src/main/java/com/github/rutledgepaulv/qbuilders/visitors/PredicateVisitor.java
PredicateVisitor.recurseSingle
private boolean recurseSingle(Object root, String field, ComparisonNode node, BiPredicate<Object, Object> func) { //Add an if statement //Ensure null safe if (root == null) { return Stream.empty().anyMatch(t -> resolveSingleField(t, field, node, func)); } if (root.getClass().isArray()) { return Arrays.stream((Object[]) root).anyMatch(t -> resolveSingleField(t, field, node, func)); } if (root instanceof Collection) { return ((Collection<Object>) root).stream().anyMatch(t -> resolveSingleField(t, field, node, func)); } return resolveSingleField(root, field, node, func); }
Hope to help others.
The text was updated successfully, but these errors were encountered:
No branches or pull requests
This error occurs when predicatevisitor is used as the visitor of AST
I have a collection like this
The RSQL query will process
Then the error happended.The log is very simple.
I found out that the code in
PredicateVisitor.recurseSingle
isn't null safe.The if statement will throw a exception,when parameter root is null.So I override the methodPredicateVisitor.recurseSingle
in q-builder https://github.com/RutledgePaulV/q-builders/blob/develop/src/main/java/com/github/rutledgepaulv/qbuilders/visitors/PredicateVisitor.javaHope to help others.
The text was updated successfully, but these errors were encountered: