This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 9.0.x in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/9.0.x by this push: new 56cb1be6bf EL spec requires remainder() rather than mod() 56cb1be6bf is described below commit 56cb1be6bf7b784d191978c944bda53332ade296 Author: Mark Thomas <ma...@apache.org> AuthorDate: Wed Aug 31 20:49:29 2022 +0100 EL spec requires remainder() rather than mod() --- java/org/apache/el/lang/ELArithmetic.java | 2 +- test/org/apache/el/lang/TestELArithmetic.java | 8 ++++++++ webapps/docs/changelog.xml | 6 ++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/java/org/apache/el/lang/ELArithmetic.java b/java/org/apache/el/lang/ELArithmetic.java index 59506a5a7b..463772bbc4 100644 --- a/java/org/apache/el/lang/ELArithmetic.java +++ b/java/org/apache/el/lang/ELArithmetic.java @@ -113,7 +113,7 @@ public abstract class ELArithmetic { @Override protected Number mod(Number num0, Number num1) { - return ((BigInteger) num0).mod((BigInteger) num1); + return ((BigInteger) num0).remainder((BigInteger) num1); } @Override diff --git a/test/org/apache/el/lang/TestELArithmetic.java b/test/org/apache/el/lang/TestELArithmetic.java index bd47393c1b..1daa02fa7d 100644 --- a/test/org/apache/el/lang/TestELArithmetic.java +++ b/test/org/apache/el/lang/TestELArithmetic.java @@ -94,6 +94,14 @@ public class TestELArithmetic { Assert.assertEquals(Long.valueOf(0), result); } + @Test + public void testMod03() { + ELProcessor processor = new ELProcessor(); + // Large so BigInteger rather than Long is used internally + BigInteger result = processor.eval("1 % -9999999999999999999"); + Assert.assertEquals(BigInteger.valueOf(1), result); + } + @Test public void testUnaryMinus01() { ELProcessor processor = new ELProcessor(); diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index eb0f1efd52..70eb12e173 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -247,6 +247,12 @@ error when invoking a static method on an instance of the class rather than directly on the class. (markt) </fix> + <fix> + Use <code>BigInteger.remainder()</code> rather than + <code>BigInteger.mod()</code> when performing the modulus operation for + instances of <code>BigInteger</code> as part of an EL expression. + (markt) + </fix> </changelog> </subsection> <subsection name="Cluster"> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org