You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2022/08/30 12:28:32 UTC

[tomcat] branch 10.0.x updated: Switch to ELException as it seems more natural here

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

markt pushed a commit to branch 10.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/10.0.x by this push:
     new cd8ac5cf64 Switch to ELException as it seems more natural here
cd8ac5cf64 is described below

commit cd8ac5cf64790f0e7eccfdbe647d7a4123c12b37
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Tue Aug 30 13:28:15 2022 +0100

    Switch to ELException as it seems more natural here
    
    The EL spec requires "error" in this case. Since this is an EL
    operation, ELException seems more natural. It is also - generally - more
    consistent with the EL API.
---
 java/org/apache/el/lang/ELArithmetic.java | 9 +++------
 webapps/docs/changelog.xml                | 5 +++++
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/java/org/apache/el/lang/ELArithmetic.java b/java/org/apache/el/lang/ELArithmetic.java
index 82804728a3..65194cc2e3 100644
--- a/java/org/apache/el/lang/ELArithmetic.java
+++ b/java/org/apache/el/lang/ELArithmetic.java
@@ -20,6 +20,8 @@ import java.math.BigDecimal;
 import java.math.BigInteger;
 import java.math.RoundingMode;
 
+import jakarta.el.ELException;
+
 import org.apache.el.util.MessageFactory;
 
 
@@ -363,9 +365,6 @@ public abstract class ELArithmetic {
             Number.class.isAssignableFrom(type);
     }
 
-    /**
-     *
-     */
     protected ELArithmetic() {
         super();
     }
@@ -395,8 +394,7 @@ public abstract class ELArithmetic {
             return coerce(Short.valueOf((short) ((Character) obj).charValue()));
         }
 
-        throw new IllegalArgumentException(MessageFactory.get("error.convert",
-                obj, obj.getClass(), "Number"));
+        throw new ELException(MessageFactory.get("error.convert", obj, obj.getClass(), "Number"));
     }
 
     protected abstract Number coerce(final String str);
@@ -404,5 +402,4 @@ public abstract class ELArithmetic {
     protected abstract Number divide(final Number num0, final Number num1);
 
     protected abstract boolean matches(final Object obj0, final Object obj1);
-
 }
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index b71bf80807..91c138ebe9 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -234,6 +234,11 @@
         Improve handling of EL error messages so instances of Number are not
         formatted in unexpected ways. (markt)
       </fix>
+      <fix>
+        Switch to using ELException rather than IllegalArgumentException when a
+        type conversion fails during an EL arithmetic operation. This is an EL
+        error so ELException seems more appropriate. (markt)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Cluster">


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org