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 2022/03/14 09:23:08 UTC

[commons-jexl] branch master updated: JEXL-362: avoid 0 positions in JexlInfo

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 38e1e99  JEXL-362: avoid 0 positions in JexlInfo
38e1e99 is described below

commit 38e1e99a685e8c91fc1acf881fcfd713fa6a9754
Author: henrib <he...@apache.org>
AuthorDate: Mon Mar 14 10:23:02 2022 +0100

    JEXL-362: avoid 0 positions in JexlInfo
---
 .../java/org/apache/commons/jexl3/JexlInfo.java    | 24 ++++++++--------------
 1 file changed, 9 insertions(+), 15 deletions(-)

diff --git a/src/main/java/org/apache/commons/jexl3/JexlInfo.java b/src/main/java/org/apache/commons/jexl3/JexlInfo.java
index ba77133..6b87e3b 100644
--- a/src/main/java/org/apache/commons/jexl3/JexlInfo.java
+++ b/src/main/java/org/apache/commons/jexl3/JexlInfo.java
@@ -72,8 +72,8 @@ public class JexlInfo {
      */
     public JexlInfo(final String source, final int l, final int c) {
         name = source;
-        line = l;
-        column = c;
+        line = l <= 0? 1: l;
+        column = c <= 0? 1 : c;
     }
 
     /**
@@ -99,8 +99,8 @@ public class JexlInfo {
             }
         }
         this.name = se != null ? se.getClassName() + "." + se.getMethodName() + ":" + se.getLineNumber() : "?";
-        this.line = 0;
-        this.column = 0;
+        this.line = 1;
+        this.column = 1;
     }
 
     /**
@@ -120,9 +120,7 @@ public class JexlInfo {
      * @param copy the instance to copy
      */
     protected JexlInfo(final JexlInfo copy) {
-        name = copy.getName();
-        line = copy.getLine();
-        column = copy.getColumn();
+        this(copy.getName(), copy.getLine(), copy.getColumn());
     }
 
     /**
@@ -133,14 +131,10 @@ public class JexlInfo {
     @Override
     public String toString() {
         final StringBuilder sb = new StringBuilder(name != null? name : "");
-        if (line > 0) {
-            sb.append("@");
-            sb.append(line);
-            if (column > 0) {
-                sb.append(":");
-                sb.append(column);
-            }
-        }
+        sb.append("@");
+        sb.append(line);
+        sb.append(":");
+        sb.append(column);
         final JexlInfo.Detail dbg = getDetail();
         if (dbg!= null) {
             sb.append("![");