This is an automated email from the ASF dual-hosted git repository.
gnodet pushed a commit to branch maven-4.0.x
in repository https://gitbox.apache.org/repos/asf/maven.git
The following commit(s) were added to refs/heads/maven-4.0.x by this push:
new f438166fdf Fix #12052: tokenize arithmetic operators as delimiters in
ConditionParser (#12053) (#12275)
f438166fdf is described below
commit f438166fdf9645720fe9b19775566ca22ebd0204
Author: Guillaume Nodet <[email protected]>
AuthorDate: Tue Jun 16 19:33:56 2026 +0200
Fix #12052: tokenize arithmetic operators as delimiters in ConditionParser
(#12053) (#12275)
The tokenizer did not recognize `-`, `*`, `/` as delimiter characters,
so expressions like `5-3` or `6*4` (without spaces) were tokenized as
single tokens and failed to parse.
Co-authored-by: Claude Opus 4.6 (1M context) <[email protected]>
---
.../org/apache/maven/impl/model/profile/ConditionParser.java | 3 +++
.../apache/maven/impl/model/profile/ConditionParserTest.java | 12 ++++++++++++
2 files changed, 15 insertions(+)
diff --git
a/impl/maven-impl/src/main/java/org/apache/maven/impl/model/profile/ConditionParser.java
b/impl/maven-impl/src/main/java/org/apache/maven/impl/model/profile/ConditionParser.java
index 2f6a075f87..4b73b5217e 100644
---
a/impl/maven-impl/src/main/java/org/apache/maven/impl/model/profile/ConditionParser.java
+++
b/impl/maven-impl/src/main/java/org/apache/maven/impl/model/profile/ConditionParser.java
@@ -134,6 +134,9 @@ private List<String> tokenize(String expression) {
|| c == ')'
|| c == ','
|| c == '+'
+ || c == '-'
+ || c == '*'
+ || c == '/'
|| c == '>'
|| c == '<'
|| c == '='
diff --git
a/impl/maven-impl/src/test/java/org/apache/maven/impl/model/profile/ConditionParserTest.java
b/impl/maven-impl/src/test/java/org/apache/maven/impl/model/profile/ConditionParserTest.java
index 990af0d7e3..be1da09919 100644
---
a/impl/maven-impl/src/test/java/org/apache/maven/impl/model/profile/ConditionParserTest.java
+++
b/impl/maven-impl/src/test/java/org/apache/maven/impl/model/profile/ConditionParserTest.java
@@ -242,6 +242,18 @@ void testArithmeticFunctions() {
assertEquals(2.5, parser.parse("5 / 2"));
}
+ @Test
+ void testArithmeticWithoutSpaces() {
+ assertEquals(5.0, parser.parse("2+3"));
+ assertEquals(10.0, parser.parse("15-5"));
+ assertEquals(24.0, parser.parse("6*4"));
+ assertEquals(3.0, parser.parse("9/3"));
+ assertEquals(14.0, parser.parse("2+3*4"));
+ assertEquals(20.0, parser.parse("(2+3)*4"));
+ assertEquals(-5.0, parser.parse("-5"));
+ assertEquals(-5.0, parser.parse("-(2+3)"));
+ }
+
@Test
void testCombinedArithmeticAndLogic() {
assertTrue((Boolean) parser.parse("(5 > 3) && (10 / 2 == 5)"));