From c75cf76860e644acdd70998540d34c8685e1e564 Mon Sep 17 00:00:00 2001 From: Andrey Subbotin Date: Thu, 30 Mar 2017 13:26:36 +0400 Subject: [PATCH] PL-8851 NPE occurs when the Join-section of a custom filter specified incorrectly --- .../global/src/com/haulmont/cuba/core/sys/jpql/Parser.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/modules/global/src/com/haulmont/cuba/core/sys/jpql/Parser.java b/modules/global/src/com/haulmont/cuba/core/sys/jpql/Parser.java index 4d32458a60..90a0ab6b85 100644 --- a/modules/global/src/com/haulmont/cuba/core/sys/jpql/Parser.java +++ b/modules/global/src/com/haulmont/cuba/core/sys/jpql/Parser.java @@ -54,6 +54,11 @@ public class Parser { JPA2Parser parser = createParser(join); JPA2Parser.join_section_return aReturn = parser.join_section(); CommonTree tree = (CommonTree) aReturn.getTree(); + if (tree == null) { + parser = createParser("join " + join); + aReturn = parser.join_section(); + tree = (CommonTree) aReturn.getTree(); + } if (tree instanceof JoinVariableNode) { checkTreeForExceptions(join, tree); return Collections.singletonList((JoinVariableNode) tree); @@ -62,7 +67,7 @@ public class Parser { .filter(node -> node instanceof JoinVariableNode) .map(JoinVariableNode.class::cast) .collect(Collectors.toList()); - joins.stream().forEach(node -> checkTreeForExceptions(join, tree)); + checkTreeForExceptions(join, tree); return joins; } }