You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by he...@apache.org on 2021/06/17 10:55:32 UTC

[commons-jexl] branch master updated: JEXL-342: fixed error handling (inner JexlException.Method throw) and reporting (line info)

This is an automated email from the ASF dual-hosted git repository.

henrib pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-jexl.git


The following commit(s) were added to refs/heads/master by this push:
     new d7c2452  JEXL-342: fixed error handling (inner JexlException.Method throw) and reporting (line info)
d7c2452 is described below

commit d7c2452200fd8e05a64cf6c56f47b146a926025c
Author: henrib <he...@apache.org>
AuthorDate: Thu Jun 17 12:55:26 2021 +0200

    JEXL-342: fixed error handling (inner JexlException.Method throw) and reporting (line info)
---
 .../java/org/apache/commons/jexl3/internal/Interpreter.java    | 10 ++++++----
 src/main/java/org/apache/commons/jexl3/parser/JexlNode.java    |  2 +-
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/src/main/java/org/apache/commons/jexl3/internal/Interpreter.java b/src/main/java/org/apache/commons/jexl3/internal/Interpreter.java
index d44224a..2aec6ac 100644
--- a/src/main/java/org/apache/commons/jexl3/internal/Interpreter.java
+++ b/src/main/java/org/apache/commons/jexl3/internal/Interpreter.java
@@ -1683,10 +1683,8 @@ public class Interpreter extends InterpreterBase {
                 narrow = true;
                 // continue;
             }
-            // we have either evaluated and returned or no method was found
-            return node.isSafeLhs(isSafe())
-                    ? null
-                    : unsolvableMethod(node, methodName, argv);
+        } catch (JexlException.Method xmethod) {
+            // ignore and handle at end; treat as an inner discover that fails
         } catch (final JexlException.TryFailed xany) {
             throw invocationException(node, methodName, xany);
         } catch (final JexlException xthru) {
@@ -1694,6 +1692,10 @@ public class Interpreter extends InterpreterBase {
         } catch (final Exception xany) {
             throw invocationException(node, methodName, xany);
         }
+        // we have either evaluated and returned or no method was found
+        return node.isSafeLhs(isSafe())
+                ? null
+                : unsolvableMethod(node, methodName, argv);
     }
 
     @Override
diff --git a/src/main/java/org/apache/commons/jexl3/parser/JexlNode.java b/src/main/java/org/apache/commons/jexl3/parser/JexlNode.java
index 1ecd825..0922712 100644
--- a/src/main/java/org/apache/commons/jexl3/parser/JexlNode.java
+++ b/src/main/java/org/apache/commons/jexl3/parser/JexlNode.java
@@ -85,7 +85,7 @@ public abstract class JexlNode extends SimpleNode {
             final int c = lc & 0xfff;
             final int l = lc >> 0xc;
             // at least an info with line/column number
-            return info != null? info.at(l, c) : new JexlInfo(null, l, c);
+            return info != null? info.at(info.getLine() + l - 1, c) : new JexlInfo(null, l, c);
         }
         // weird though; no jjSetFirstToken(...) ever called?
         return info;