(commons-jexl) branch master updated: JEXL-424: fully resolve sandbox inheritable permissions through super-interfaces and super-classes (vs cache lookup); - added test;
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 78b3dd90 JEXL-424: fully resolve sandbox inheritable permissions through super-interfaces and super-classes (vs cache lookup); - added test; 78b3dd90 is described below commit 78b3dd90f07d86531c8c99f6f9b5bea00bea8205 Author: Henri Biestro AuthorDate: Tue Jun 18 17:52:26 2024 +0200 JEXL-424: fully resolve sandbox inheritable permissions through super-interfaces and super-classes (vs cache lookup); - added test; --- .../commons/jexl3/introspection/JexlSandbox.java | 56 -- .../commons/jexl3/introspection/SandboxTest.java | 37 ++ 2 files changed, 78 insertions(+), 15 deletions(-) diff --git a/src/main/java/org/apache/commons/jexl3/introspection/JexlSandbox.java b/src/main/java/org/apache/commons/jexl3/introspection/JexlSandbox.java index 241e3410..cae92e27 100644 --- a/src/main/java/org/apache/commons/jexl3/introspection/JexlSandbox.java +++ b/src/main/java/org/apache/commons/jexl3/introspection/JexlSandbox.java @@ -20,6 +20,7 @@ package org.apache.commons.jexl3.introspection; import java.util.HashMap; import java.util.HashSet; import java.util.Map; +import java.util.Objects; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; @@ -67,7 +68,7 @@ import java.util.concurrent.ConcurrentHashMap; */ public final class JexlSandbox { /** - * A allow set of names. + * An allow set of names. */ static class AllowSet extends Names { /** The map of controlled names and aliases. */ @@ -108,12 +109,19 @@ public final class JexlSandbox { } return actual; } + +@Override +public String toString() { +return "allow{" + (names == null? "all" : Objects.toString(names.entrySet())) + "}"; +} } + /** * @deprecated since 3.2, use {@link BlockSet} */ @Deprecated public static final class BlackSet extends BlockSet {} + /** * A block set of names. */ @@ -141,12 +149,17 @@ public final class JexlSandbox { // if name is null and contained in set, explicit null aka NULL return names != null && !names.contains(name) ? name : name != null ? null : NULL; } + +@Override +public String toString() { +return "block{" + (names == null? "all" :Objects.toString(names)) + "}"; +} } + /** * A base set of names. */ public abstract static class Names { - /** * Adds a name to this set. * @@ -259,7 +272,7 @@ public final class JexlSandbox { } /** - * @return whether these permissions applies to derived classes. + * @return whether these permissions apply to derived classes. */ public boolean isInheritable() { return inheritable; @@ -331,8 +344,8 @@ public final class JexlSandbox { } @Override -protected Names copy() { -return this; +public String toString() { +return "allowAll"; } }; @@ -346,13 +359,13 @@ public final class JexlSandbox { } @Override -protected Names copy() { -return this; +public String get(final String name) { +return name == null ? NULL : null; } @Override -public String get(final String name) { -return name == null ? NULL : null; +public String toString() { +return "blockAll"; } }; @@ -533,12 +546,23 @@ public final class JexlSandbox { */ @SuppressWarnings("null") // clazz can not be null since permissions would be not null and block; public Permissions get(final Class clazz) { -Permissions permissions = clazz == null ? BLOCK_ALL : sandbox.get(clazz.getName()); +// we only store the result for classes we actively seek permissions for +return clazz == null ? BLOCK_ALL : compute(clazz, true); +} + +/** + * Computes and optionally the permissions associated to a class. + * @param clazz the class + * @param store whether the resulting permissions should be stored in the sandbox + * @return the permissions + */ +private Permissions compute(final Class clazz, boolean store) { +Permissions permissions = sandbox.get(clazz.getName()); if (permissions == null) { if (inherit) { // find first inherited interface that defines permissions for (final Class inter : clazz.getInterfaces()) { -p
(commons-jexl) branch master updated: JEXL: fix parsing error caused by ternary and ns call embedded in lambda via method call ;
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 b2d7c7ee JEXL: fix parsing error caused by ternary and ns call embedded in lambda via method call ; b2d7c7ee is described below commit b2d7c7eef909b23e79b88c6f203087bd17a1eb3b Author: Henri Biestro AuthorDate: Wed May 29 15:49:38 2024 +0200 JEXL: fix parsing error caused by ternary and ns call embedded in lambda via method call ; --- .../org/apache/commons/jexl3/parser/Parser.jjt | 9 ++- .../org/apache/commons/jexl3/Issues400Test.java| 31 +- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/apache/commons/jexl3/parser/Parser.jjt b/src/main/java/org/apache/commons/jexl3/parser/Parser.jjt index 2aa71f9c..b6a6d896 100644 --- a/src/main/java/org/apache/commons/jexl3/parser/Parser.jjt +++ b/src/main/java/org/apache/commons/jexl3/parser/Parser.jjt @@ -1142,9 +1142,16 @@ void MethodCall() #void : {} (MemberAccess() (LOOKAHEAD() Arguments())+) #MethodNode(>1) } + +void MethodCallLookahead() #void : {} +{ +MemberAccess() +} + + void MemberExpression() #void : {} { -LOOKAHEAD(MethodCall()) MethodCall() | MemberAccess() +LOOKAHEAD(MethodCallLookahead()) MethodCall() | MemberAccess() } void ValueExpression() #void : {} diff --git a/src/test/java/org/apache/commons/jexl3/Issues400Test.java b/src/test/java/org/apache/commons/jexl3/Issues400Test.java index fb64b811..f0778cea 100644 --- a/src/test/java/org/apache/commons/jexl3/Issues400Test.java +++ b/src/test/java/org/apache/commons/jexl3/Issues400Test.java @@ -397,8 +397,18 @@ public class Issues400Test { } } + public static class VinzCaller { +private final JexlContext context; +VinzCaller(JexlContext context) { + this.context = context; +} +public Object execute(JexlScript script) { + return script.execute(context); +} + } + @Test - public void testNamespaceVsTernary() { + public void testNamespaceVsTernary0() { VinzContext ctxt = new VinzContext(); ctxt.set("Users", "USERS"); final JexlEngine jexl = new JexlBuilder().safe(false).strict(true).silent(false).create(); @@ -413,4 +423,23 @@ public class Issues400Test { r = script.execute(ctxt); Assert.assertEquals("USERS.user", r); } + + @Test + public void testNamespaceVsTernary1() { +VinzContext ctxt = new VinzContext(); +ctxt.set("Users", "USERS"); +ctxt.set("vinz", new VinzCaller(ctxt)); +final JexlEngine jexl = new JexlBuilder().safe(false).strict(true).silent(false).create(); +JexlScript script = jexl.createScript( + "vinz.execute(() -> {\n" ++ " var test = 42;\n" ++ " var user = useTest ? test : member(Users, 'user');\n" ++ "})\n" , "useTest"); +Object r = script.execute(ctxt, false); +Assert.assertNotNull(r); +Assert.assertEquals("USERS.user", r); +r = script.execute(ctxt, true); +Assert.assertNotNull(r); +Assert.assertEquals(42, r); + } }
(commons-jexl) branch master updated: JEXL: getting ready for 3.4; - release notes; - remove useless code;
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 39551685 JEXL: getting ready for 3.4; - release notes; - remove useless code; 39551685 is described below commit 395516851e1ffdd241220bb45a19248a0464dfa1 Author: Henri Biestro AuthorDate: Sat May 25 10:46:45 2024 +0200 JEXL: getting ready for 3.4; - release notes; - remove useless code; --- .../internal/introspection/ArrayIterator.java | 8 -- .../introspection/EnumerationIterator.java | 5 - src/site/site.xml | 2 +- src/site/xdoc/relnotes34.xml | 157 + 4 files changed, 158 insertions(+), 14 deletions(-) diff --git a/src/main/java/org/apache/commons/jexl3/internal/introspection/ArrayIterator.java b/src/main/java/org/apache/commons/jexl3/internal/introspection/ArrayIterator.java index 3cb09e4f..0df2e032 100644 --- a/src/main/java/org/apache/commons/jexl3/internal/introspection/ArrayIterator.java +++ b/src/main/java/org/apache/commons/jexl3/internal/introspection/ArrayIterator.java @@ -87,12 +87,4 @@ public class ArrayIterator implements Iterator { public boolean hasNext() { return pos < size; } - -/** - * No op--merely added to satify the Iterator interface. - */ -@Override -public void remove() { -throw new UnsupportedOperationException(); -} } \ No newline at end of file diff --git a/src/main/java/org/apache/commons/jexl3/internal/introspection/EnumerationIterator.java b/src/main/java/org/apache/commons/jexl3/internal/introspection/EnumerationIterator.java index 7d5523f5..b9c1af56 100644 --- a/src/main/java/org/apache/commons/jexl3/internal/introspection/EnumerationIterator.java +++ b/src/main/java/org/apache/commons/jexl3/internal/introspection/EnumerationIterator.java @@ -50,9 +50,4 @@ public class EnumerationIterator implements Iterator { public boolean hasNext() { return enumeration.hasMoreElements(); } - -@Override -public void remove() { -// not implemented -} } \ No newline at end of file diff --git a/src/site/site.xml b/src/site/site.xml index fe28e10c..ff53d369 100644 --- a/src/site/site.xml +++ b/src/site/site.xml @@ -25,7 +25,7 @@ - + diff --git a/src/site/xdoc/relnotes34.xml b/src/site/xdoc/relnotes34.xml new file mode 100644 index ..477a8dce --- /dev/null +++ b/src/site/xdoc/relnotes34.xml @@ -0,0 +1,157 @@ + + + + + +Apache Commons JEXL 3.4 Release Notes + + + + + +Version 3.4 is source and binary compatible with 3.3. + + + + +Since 3.3 release, the default setting for permissions that determine which packages, classes and methods are +accessible to scripts has been reduced to a very narrow set. When migrating from previous version of JEXL, +this may result in breaking your application behavior ; this breaking change requires remediation in your code. + + +Despite the obvious inconvenience - our sincere apologies on the matter -, how much functional and semantic +power is accessible through scripts has a real impact on your application security and stability ; +that potential risk requires an informed review and conscious choice on your end. + + +To mitigate the change, you can revert to the previous behavior with one line of code +(see JexlPermissions, +JexlBuilder +and +JexlScriptEngine +) or use this +opportunity to reduce exposure. Whether Files, URLs, networking, processes, class-loaders or reflection classes +or whether loops or side effects are accessible are part of your choice to make. + + + + +Features and permissions are easier to define through new methods. + + +Some new syntaxes are introduced ; try/catch/finally (including with resources), +an array-access safe navigation ((x?[y]), strict equality/inequality operators (===, !==), +instanceof/!instanceof operators and more permissive structured literals. + + + + + + + +https://issues.apache.org/jira/browse/JEXL-423>">JEXL-423: +Add support for instanceof / !instanceof + + +https://issues.apache.org/jira/browse/JEXL-422>">JEXL-422: +Add strict equality (===) and inequality (!==) operators + + +https://issues.apache.org/jira/browse/JEXL-421>">JEXL-421: +ArrayBuilder: array type should
(commons-jexl) branch master updated: JEXL: getting ready for 3.4; - added tests to (re)improve coverage; - removed useless code; - updated doc, changes, release notes
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 0fdb020c JEXL: getting ready for 3.4; - added tests to (re)improve coverage; - removed useless code; - updated doc, changes, release notes 0fdb020c is described below commit 0fdb020c2eeec9f03b8615062620fc98c8ab65d1 Author: Henri Biestro AuthorDate: Fri May 24 19:02:58 2024 +0200 JEXL: getting ready for 3.4; - added tests to (re)improve coverage; - removed useless code; - updated doc, changes, release notes --- RELEASE-NOTES.txt | 2 + src/changes/changes.xml| 6 + .../org/apache/commons/jexl3/JexlArithmetic.java | 4 +- .../commons/jexl3/internal/IntegerRange.java | 10 - .../apache/commons/jexl3/internal/Interpreter.java | 4 +- .../apache/commons/jexl3/internal/LongRange.java | 10 - .../commons/jexl3/internal/TemplateEngine.java | 20 -- src/site/xdoc/reference/syntax.xml | 36 +++- .../org/apache/commons/jexl3/ArithmeticTest.java | 226 - .../apache/commons/jexl3/internal/RangeTest.java | 67 ++ .../jexl3/scripting/JexlScriptEngineTest.java | 17 +- 11 files changed, 342 insertions(+), 60 deletions(-) diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt index 2492472d..e075f82c 100644 --- a/RELEASE-NOTES.txt +++ b/RELEASE-NOTES.txt @@ -38,6 +38,8 @@ more permissive structured literals. See the JIRA tickets for more details. New Features in 3.4: +* JEXL-423: Add support for instanceof / !instanceof +* JEXL-422 Add strict equality (===) and inequality (!==) operators * JEXL-421: ArrayBuilder: array type should reflect common class of its entries * JEXL-419: Add permission syntax to allow class/method/field * JEXL-418: Add try-catch-finally support diff --git a/src/changes/changes.xml b/src/changes/changes.xml index b6d65c71..234f41e9 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -29,6 +29,12 @@ + +Add support for instanceof / !instanceof + + +Add strict equality (===) and inequality (!==) operators + ArrayBuilder: array type should reflect common class of its entries diff --git a/src/main/java/org/apache/commons/jexl3/JexlArithmetic.java b/src/main/java/org/apache/commons/jexl3/JexlArithmetic.java index cd499a19..5d5c72b1 100644 --- a/src/main/java/org/apache/commons/jexl3/JexlArithmetic.java +++ b/src/main/java/org/apache/commons/jexl3/JexlArithmetic.java @@ -2086,8 +2086,8 @@ public class JexlArithmetic { if (left == null || right == null) { return false; } -if (left.getClass().equals(right.getClass()) && left instanceof Comparable) { -return ((Comparable) left).compareTo((Comparable) right) == 0; +if (left.getClass().equals(right.getClass())) { +return left.equals(right); } return false; } diff --git a/src/main/java/org/apache/commons/jexl3/internal/IntegerRange.java b/src/main/java/org/apache/commons/jexl3/internal/IntegerRange.java index 9bec4b16..ce8cff42 100644 --- a/src/main/java/org/apache/commons/jexl3/internal/IntegerRange.java +++ b/src/main/java/org/apache/commons/jexl3/internal/IntegerRange.java @@ -261,11 +261,6 @@ final class AscIntegerIterator implements Iterator { } throw new NoSuchElementException(); } - -@Override -public void remove() { -throw new UnsupportedOperationException("Not supported."); -} } /** @@ -301,9 +296,4 @@ final class DescIntegerIterator implements Iterator { } throw new NoSuchElementException(); } - -@Override -public void remove() { -throw new UnsupportedOperationException("Not supported."); -} } 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 4cbfa331..7621a848 100644 --- a/src/main/java/org/apache/commons/jexl3/internal/Interpreter.java +++ b/src/main/java/org/apache/commons/jexl3/internal/Interpreter.java @@ -299,7 +299,7 @@ public class Interpreter extends InterpreterBase { final Object result = operators.tryOverload(node, JexlOperator.SHIFTRIGHTU, left, right); return result != JexlEngine.TRY_FAILED ? result : arithmetic.shiftRightUnsigned(left, right); } catch (final ArithmeticException xrt) { -throw new JexlException(findNullOperand(node, left, right), ">> error", xrt); +throw new JexlException(findNullO
(commons-jexl) branch master updated: JEXL: last updates before 3.4; - !==, === operators; - instanceof, !instanceof operator; - Exception cause unwrap in catch; - JEXL-235 check;
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 b640ba68 JEXL: last updates before 3.4; - !==, === operators; - instanceof, !instanceof operator; - Exception cause unwrap in catch; - JEXL-235 check; b640ba68 is described below commit b640ba6820eb07ffc23043f118a3497f64339df5 Author: Henri Biestro AuthorDate: Fri May 24 11:55:43 2024 +0200 JEXL: last updates before 3.4; - !==, === operators; - instanceof, !instanceof operator; - Exception cause unwrap in catch; - JEXL-235 check; --- RELEASE-NOTES.txt | 22 --- pom.xml| 2 +- src/changes/changes.xml| 9 ++- .../org/apache/commons/jexl3/JexlArithmetic.java | 22 +++ .../org/apache/commons/jexl3/JexlFeatures.java | 5 +- .../org/apache/commons/jexl3/JexlOperator.java | 8 +++ .../apache/commons/jexl3/internal/Debugger.java| 22 ++- .../apache/commons/jexl3/internal/Interpreter.java | 71 +- .../commons/jexl3/internal/ScriptVisitor.java | 18 +- .../org/apache/commons/jexl3/internal/Source.java | 7 ++- .../commons/jexl3/parser/OperatorController.java | 10 +++ .../org/apache/commons/jexl3/parser/Parser.jjt | 35 --- .../apache/commons/jexl3/parser/ParserVisitor.java | 8 +++ .../jexl3/scripting/JexlScriptEngineFactory.java | 4 +- src/site/site.xml | 2 +- .../org/apache/commons/jexl3/ArithmeticTest.java | 25 +++- .../apache/commons/jexl3/TryCatchFinallyTest.java | 7 +++ .../jexl3/scripting/JexlScriptEngineTest.java | 4 +- src/test/scripts/httpPost.jexl | 2 +- 19 files changed, 250 insertions(+), 33 deletions(-) diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt index dfae9e13..2492472d 100644 --- a/RELEASE-NOTES.txt +++ b/RELEASE-NOTES.txt @@ -1,6 +1,6 @@ Apache Commons JEXL -Version 3.3 +Version 3.4 Release Notes @@ -19,16 +19,24 @@ Its goal is to expose scripting features usable by technical operatives or consu https://commons.apache.org/jexl/ -Release 3.3.1 +Release 3.4 -Version 3.3.1 is a maintenance release. +Version 3.4 is a minor release. Compatibility with previous releases -Version 3.3.1 is source and binary compatible with 3.3. +Version 3.4 is source and binary compatible with 3.3. -New Features in 3.3.1: + +What's new in 3.4: +== +Features and permissions are easier to define through new methods. +Some new syntaxes are introduced (thus the new minor); try/catch/finally (including with resources), +an array-access safe navigation ((x?[y]), strict equality/inequality operators (===, !==) and +more permissive structured literals. See the JIRA tickets for more details. + +New Features in 3.4: * JEXL-421: ArrayBuilder: array type should reflect common class of its entries * JEXL-419: Add permission syntax to allow class/method/field @@ -38,8 +46,8 @@ New Features in 3.3.1: * JEXL-401: Captured variables should be read-only * JEXL-398: Allow 'trailing commas' or ellipsis while defining array, map and set literals -Bugs Fixed in 3.3.1: -=== +Bugs Fixed in 3.4: +== * JEXL-420: Error while comparing float and string value * JEXL-417: JexlArithmetic looses precision during arithmetic operator execution * JEXL-416: Null-valued pragma throws NPE in 3.3 diff --git a/pom.xml b/pom.xml index e1fca938..f86e5ad3 100644 --- a/pom.xml +++ b/pom.xml @@ -58,7 +58,7 @@ true 0.96 0.89 -0.90 +0.89 0.80 0.89 0.75 diff --git a/src/changes/changes.xml b/src/changes/changes.xml index e0de8faa..b6d65c71 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -27,7 +27,7 @@ Commons Developers - + ArrayBuilder: array type should reflect common class of its entries @@ -50,7 +50,9 @@ Allow 'trailing commas' or ellipsis while defining array, map and set literals -Add Maven property project.build.outputTimestamp for build reproducibility. + +Add Maven property project.build.outputTimestamp for build reproducibility
(commons-jexl) branch master updated: JEXL: fix parsing error caused by ternary and ns call in lambda;
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 ff9f3b6e JEXL: fix parsing error caused by ternary and ns call in lambda; ff9f3b6e is described below commit ff9f3b6eaaa87314d0706b418945209b356af1e7 Author: henrib AuthorDate: Mon Apr 15 19:19:40 2024 +0200 JEXL: fix parsing error caused by ternary and ns call in lambda; --- .../org/apache/commons/jexl3/parser/Parser.jjt | 1 + .../org/apache/commons/jexl3/Issues400Test.java| 22 ++ 2 files changed, 23 insertions(+) diff --git a/src/main/java/org/apache/commons/jexl3/parser/Parser.jjt b/src/main/java/org/apache/commons/jexl3/parser/Parser.jjt index 7e3824b3..93e22d9e 100644 --- a/src/main/java/org/apache/commons/jexl3/parser/Parser.jjt +++ b/src/main/java/org/apache/commons/jexl3/parser/Parser.jjt @@ -399,6 +399,7 @@ void StatementNoVar() #void : {} | LOOKAHEAD() Break() | LOOKAHEAD() ThrowStatement() | LOOKAHEAD() TryStatement() +| LOOKAHEAD(LambdaLookahead()) Lambda() | LOOKAHEAD(Expression()) ExpressionStatement() | Block() | LOOKAHEAD(, {!getFeatures().isLexical()} ) Var() diff --git a/src/test/java/org/apache/commons/jexl3/Issues400Test.java b/src/test/java/org/apache/commons/jexl3/Issues400Test.java index 249efeec..fb64b811 100644 --- a/src/test/java/org/apache/commons/jexl3/Issues400Test.java +++ b/src/test/java/org/apache/commons/jexl3/Issues400Test.java @@ -391,4 +391,26 @@ public class Issues400Test { Assert.assertEquals(42, result); } + public static class VinzContext extends MapContext { +public String member(String m, String u) { + return m + '.' + u; +} + } + + @Test + public void testNamespaceVsTernary() { +VinzContext ctxt = new VinzContext(); +ctxt.set("Users", "USERS"); +final JexlEngine jexl = new JexlBuilder().safe(false).strict(true).silent(false).create(); +JexlScript script = jexl.createScript("() -> {\n" ++ " var fn = (user) -> {\n" ++ " user ? user : member(Users, 'user');\n" ++ " }\n" ++ "}"); +Object r = script.execute(ctxt); +Assert.assertNotNull(r); +script = (JexlScript) r; +r = script.execute(ctxt); +Assert.assertEquals("USERS.user", r); + } }
(commons-jexl) branch master updated (a6534343 -> 66ed7efe)
This is an automated email from the ASF dual-hosted git repository. henrib pushed a change to branch master in repository https://gitbox.apache.org/repos/asf/commons-jexl.git from a6534343 Bump org.ow2.asm:asm from 9.6 to 9.7 #242 add e87be22b Bump org.apache.commons:commons-parent from 67 to 69 new 66ed7efe Merge pull request #244 from apache/dependabot/maven/org.apache.commons-commons-parent-69 The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference. Summary of changes: pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
(commons-jexl) 01/01: Merge pull request #244 from apache/dependabot/maven/org.apache.commons-commons-parent-69
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 commit 66ed7efe0894a321fcd80271db57743c0b7742c5 Merge: a6534343 e87be22b Author: Henrib AuthorDate: Mon Apr 8 22:06:43 2024 +0200 Merge pull request #244 from apache/dependabot/maven/org.apache.commons-commons-parent-69 Bump org.apache.commons:commons-parent from 67 to 69 pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
(commons-jexl) branch master updated (3188a279 -> b7f72016)
This is an automated email from the ASF dual-hosted git repository. henrib pushed a change to branch master in repository https://gitbox.apache.org/repos/asf/commons-jexl.git from 3188a279 The Moditect plugin is now invoked through the parent POM add ca8dd7bf JEXL-418: initial drop; add 51ad527d JEXL-418: fixing reserved names, preparing for feature flag; add 45a71f4f JEXL-418: improve try-with-resources handling; add throw handling; more tests; add fe3aa70c JEXL-418: fix try-with-resources grammar; more tests; add 958b168f JEXL-418: fix try-catch-finally debugger handling; more tests; add 01310b5e JEXL-418: initial drop; add d2d2ff57 JEXL-418: fixing reserved names, preparing for feature flag; add 6fb7c7b1 Merge pull request #229 from apache/master add 67fbd237 JEXL-418: improve try-with-resources handling; add throw handling; more tests; add 90e421d3 JEXL-418: fix try-with-resources grammar; more tests; add d0454344 JEXL-418: fix try-catch-finally debugger handling; more tests; add b255c771 Merge remote-tracking branch 'origin/JEXL-418' into JEXL-418 add 5ea88854 JEXL-418: cleaning debug output; - tidy code; add 30857115 JEXL-418: javadoc fix; add ecabdcab JEXL-418: doc fix; - syntax update and test; new b7f72016 Merge pull request #228 from apache/JEXL-418 The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference. Summary of changes: RELEASE-NOTES.txt | 1 + src/changes/changes.xml| 3 + .../org/apache/commons/jexl3/JexlArithmetic.java | 18 +- .../org/apache/commons/jexl3/JexlException.java| 30 +++ .../org/apache/commons/jexl3/JexlFeatures.java | 4 +- .../apache/commons/jexl3/internal/Debugger.java| 138 --- .../apache/commons/jexl3/internal/Interpreter.java | 240 .../commons/jexl3/internal/InterpreterBase.java| 12 + .../commons/jexl3/internal/ScriptVisitor.java | 103 ++--- .../parser/{ASTVar.java => ASTTryResources.java} | 11 +- ...alifiedIdentifier.java => ASTTryStatement.java} | 35 +-- .../commons/jexl3/parser/FeatureController.java| 8 + .../org/apache/commons/jexl3/parser/Parser.jjt | 65 +- .../apache/commons/jexl3/parser/ParserVisitor.java | 6 + src/site/xdoc/reference/syntax.xml | 118 +- .../org/apache/commons/jexl3/FeaturesTest.java | 2 +- .../org/apache/commons/jexl3/Issues400Test.java| 21 ++ .../java/org/apache/commons/jexl3/LexicalTest.java | 4 +- .../apache/commons/jexl3/TryCatchFinallyTest.java | 251 + 19 files changed, 764 insertions(+), 306 deletions(-) copy src/main/java/org/apache/commons/jexl3/parser/{ASTVar.java => ASTTryResources.java} (84%) copy src/main/java/org/apache/commons/jexl3/parser/{ASTQualifiedIdentifier.java => ASTTryStatement.java} (68%) create mode 100644 src/test/java/org/apache/commons/jexl3/TryCatchFinallyTest.java
(commons-jexl) 01/01: Merge pull request #228 from apache/JEXL-418
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 commit b7f720162deda73c273cb2668e1433fe82b37b65 Merge: 3188a279 ecabdcab Author: Henrib AuthorDate: Fri Mar 15 19:01:43 2024 +0100 Merge pull request #228 from apache/JEXL-418 JEXL-418: adding try/catch/finally/throw RELEASE-NOTES.txt | 1 + src/changes/changes.xml| 3 + .../org/apache/commons/jexl3/JexlArithmetic.java | 18 +- .../org/apache/commons/jexl3/JexlException.java| 30 +++ .../org/apache/commons/jexl3/JexlFeatures.java | 4 +- .../apache/commons/jexl3/internal/Debugger.java| 138 --- .../apache/commons/jexl3/internal/Interpreter.java | 240 .../commons/jexl3/internal/InterpreterBase.java| 12 + .../commons/jexl3/internal/ScriptVisitor.java | 103 ++--- .../commons/jexl3/parser/ASTTryResources.java | 36 +++ .../commons/jexl3/parser/ASTTryStatement.java | 56 + .../commons/jexl3/parser/FeatureController.java| 8 + .../org/apache/commons/jexl3/parser/Parser.jjt | 65 +- .../apache/commons/jexl3/parser/ParserVisitor.java | 6 + src/site/xdoc/reference/syntax.xml | 118 +- .../org/apache/commons/jexl3/FeaturesTest.java | 2 +- .../org/apache/commons/jexl3/Issues400Test.java| 21 ++ .../java/org/apache/commons/jexl3/LexicalTest.java | 4 +- .../apache/commons/jexl3/TryCatchFinallyTest.java | 251 + 19 files changed, 833 insertions(+), 283 deletions(-)
(commons-jexl) branch JEXL-418 updated (30857115 -> ecabdcab)
This is an automated email from the ASF dual-hosted git repository. henrib pushed a change to branch JEXL-418 in repository https://gitbox.apache.org/repos/asf/commons-jexl.git from 30857115 JEXL-418: javadoc fix; add ecabdcab JEXL-418: doc fix; - syntax update and test; No new revisions were added by this update. Summary of changes: RELEASE-NOTES.txt | 1 + src/changes/changes.xml| 3 + src/site/xdoc/reference/syntax.xml | 118 - .../org/apache/commons/jexl3/Issues400Test.java| 21 4 files changed, 141 insertions(+), 2 deletions(-)
(commons-jexl) branch JEXL-418 updated (5ea88854 -> 30857115)
This is an automated email from the ASF dual-hosted git repository. henrib pushed a change to branch JEXL-418 in repository https://gitbox.apache.org/repos/asf/commons-jexl.git from 5ea88854 JEXL-418: cleaning debug output; - tidy code; add 30857115 JEXL-418: javadoc fix; No new revisions were added by this update. Summary of changes: src/main/java/org/apache/commons/jexl3/JexlArithmetic.java | 10 +- 1 file changed, 9 insertions(+), 1 deletion(-)
(commons-jexl) branch JEXL-418 updated (d0454344 -> 5ea88854)
This is an automated email from the ASF dual-hosted git repository. henrib pushed a change to branch JEXL-418 in repository https://gitbox.apache.org/repos/asf/commons-jexl.git from d0454344 JEXL-418: fix try-catch-finally debugger handling; more tests; add aba0a754 Bump github/codeql-action from 3.24.3 to 3.24.5 add e4351cb2 Merge pull request #230 from apache/dependabot/github_actions/github/codeql-action-3.24.5 add 1ac09a99 Bump actions/setup-java from 4.0.0 to 4.1.0 add 6014969e Merge pull request #231 from apache/dependabot/github_actions/actions/setup-java-4.1.0 add 342ecf13 Bump github/codeql-action from 3.24.5 to 3.24.6 add aea96109 Merge pull request #233 from apache/dependabot/github_actions/github/codeql-action-3.24.6 add a60dea97 Bump actions/cache from 4.0.0 to 4.0.1 add 28ab2bcf Merge pull request #232 from apache/dependabot/github_actions/actions/cache-4.0.1 add 9bd08b81 Bump org.apache.commons:commons-parent from 66 to 67 add 0ac3a2ca Merge pull request #234 from apache/dependabot/maven/org.apache.commons-commons-parent-67 add ca8dd7bf JEXL-418: initial drop; add 51ad527d JEXL-418: fixing reserved names, preparing for feature flag; add 45a71f4f JEXL-418: improve try-with-resources handling; add throw handling; more tests; add fe3aa70c JEXL-418: fix try-with-resources grammar; more tests; add 958b168f JEXL-418: fix try-catch-finally debugger handling; more tests; add b255c771 Merge remote-tracking branch 'origin/JEXL-418' into JEXL-418 add 5ea88854 JEXL-418: cleaning debug output; - tidy code; No new revisions were added by this update. Summary of changes: .github/workflows/codeql-analysis.yml | 8 +- .github/workflows/maven.yml| 4 +- .github/workflows/scorecards-analysis.yml | 2 +- pom.xml| 2 +- .../org/apache/commons/jexl3/JexlArithmetic.java | 8 +- .../apache/commons/jexl3/internal/Debugger.java| 17 +--- .../apache/commons/jexl3/internal/Interpreter.java | 103 ++--- .../commons/jexl3/parser/ASTTryStatement.java | 19 ++-- .../org/apache/commons/jexl3/parser/Parser.jjt | 14 +-- 9 files changed, 81 insertions(+), 96 deletions(-)
(commons-jexl) branch master updated (28ab2bcf -> 0ac3a2ca)
This is an automated email from the ASF dual-hosted git repository. henrib pushed a change to branch master in repository https://gitbox.apache.org/repos/asf/commons-jexl.git from 28ab2bcf Merge pull request #232 from apache/dependabot/github_actions/actions/cache-4.0.1 add 9bd08b81 Bump org.apache.commons:commons-parent from 66 to 67 new 0ac3a2ca Merge pull request #234 from apache/dependabot/maven/org.apache.commons-commons-parent-67 The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference. Summary of changes: pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
(commons-jexl) 01/01: Merge pull request #234 from apache/dependabot/maven/org.apache.commons-commons-parent-67
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 commit 0ac3a2ca62561723adfede2d5fed61b558e36dd1 Merge: 28ab2bcf 9bd08b81 Author: Henrib AuthorDate: Wed Mar 6 15:45:01 2024 +0100 Merge pull request #234 from apache/dependabot/maven/org.apache.commons-commons-parent-67 Bump org.apache.commons:commons-parent from 66 to 67 pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
(commons-jexl) branch JEXL-418 updated (90e421d3 -> d0454344)
This is an automated email from the ASF dual-hosted git repository. henrib pushed a change to branch JEXL-418 in repository https://gitbox.apache.org/repos/asf/commons-jexl.git from 90e421d3 JEXL-418: fix try-with-resources grammar; more tests; add d0454344 JEXL-418: fix try-catch-finally debugger handling; more tests; No new revisions were added by this update. Summary of changes: .../apache/commons/jexl3/internal/Debugger.java| 23 ++-- .../apache/commons/jexl3/TryCatchFinallyTest.java | 68 +- 2 files changed, 85 insertions(+), 6 deletions(-)
(commons-jexl) branch JEXL-418 updated (67fbd237 -> 90e421d3)
This is an automated email from the ASF dual-hosted git repository. henrib pushed a change to branch JEXL-418 in repository https://gitbox.apache.org/repos/asf/commons-jexl.git from 67fbd237 JEXL-418: improve try-with-resources handling; add throw handling; more tests; add 90e421d3 JEXL-418: fix try-with-resources grammar; more tests; No new revisions were added by this update. Summary of changes: .../org/apache/commons/jexl3/parser/Parser.jjt | 8 ++-- .../apache/commons/jexl3/TryCatchFinallyTest.java | 24 ++ 2 files changed, 30 insertions(+), 2 deletions(-)
(commons-jexl) branch JEXL-418 updated (6fb7c7b1 -> 67fbd237)
This is an automated email from the ASF dual-hosted git repository. henrib pushed a change to branch JEXL-418 in repository https://gitbox.apache.org/repos/asf/commons-jexl.git from 6fb7c7b1 Merge pull request #229 from apache/master add 67fbd237 JEXL-418: improve try-with-resources handling; add throw handling; more tests; No new revisions were added by this update. Summary of changes: .../org/apache/commons/jexl3/JexlException.java| 30 ++ .../apache/commons/jexl3/internal/Debugger.java| 47 + .../apache/commons/jexl3/internal/Interpreter.java | 102 --- .../commons/jexl3/internal/InterpreterBase.java| 12 +++ .../commons/jexl3/internal/ScriptVisitor.java | 10 ++ .../parser/{ASTVar.java => ASTTryResources.java} | 11 +-- .../commons/jexl3/parser/ASTTryStatement.java | 2 +- .../org/apache/commons/jexl3/parser/Parser.jjt | 25 +++-- .../apache/commons/jexl3/parser/ParserVisitor.java | 4 + .../apache/commons/jexl3/TryCatchFinallyTest.java | 110 + 10 files changed, 242 insertions(+), 111 deletions(-) copy src/main/java/org/apache/commons/jexl3/parser/{ASTVar.java => ASTTryResources.java} (84%)
(commons-jexl) branch JEXL-418 updated (d2d2ff57 -> 6fb7c7b1)
This is an automated email from the ASF dual-hosted git repository. henrib pushed a change to branch JEXL-418 in repository https://gitbox.apache.org/repos/asf/commons-jexl.git from d2d2ff57 JEXL-418: fixing reserved names, preparing for feature flag; add 022c2d15 Bump github/codeql-action from 3.24.0 to 3.24.3 add 05845fd7 Merge pull request #227 from apache/dependabot/github_actions/github/codeql-action-3.24.3 add 6fb7c7b1 Merge pull request #229 from apache/master No new revisions were added by this update. Summary of changes: .github/workflows/codeql-analysis.yml | 6 +++--- .github/workflows/scorecards-analysis.yml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-)
(commons-jexl) branch JEXL-418 updated: JEXL-418: fixing reserved names, preparing for feature flag;
This is an automated email from the ASF dual-hosted git repository. henrib pushed a commit to branch JEXL-418 in repository https://gitbox.apache.org/repos/asf/commons-jexl.git The following commit(s) were added to refs/heads/JEXL-418 by this push: new d2d2ff57 JEXL-418: fixing reserved names, preparing for feature flag; d2d2ff57 is described below commit d2d2ff57adf991e639c4b218fd714a769bdd53aa Author: Henri Biestro AuthorDate: Fri Feb 16 23:19:52 2024 +0100 JEXL-418: fixing reserved names, preparing for feature flag; --- .../org/apache/commons/jexl3/JexlFeatures.java | 4 +- .../apache/commons/jexl3/internal/Interpreter.java | 3 +- .../org/apache/commons/jexl3/parser/Parser.jjt | 20 +++-- .../org/apache/commons/jexl3/FeaturesTest.java | 2 +- .../java/org/apache/commons/jexl3/LexicalTest.java | 4 +- .../apache/commons/jexl3/TryCatchFinallyTest.java | 49 +- 6 files changed, 61 insertions(+), 21 deletions(-) diff --git a/src/main/java/org/apache/commons/jexl3/JexlFeatures.java b/src/main/java/org/apache/commons/jexl3/JexlFeatures.java index 4cee5a7d..be45f9b5 100644 --- a/src/main/java/org/apache/commons/jexl3/JexlFeatures.java +++ b/src/main/java/org/apache/commons/jexl3/JexlFeatures.java @@ -227,13 +227,13 @@ public final class JexlFeatures { /** * Protected future syntactic elements. - * try, catch, throw, finally, switch, case, default, class, instanceof, jexl, $jexl + * throw, switch, case, default, class, instanceof, jexl, $jexl * @since 3.3.1 */ private static final Set RESERVED_WORDS = Collections.unmodifiableSet( new HashSet<>((Arrays.asList( -"try", "catch", "throw", "finally", "switch", "case", "default", "class", "instanceof", "jexl", "$jexl"; +"switch", "case", "default", "class", "instanceof", "jexl", "$jexl"; /** * The modern scripting features set. 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 c2553001..82a77edf 100644 --- a/src/main/java/org/apache/commons/jexl3/internal/Interpreter.java +++ b/src/main/java/org/apache/commons/jexl3/internal/Interpreter.java @@ -695,10 +695,10 @@ public class Interpreter extends InterpreterBase { */ private Object evalTry(JexlNode tryVar, JexlNode tryExpression, JexlNode tryBody, final Object data) { boolean lexical = false; +Object tryResult = null; try { final ASTIdentifier tryVariable; final int symbol; -Object tryResult = null; /* Capture try variable if any. */ if (tryVar instanceof ASTReference) { tryVariable = (ASTIdentifier) tryVar.jjtGetChild(0); @@ -734,6 +734,7 @@ public class Interpreter extends InterpreterBase { // evaluate the body return tryBody.jjtAccept(this, data); } finally { +closeIfSupported(tryResult); // restore lexical frame if (lexical) { block = block.pop(); diff --git a/src/main/java/org/apache/commons/jexl3/parser/Parser.jjt b/src/main/java/org/apache/commons/jexl3/parser/Parser.jjt index 7dbcebaa..a09f2f21 100644 --- a/src/main/java/org/apache/commons/jexl3/parser/Parser.jjt +++ b/src/main/java/org/apache/commons/jexl3/parser/Parser.jjt @@ -82,6 +82,7 @@ PARSER_END(Parser) TOKEN_MGR_DECLS : { boolean comparatorNames = false; +boolean jexl331 = true; } /*** @@ -219,11 +220,14 @@ TOKEN_MGR_DECLS : { | < NULL : "null" > | < TRUE : "true" > | < FALSE : "false" > -| < THROW : "throw" > +} + + TOKEN : /* Exception handling. */ +{ + < THROW : "throw" > | < TRY : "try" > | < CATCH : "catch" > | < FINALLY : "finally" > - } /*** @@ -249,7 +253,8 @@ TOKEN_MGR_DECLS : { < IDENTIFIER: (||)* > { matchedToken.image = StringParser.unescapeIdentifier(matchedToken.image); - if (comparatorNames && matchedToken.image.length() == 2) { + final int length = matchedToken.image.length(); + if (comparatorNames && length == 2) { switch (matchedToken.image) { case "ne" : matchedToken.kind = NE; break; case "eq" : matchedToken.kind = EQ; break; @@ -258,6 +263,13 @@ TOKEN_MGR_DECLS : { case "gt" : matchedToken.kind = GT; break; case "ge" : matchedToken.kind
(commons-jexl) branch JEXL-418 created (now 01310b5e)
This is an automated email from the ASF dual-hosted git repository. henrib pushed a change to branch JEXL-418 in repository https://gitbox.apache.org/repos/asf/commons-jexl.git at 01310b5e JEXL-418: initial drop; This branch includes the following new commits: new 01310b5e JEXL-418: initial drop; The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference.
(commons-jexl) 01/01: JEXL-418: initial drop;
This is an automated email from the ASF dual-hosted git repository. henrib pushed a commit to branch JEXL-418 in repository https://gitbox.apache.org/repos/asf/commons-jexl.git commit 01310b5ef80288bcfe5e8269c7ccda388a5b0042 Author: Henri Biestro AuthorDate: Fri Feb 16 22:10:10 2024 +0100 JEXL-418: initial drop; --- .../apache/commons/jexl3/internal/Debugger.java| 129 -- .../apache/commons/jexl3/internal/Interpreter.java | 262 ++--- .../commons/jexl3/internal/ScriptVisitor.java | 93 +--- .../commons/jexl3/parser/ASTTryStatement.java | 49 .../commons/jexl3/parser/FeatureController.java| 8 + .../org/apache/commons/jexl3/parser/Parser.jjt | 36 ++- .../apache/commons/jexl3/parser/ParserVisitor.java | 2 + .../apache/commons/jexl3/TryCatchFinallyTest.java | 58 + 8 files changed, 369 insertions(+), 268 deletions(-) diff --git a/src/main/java/org/apache/commons/jexl3/internal/Debugger.java b/src/main/java/org/apache/commons/jexl3/internal/Debugger.java index 6353a57f..4cb224c7 100644 --- a/src/main/java/org/apache/commons/jexl3/internal/Debugger.java +++ b/src/main/java/org/apache/commons/jexl3/internal/Debugger.java @@ -25,95 +25,7 @@ import org.apache.commons.jexl3.JexlExpression; import org.apache.commons.jexl3.JexlFeatures; import org.apache.commons.jexl3.JexlInfo; import org.apache.commons.jexl3.JexlScript; -import org.apache.commons.jexl3.parser.ASTAddNode; -import org.apache.commons.jexl3.parser.ASTAndNode; -import org.apache.commons.jexl3.parser.ASTAnnotatedStatement; -import org.apache.commons.jexl3.parser.ASTAnnotation; -import org.apache.commons.jexl3.parser.ASTArguments; -import org.apache.commons.jexl3.parser.ASTArrayAccess; -import org.apache.commons.jexl3.parser.ASTArrayLiteral; -import org.apache.commons.jexl3.parser.ASTAssignment; -import org.apache.commons.jexl3.parser.ASTBitwiseAndNode; -import org.apache.commons.jexl3.parser.ASTBitwiseComplNode; -import org.apache.commons.jexl3.parser.ASTBitwiseOrNode; -import org.apache.commons.jexl3.parser.ASTBitwiseXorNode; -import org.apache.commons.jexl3.parser.ASTBlock; -import org.apache.commons.jexl3.parser.ASTBreak; -import org.apache.commons.jexl3.parser.ASTConstructorNode; -import org.apache.commons.jexl3.parser.ASTContinue; -import org.apache.commons.jexl3.parser.ASTDecrementGetNode; -import org.apache.commons.jexl3.parser.ASTDefineVars; -import org.apache.commons.jexl3.parser.ASTDivNode; -import org.apache.commons.jexl3.parser.ASTDoWhileStatement; -import org.apache.commons.jexl3.parser.ASTEQNode; -import org.apache.commons.jexl3.parser.ASTERNode; -import org.apache.commons.jexl3.parser.ASTEWNode; -import org.apache.commons.jexl3.parser.ASTEmptyFunction; -import org.apache.commons.jexl3.parser.ASTExtendedLiteral; -import org.apache.commons.jexl3.parser.ASTFalseNode; -import org.apache.commons.jexl3.parser.ASTForeachStatement; -import org.apache.commons.jexl3.parser.ASTFunctionNode; -import org.apache.commons.jexl3.parser.ASTGENode; -import org.apache.commons.jexl3.parser.ASTGTNode; -import org.apache.commons.jexl3.parser.ASTGetDecrementNode; -import org.apache.commons.jexl3.parser.ASTGetIncrementNode; -import org.apache.commons.jexl3.parser.ASTIdentifier; -import org.apache.commons.jexl3.parser.ASTIdentifierAccess; -import org.apache.commons.jexl3.parser.ASTIfStatement; -import org.apache.commons.jexl3.parser.ASTIncrementGetNode; -import org.apache.commons.jexl3.parser.ASTJexlLambda; -import org.apache.commons.jexl3.parser.ASTJexlScript; -import org.apache.commons.jexl3.parser.ASTJxltLiteral; -import org.apache.commons.jexl3.parser.ASTLENode; -import org.apache.commons.jexl3.parser.ASTLTNode; -import org.apache.commons.jexl3.parser.ASTMapEntry; -import org.apache.commons.jexl3.parser.ASTMapLiteral; -import org.apache.commons.jexl3.parser.ASTMethodNode; -import org.apache.commons.jexl3.parser.ASTModNode; -import org.apache.commons.jexl3.parser.ASTMulNode; -import org.apache.commons.jexl3.parser.ASTNENode; -import org.apache.commons.jexl3.parser.ASTNEWNode; -import org.apache.commons.jexl3.parser.ASTNRNode; -import org.apache.commons.jexl3.parser.ASTNSWNode; -import org.apache.commons.jexl3.parser.ASTNotNode; -import org.apache.commons.jexl3.parser.ASTNullLiteral; -import org.apache.commons.jexl3.parser.ASTNullpNode; -import org.apache.commons.jexl3.parser.ASTNumberLiteral; -import org.apache.commons.jexl3.parser.ASTOrNode; -import org.apache.commons.jexl3.parser.ASTQualifiedIdentifier; -import org.apache.commons.jexl3.parser.ASTRangeNode; -import org.apache.commons.jexl3.parser.ASTReference; -import org.apache.commons.jexl3.parser.ASTReferenceExpression; -import org.apache.commons.jexl3.parser.ASTRegexLiteral; -import org.apache.commons.jexl3.parser.ASTReturnStatement; -import org.apache.commons.jexl3.parser.ASTSWNode; -import org.apache.commons.jexl3.parser.ASTSetAddNode; -import org.apache.commons.jexl3.parser.ASTSetAndNode; -import org.apache.commons.jexl3
(commons-jexl) branch master updated: JEXL-421: added methods to find 'best' common class; - updated ArrayBuilder; - added test; - updated changes & release notes;
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 a6c1366e JEXL-421: added methods to find 'best' common class; - updated ArrayBuilder; - added test; - updated changes & release notes; a6c1366e is described below commit a6c1366e0837694dc5d4224e3ff3534b38697bce Author: Henri Biestro AuthorDate: Thu Feb 15 13:16:13 2024 +0100 JEXL-421: added methods to find 'best' common class; - updated ArrayBuilder; - added test; - updated changes & release notes; --- src/test/java/org/apache/commons/jexl3/ArrayTypeTest.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/test/java/org/apache/commons/jexl3/ArrayTypeTest.java b/src/test/java/org/apache/commons/jexl3/ArrayTypeTest.java index cebafbcc..4bdd3164 100644 --- a/src/test/java/org/apache/commons/jexl3/ArrayTypeTest.java +++ b/src/test/java/org/apache/commons/jexl3/ArrayTypeTest.java @@ -104,8 +104,10 @@ public class ArrayTypeTest { Set> sset = ClassMisc.getSuperClasses(ArrayList.class, ArrayDeque.class); Assert.assertFalse(sset.isEmpty()); +// in java 21, a SequenceCollection interface is added to the sset List> expected = Arrays.asList(AbstractCollection.class, Collection.class, Iterable.class, Cloneable.class, Serializable.class); -Assert.assertEquals(expected, new ArrayList(sset)); +Assert.assertTrue(sset.containsAll(expected)); + Class collection = ClassMisc.getCommonSuperClass(ArrayList.class, Collections.emptyList().getClass()); Assert.assertEquals(AbstractList.class, collection); collection = ClassMisc.getSuperClasses(ArrayList.class, Collections.emptyList().getClass())
(commons-jexl) branch master updated: JEXL-421: added methods to find 'best' common class; - updated ArrayBuilder; - added test; - updated changes & release notes;
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 b10477ec JEXL-421: added methods to find 'best' common class; - updated ArrayBuilder; - added test; - updated changes & release notes; b10477ec is described below commit b10477ec25c7b7ed52e58aca30e8ab3c940eeaa9 Author: Henri Biestro AuthorDate: Thu Feb 15 13:16:13 2024 +0100 JEXL-421: added methods to find 'best' common class; - updated ArrayBuilder; - added test; - updated changes & release notes; --- RELEASE-NOTES.txt | 1 + src/changes/changes.xml| 3 + .../commons/jexl3/internal/ArrayBuilder.java | 41 -- .../jexl3/internal/introspection/ClassMisc.java| 128 ++ .../org/apache/commons/jexl3/ArrayTypeTest.java| 149 + .../org/apache/commons/jexl3/Issues400Test.java| 4 - 6 files changed, 310 insertions(+), 16 deletions(-) diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt index d8bac03e..8e40650f 100644 --- a/RELEASE-NOTES.txt +++ b/RELEASE-NOTES.txt @@ -30,6 +30,7 @@ Version 3.3.1 is source and binary compatible with 3.3. New Features in 3.3.1: +* JEXL-421: ArrayBuilder: array type should reflect common class of its entries * JEXL-419: Add permission syntax to allow class/method/field * JEXL-408: Using JexlFeatures is tedious * JEXL-404: Support array-access safe navigation (x?[y]) diff --git a/src/changes/changes.xml b/src/changes/changes.xml index b5666812..0ef1e059 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -29,6 +29,9 @@ + +ArrayBuilder: array type should reflect common class of its entries + Add permission syntax to allow class/method/field diff --git a/src/main/java/org/apache/commons/jexl3/internal/ArrayBuilder.java b/src/main/java/org/apache/commons/jexl3/internal/ArrayBuilder.java index a7825b1c..f738df30 100644 --- a/src/main/java/org/apache/commons/jexl3/internal/ArrayBuilder.java +++ b/src/main/java/org/apache/commons/jexl3/internal/ArrayBuilder.java @@ -24,6 +24,7 @@ import java.util.List; import java.util.Map; import org.apache.commons.jexl3.JexlArithmetic; +import org.apache.commons.jexl3.internal.introspection.ClassMisc; /** * Helper class to create typed arrays. @@ -67,6 +68,17 @@ public class ArrayBuilder implements JexlArithmetic.ArrayBuilder { /** Extended? */ protected final boolean extended; +/** + * Computes the best super class/super interface. + * Used to try and maintain type safe arrays. + * @param baseClass the baseClass + * @param other another class + * @return a common ancestor, class or interface, worst case being class Object + */ +protected Class getCommonSuperClass(final Class baseClass, final Class other) { +return ClassMisc.getCommonSuperClass(baseClass, other); +} + /** * Creates a new builder. * @param size the exact array size @@ -97,19 +109,13 @@ public class ArrayBuilder implements JexlArithmetic.ArrayBuilder { if (commonClass == null) { commonClass = eclass; isNumber = isNumber && Number.class.isAssignableFrom(commonClass); -} else if (!commonClass.equals(eclass)) { +} else if (!commonClass.isAssignableFrom(eclass)) { // if both are numbers... if (isNumber && Number.class.isAssignableFrom(eclass)) { commonClass = Number.class; } else { -// attempt to find valid superclass -do { -eclass = eclass.getSuperclass(); -if (eclass == null) { -commonClass = Object.class; -break; -} -} while (!commonClass.isAssignableFrom(eclass)); +isNumber = false; +commonClass = getCommonSuperClass(commonClass, eclass); } } } @@ -120,21 +126,32 @@ public class ArrayBuilder implements JexlArithmetic.ArrayBuilder { untyped[added++] = value; } +/** + * Creates a new list (aka extended array)/ + * @param clazz the class + * @param size the size + * @return the instance + * @param the type + */ +protected List newList(Class clazz, int size) { +return new ArrayList<>(size); +} + @Override public Object create(final boolean e)
(commons-jexl) branch master updated: JEXL-420: improved arithmetic coherence; - added tests;
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 f5bf27ca JEXL-420: improved arithmetic coherence; - added tests; f5bf27ca is described below commit f5bf27caaf7c577ed039232e5db81bcb835bc228 Author: Henri Biestro AuthorDate: Fri Feb 9 10:03:13 2024 +0100 JEXL-420: improved arithmetic coherence; - added tests; --- RELEASE-NOTES.txt | 1 + src/changes/changes.xml| 3 + .../org/apache/commons/jexl3/JexlArithmetic.java | 141 - .../org/apache/commons/jexl3/ArithmeticTest.java | 27 +++- 4 files changed, 109 insertions(+), 63 deletions(-) diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt index a059780d..d8bac03e 100644 --- a/RELEASE-NOTES.txt +++ b/RELEASE-NOTES.txt @@ -38,6 +38,7 @@ New Features in 3.3.1: Bugs Fixed in 3.3.1: === +* JEXL-420: Error while comparing float and string value * JEXL-417: JexlArithmetic looses precision during arithmetic operator execution * JEXL-416: Null-valued pragma throws NPE in 3.3 * JEXL-415: Incorrect template eval result diff --git a/src/changes/changes.xml b/src/changes/changes.xml index b614ba05..b5666812 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -46,6 +46,9 @@ Add Maven property project.build.outputTimestamp for build reproducibility. + +Error while comparing float and string value + JexlArithmetic looses precision during arithmetic operator execution diff --git a/src/main/java/org/apache/commons/jexl3/JexlArithmetic.java b/src/main/java/org/apache/commons/jexl3/JexlArithmetic.java index 006bc426..044c3791 100644 --- a/src/main/java/org/apache/commons/jexl3/JexlArithmetic.java +++ b/src/main/java/org/apache/commons/jexl3/JexlArithmetic.java @@ -18,6 +18,7 @@ package org.apache.commons.jexl3; import static java.lang.StrictMath.floor; +import static org.apache.commons.jexl3.JexlOperator.EQ; import java.lang.reflect.Array; import java.lang.reflect.Constructor; @@ -58,12 +59,24 @@ import org.apache.commons.jexl3.introspection.JexlMethod; * @since 2.0 */ public class JexlArithmetic { - /** Marker class for null operand exceptions. */ public static class NullOperand extends ArithmeticException { private static final long serialVersionUID = 4720876194840764770L; } +/** Marker class for coercion operand exceptions. */ +public static class CoercionException extends ArithmeticException { +private static final long serialVersionUID = 202402081150L; + +/** + * Simple ctor. + * @param msg the exception message + */ +public CoercionException(String msg) { +super(msg); +} +} + /** Double.MAX_VALUE as BigDecimal. */ protected static final BigDecimal BIGD_DOUBLE_MAX_VALUE = BigDecimal.valueOf(Double.MAX_VALUE); @@ -525,7 +538,7 @@ public class JexlArithmetic { if (val == null) { return controlNullOperand(strict, 0); } -throw new ArithmeticException("Integer coercion: " +throw new CoercionException("Integer coercion: " + val.getClass().getName() + ":(" + val + ")"); } @@ -576,7 +589,7 @@ public class JexlArithmetic { if (val == null) { return controlNullOperand(strict, 0L); } -throw new ArithmeticException("Long coercion: " +throw new CoercionException("Long coercion: " + val.getClass().getName() + ":(" + val + ")"); } @@ -637,7 +650,7 @@ public class JexlArithmetic { if (val == null) { return controlNullOperand(strict, BigInteger.ZERO); } -throw new ArithmeticException("BigInteger coercion: " +throw new CoercionException("BigInteger coercion: " + val.getClass().getName() + ":(" + val + ")"); } @@ -676,7 +689,7 @@ public class JexlArithmetic { return roundBigDecimal(new BigDecimal(val.toString(), getMathContext())); } if (val instanceof Number) { -return roundBigDecimal(new BigDecimal(val.toString(), getMathContext())); +return roundBigDecimal(parseBigDecimal(val.toString())); } if (val instanceof Boolean) { return BigDecimal.valueOf((Boolean) val ? 1. : 0.); @@ -685,20 +698,15 @@ public class JexlArithmetic { return BigDecimal.valueOf(((AtomicBoolean) val).get() ? 1L : 0L); } if (val instanceof String) { -
(commons-jexl) branch master updated: JEXL-419: added positive permission syntax; - added tests, updated javadoc, release notes and changes;
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 1aeec988 JEXL-419: added positive permission syntax; - added tests, updated javadoc, release notes and changes; 1aeec988 is described below commit 1aeec98893992c799b42fcca7cb1a914a250b33e Author: Henri Biestro AuthorDate: Sun Jan 28 11:35:51 2024 +0100 JEXL-419: added positive permission syntax; - added tests, updated javadoc, release notes and changes; --- RELEASE-NOTES.txt | 1 + src/changes/changes.xml| 3 + .../jexl3/internal/introspection/ClassMap.java | 3 +- .../jexl3/internal/introspection/Permissions.java | 28 +-- .../internal/introspection/PermissionsParser.java | 50 - .../jexl3/introspection/JexlPermissions.java | 39 -- .../org/apache/commons/jexl3/Issues400Test.java| 41 ++ .../internal/introspection/PermissionsTest.java| 87 +- 8 files changed, 199 insertions(+), 53 deletions(-) diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt index b53f7d24..a059780d 100644 --- a/RELEASE-NOTES.txt +++ b/RELEASE-NOTES.txt @@ -30,6 +30,7 @@ Version 3.3.1 is source and binary compatible with 3.3. New Features in 3.3.1: +* JEXL-419: Add permission syntax to allow class/method/field * JEXL-408: Using JexlFeatures is tedious * JEXL-404: Support array-access safe navigation (x?[y]) * JEXL-401: Captured variables should be read-only diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 03e9d0dc..3bfb20bd 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -29,6 +29,9 @@ + +Add permission syntax to allow class/method/field + Using JexlFeatures is tedious diff --git a/src/main/java/org/apache/commons/jexl3/internal/introspection/ClassMap.java b/src/main/java/org/apache/commons/jexl3/internal/introspection/ClassMap.java index fac798e5..f3bd5372 100644 --- a/src/main/java/org/apache/commons/jexl3/internal/introspection/ClassMap.java +++ b/src/main/java/org/apache/commons/jexl3/internal/introspection/ClassMap.java @@ -262,8 +262,7 @@ final class ClassMap { } // now that we've got all methods keyed in, lets organize them by name if (!cache.byKey.isEmpty()) { -final List lm = new ArrayList<>(cache.byKey.size()); -lm.addAll(cache.byKey.values()); +final List lm = new ArrayList<>(cache.byKey.values()); // sort all methods by name lm.sort(Comparator.comparing(Method::getName)); // put all lists of methods with same name in byName cache diff --git a/src/main/java/org/apache/commons/jexl3/internal/introspection/Permissions.java b/src/main/java/org/apache/commons/jexl3/internal/introspection/Permissions.java index 692a35e8..e3ca6f1a 100644 --- a/src/main/java/org/apache/commons/jexl3/internal/introspection/Permissions.java +++ b/src/main/java/org/apache/commons/jexl3/internal/introspection/Permissions.java @@ -56,21 +56,21 @@ public class Permissions implements JexlPermissions { */ static class NoJexlPackage { // the NoJexl class names -protected Map nojexl; +protected final Map nojexl; /** * Ctor. * @param map the map of NoJexl classes */ NoJexlPackage(final Map map) { -this.nojexl = map; +this.nojexl = new ConcurrentHashMap<>(map == null ? Collections.emptyMap() : map); } /** * Default ctor. */ NoJexlPackage() { -this(new ConcurrentHashMap<>()); +this(null); } boolean isEmpty() { return nojexl.isEmpty(); } @@ -80,7 +80,11 @@ public class Permissions implements JexlPermissions { } void addNoJexl(final String key, final NoJexlClass njc) { -nojexl.put(key, njc); +if (njc == null) { +nojexl.remove(key); +} else { +nojexl.put(key, njc); +} } } @@ -120,12 +124,13 @@ public class Permissions implements JexlPermissions { /** * Equivalent of @NoJexl on a ctor, a method or a field in a class. + * Field or method that are named are denied access. */ static class NoJexlClass { // the NoJexl method names (including ctor, name of class) -protected Set methodNames; +protected final Set methodNames; // the NoJexl field names -protected Set fieldNames; +protected final Set fieldNames; NoJexlClass(final Set m
(commons-jexl) branch master updated: JEXL-398: re-allow dot-ed expression for map keys; - fix array/set/map builders to use extended flag; - re-allow [,...] as valid empty syntax;
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 3e54d5e0 JEXL-398: re-allow dot-ed expression for map keys; - fix array/set/map builders to use extended flag; - re-allow [,...] as valid empty syntax; new f8311d59 Merge remote-tracking branch 'origin/master' 3e54d5e0 is described below commit 3e54d5e0078c76bcbfdb047588e23e2bc4ed54c4 Author: henrib AuthorDate: Tue Jan 23 11:34:26 2024 +0100 JEXL-398: re-allow dot-ed expression for map keys; - fix array/set/map builders to use extended flag; - re-allow [,...] as valid empty syntax; --- .../org/apache/commons/jexl3/JexlArithmetic.java | 13 +++--- .../org/apache/commons/jexl3/parser/Parser.jjt | 4 +- .../org/apache/commons/jexl3/Issues300Test.java| 48 +- 3 files changed, 57 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/apache/commons/jexl3/JexlArithmetic.java b/src/main/java/org/apache/commons/jexl3/JexlArithmetic.java index 585cf15d..006bc426 100644 --- a/src/main/java/org/apache/commons/jexl3/JexlArithmetic.java +++ b/src/main/java/org/apache/commons/jexl3/JexlArithmetic.java @@ -284,8 +284,9 @@ public class JexlArithmetic { * @return the array builder */ public ArrayBuilder arrayBuilder(final int size, final boolean extended) { -return new org.apache.commons.jexl3.internal.ArrayBuilder(size); +return new org.apache.commons.jexl3.internal.ArrayBuilder(size, extended); } + @Deprecated /** * @deprecated since 3.3.1 @@ -322,8 +323,9 @@ public class JexlArithmetic { * @return the array builder */ public SetBuilder setBuilder(final int size, final boolean extended) { -return new org.apache.commons.jexl3.internal.SetBuilder(size); +return new org.apache.commons.jexl3.internal.SetBuilder(size, extended); } + @Deprecated /** * @deprecated since 3.3.1 @@ -361,8 +363,9 @@ public class JexlArithmetic { * @return the map builder */ public MapBuilder mapBuilder(final int size, final boolean extended) { -return new org.apache.commons.jexl3.internal.MapBuilder(size); +return new org.apache.commons.jexl3.internal.MapBuilder(size, extended); } + @Deprecated /** * @deprecated since 3.3.1 @@ -683,7 +686,7 @@ public class JexlArithmetic { } if (val instanceof String) { final String string = (String) val; -if ("".equals(string)) { +if (string.isEmpty()) { return BigDecimal.ZERO; } return roundBigDecimal(new BigDecimal(string, getMathContext())); @@ -1144,7 +1147,7 @@ public class JexlArithmetic { * For convenience, booleans are converted as 1/0 (true/false). * * @param value argument - * @return true if argument can be represented by a long + * @return a non-null value if argument can be represented by a long */ protected Number asLongNumber(final Object value) { return asLongNumber(strict, value); diff --git a/src/main/java/org/apache/commons/jexl3/parser/Parser.jjt b/src/main/java/org/apache/commons/jexl3/parser/Parser.jjt index 520b3c8c..527f1e30 100644 --- a/src/main/java/org/apache/commons/jexl3/parser/Parser.jjt +++ b/src/main/java/org/apache/commons/jexl3/parser/Parser.jjt @@ -869,7 +869,7 @@ void ArrayLiteral() : {} { ( -ExtendedLiteral() +()? ExtendedLiteral() | (Expression() (LOOKAHEAD(2) Expression())* ( (ExtendedLiteral() { jjtThis.setExtended(true); })? )? )? @@ -890,7 +890,7 @@ void MapLiteral() : {} void MapEntry() : {} { -Identifier(true) Expression() +LOOKAHEAD(2) Identifier(true) Expression() | Expression() Expression() } diff --git a/src/test/java/org/apache/commons/jexl3/Issues300Test.java b/src/test/java/org/apache/commons/jexl3/Issues300Test.java index e89e46f1..7baa7908 100644 --- a/src/test/java/org/apache/commons/jexl3/Issues300Test.java +++ b/src/test/java/org/apache/commons/jexl3/Issues300Test.java @@ -28,7 +28,9 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; +import java.util.HashSet; import java.util.LinkedHashMap; +import java.util.LinkedHashSet; import java.util.List; import java.util.Map; import java.util.concurrent.atomic.AtomicInteger; @@ -1227,8 +1229,9 @@ public class Issues300Test { result = (String) script.execute(null, proxy); Assert.assertEquals(control, result); } + @Test -public void testIssue398() { +public void testIssue398a() { final String src = "let m = {\n" + " \"foo\": 1,\n" + " \
(commons-jexl) branch master updated: JEXL-398: re-allow dot-ed expression for map keys; - fix array/set/map builders to use extended flag; - re-allow [,...] as valid empty syntax;
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 ca55aa8e JEXL-398: re-allow dot-ed expression for map keys; - fix array/set/map builders to use extended flag; - re-allow [,...] as valid empty syntax; ca55aa8e is described below commit ca55aa8e9ad4265e4a764ac3c7eab8f057bd5e1c Author: henrib AuthorDate: Tue Jan 23 11:34:26 2024 +0100 JEXL-398: re-allow dot-ed expression for map keys; - fix array/set/map builders to use extended flag; - re-allow [,...] as valid empty syntax; --- .../org/apache/commons/jexl3/JexlArithmetic.java | 19 + .../org/apache/commons/jexl3/parser/Parser.jjt | 4 +- .../org/apache/commons/jexl3/Issues300Test.java| 48 +- 3 files changed, 60 insertions(+), 11 deletions(-) diff --git a/src/main/java/org/apache/commons/jexl3/JexlArithmetic.java b/src/main/java/org/apache/commons/jexl3/JexlArithmetic.java index 585cf15d..8e24523e 100644 --- a/src/main/java/org/apache/commons/jexl3/JexlArithmetic.java +++ b/src/main/java/org/apache/commons/jexl3/JexlArithmetic.java @@ -284,12 +284,13 @@ public class JexlArithmetic { * @return the array builder */ public ArrayBuilder arrayBuilder(final int size, final boolean extended) { -return new org.apache.commons.jexl3.internal.ArrayBuilder(size); +return new org.apache.commons.jexl3.internal.ArrayBuilder(size, extended); } -@Deprecated + /** * @deprecated since 3.3.1 */ +@Deprecated public ArrayBuilder arrayBuilder(final int size) { return arrayBuilder(size, false); } @@ -322,12 +323,13 @@ public class JexlArithmetic { * @return the array builder */ public SetBuilder setBuilder(final int size, final boolean extended) { -return new org.apache.commons.jexl3.internal.SetBuilder(size); +return new org.apache.commons.jexl3.internal.SetBuilder(size, extended); } -@Deprecated + /** * @deprecated since 3.3.1 */ +@Deprecated public SetBuilder setBuilder(final int size) { return setBuilder(size, false); } @@ -361,12 +363,13 @@ public class JexlArithmetic { * @return the map builder */ public MapBuilder mapBuilder(final int size, final boolean extended) { -return new org.apache.commons.jexl3.internal.MapBuilder(size); +return new org.apache.commons.jexl3.internal.MapBuilder(size, extended); } -@Deprecated + /** * @deprecated since 3.3.1 */ +@Deprecated public MapBuilder mapBuilder(final int size) { return mapBuilder(size, false); } @@ -683,7 +686,7 @@ public class JexlArithmetic { } if (val instanceof String) { final String string = (String) val; -if ("".equals(string)) { +if (string.isEmpty()) { return BigDecimal.ZERO; } return roundBigDecimal(new BigDecimal(string, getMathContext())); @@ -1144,7 +1147,7 @@ public class JexlArithmetic { * For convenience, booleans are converted as 1/0 (true/false). * * @param value argument - * @return true if argument can be represented by a long + * @return a non-null value if argument can be represented by a long */ protected Number asLongNumber(final Object value) { return asLongNumber(strict, value); diff --git a/src/main/java/org/apache/commons/jexl3/parser/Parser.jjt b/src/main/java/org/apache/commons/jexl3/parser/Parser.jjt index 520b3c8c..527f1e30 100644 --- a/src/main/java/org/apache/commons/jexl3/parser/Parser.jjt +++ b/src/main/java/org/apache/commons/jexl3/parser/Parser.jjt @@ -869,7 +869,7 @@ void ArrayLiteral() : {} { ( -ExtendedLiteral() +()? ExtendedLiteral() | (Expression() (LOOKAHEAD(2) Expression())* ( (ExtendedLiteral() { jjtThis.setExtended(true); })? )? )? @@ -890,7 +890,7 @@ void MapLiteral() : {} void MapEntry() : {} { -Identifier(true) Expression() +LOOKAHEAD(2) Identifier(true) Expression() | Expression() Expression() } diff --git a/src/test/java/org/apache/commons/jexl3/Issues300Test.java b/src/test/java/org/apache/commons/jexl3/Issues300Test.java index e89e46f1..7baa7908 100644 --- a/src/test/java/org/apache/commons/jexl3/Issues300Test.java +++ b/src/test/java/org/apache/commons/jexl3/Issues300Test.java @@ -28,7 +28,9 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; +import java.util.HashSet; import java.util.LinkedHashMap; +import java.util.LinkedHashSet; import java.util.List; import java.util.Map; import java.util.concurrent.atomic.AtomicInteger; @@ -1227,8 +1229,9 @@ public class Iss
(commons-jexl) branch master updated: JEXL-412: try a different map-entry vs ns call resolution;
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 5072cdd3 JEXL-412: try a different map-entry vs ns call resolution; 5072cdd3 is described below commit 5072cdd36c1e80e0889f24133606a8cf6d7d4fe7 Author: Henri Biestro AuthorDate: Mon Dec 18 19:26:21 2023 +0100 JEXL-412: try a different map-entry vs ns call resolution; --- .../org/apache/commons/jexl3/internal/Engine.java | 3 -- .../apache/commons/jexl3/parser/JexlParser.java| 4 +-- .../org/apache/commons/jexl3/parser/Parser.jjt | 2 ++ .../org/apache/commons/jexl3/Issues400Test.java| 34 +- 4 files changed, 25 insertions(+), 18 deletions(-) diff --git a/src/main/java/org/apache/commons/jexl3/internal/Engine.java b/src/main/java/org/apache/commons/jexl3/internal/Engine.java index e824f5b2..6057d01b 100644 --- a/src/main/java/org/apache/commons/jexl3/internal/Engine.java +++ b/src/main/java/org/apache/commons/jexl3/internal/Engine.java @@ -997,9 +997,6 @@ public class Engine extends JexlEngine { protected ASTJexlScript parse(final JexlInfo info, final JexlFeatures parsingf, final String src, final Scope scope) { final boolean cached = src.length() < cacheThreshold && cache != null; final JexlFeatures features = parsingf != null ? parsingf : DEFAULT_FEATURES; - // if (features.getNameSpaces().isEmpty() && !functions.isEmpty()) { - // features = new JexlFeatures(features).nameSpaces(functions.keySet()); - // } final Source source = cached? new Source(features, src) : null; ASTJexlScript script; if (source != null) { diff --git a/src/main/java/org/apache/commons/jexl3/parser/JexlParser.java b/src/main/java/org/apache/commons/jexl3/parser/JexlParser.java index 290e3c01..21f8e84b 100644 --- a/src/main/java/org/apache/commons/jexl3/parser/JexlParser.java +++ b/src/main/java/org/apache/commons/jexl3/parser/JexlParser.java @@ -28,8 +28,8 @@ import java.util.LinkedHashSet; import java.util.Map; import java.util.Set; import java.util.TreeMap; -import java.util.function.Predicate; +import org.apache.commons.jexl3.JexlContext; import org.apache.commons.jexl3.JexlEngine; import org.apache.commons.jexl3.JexlException; import org.apache.commons.jexl3.JexlFeatures; @@ -602,7 +602,7 @@ public abstract class JexlParser extends StringParser { final String name = ns.image; if (isVariable(name)) { // the namespace sticks to the colon as in 'ns:fun()' (vs 'ns : fun()') -return colon.beginColumn - 1 == ns.endColumn && isNamespace(name); +return colon.beginColumn - 1 == ns.endColumn && ((colon.endColumn == fun.beginColumn - 1) || isNamespace(name)); } return true; } diff --git a/src/main/java/org/apache/commons/jexl3/parser/Parser.jjt b/src/main/java/org/apache/commons/jexl3/parser/Parser.jjt index 725c5582..520b3c8c 100644 --- a/src/main/java/org/apache/commons/jexl3/parser/Parser.jjt +++ b/src/main/java/org/apache/commons/jexl3/parser/Parser.jjt @@ -890,6 +890,8 @@ void MapLiteral() : {} void MapEntry() : {} { +Identifier(true) Expression() +| Expression() Expression() } diff --git a/src/test/java/org/apache/commons/jexl3/Issues400Test.java b/src/test/java/org/apache/commons/jexl3/Issues400Test.java index c11b28c4..e1f79bb1 100644 --- a/src/test/java/org/apache/commons/jexl3/Issues400Test.java +++ b/src/test/java/org/apache/commons/jexl3/Issues400Test.java @@ -237,19 +237,27 @@ public class Issues400Test { final Map ctl = new HashMap<>(); ctl.put("one", 1); ctl.put("two", 2); -final String fnsrc = "function f(x) { x }\n" + -"let one = 'one', two = 'two';\n" + -"{ one : f(1), two:f(2) }"; -final JexlContext jc = new MapContext(); -final JexlEngine jexl = new JexlBuilder().create(); -try { - final JexlScript e = jexl.createScript(fnsrc); - final Object o = e.execute(jc); - Assert.assertTrue(o instanceof Map); - Map map = (Map) o; - Assert.assertEquals(map, ctl); -} catch (JexlException.Parsing xparse) { - Assert.fail(fnsrc + " : " + xparse.getMessage()); +final String fnsrc0 = "function f(x) { x }\n" + +"let one = 'one', two = 'two';\n"; +for(String map0 : Arrays.asList( +"{ one : f(1), two:f(2) }", +"{ one: f(1), two: f(2) }", +"{ one: f(1), two:f(2) }", +"{ one :f(1), two:f(2) }")) { + final String fnsrc = fnsrc0 + map0; + final JexlContext jc = new MapContext(); + final JexlEngine jexl = new JexlBuilder().create(); + try { +
(commons-jexl) branch master updated: JEXL-412: module declares namespace;
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 0b5883d2 JEXL-412: module declares namespace; 0b5883d2 is described below commit 0b5883d21cb2f981f474c6047238998b0a6a916a Author: henrib AuthorDate: Wed Dec 13 14:22:34 2023 +0100 JEXL-412: module declares namespace; --- .../apache/commons/jexl3/parser/JexlParser.java| 30 -- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/src/main/java/org/apache/commons/jexl3/parser/JexlParser.java b/src/main/java/org/apache/commons/jexl3/parser/JexlParser.java index a5235a53..290e3c01 100644 --- a/src/main/java/org/apache/commons/jexl3/parser/JexlParser.java +++ b/src/main/java/org/apache/commons/jexl3/parser/JexlParser.java @@ -207,7 +207,7 @@ public abstract class JexlParser extends StringParser { } /** - * Disables pragma feature is pragma-anywhere feature is disabled. + * Disables pragma feature if pragma-anywhere feature is disabled. */ protected void controlPragmaAnywhere() { final JexlFeatures features = getFeatures(); @@ -411,7 +411,7 @@ public abstract class JexlParser extends StringParser { /** * Declares a local function. * @param variable the identifier used to declare - * @param token the variable name toekn + * @param token the variable name token */ protected void declareFunction(final ASTVar variable, final Token token) { final String name = token.image; @@ -545,19 +545,21 @@ public abstract class JexlParser extends StringParser { if (pragmas == null) { pragmas = new TreeMap<>(); } -// declaring a namespace -final Predicate ns = features.namespaceTest(); -if (ns != null && key.startsWith(PRAGMA_JEXLNS)) { -if (!features.supportsNamespacePragma()) { -throwFeatureException(JexlFeatures.NS_PRAGMA, getToken(0)); -} -// jexl.namespace.*** -final String nsname = key.substring(PRAGMA_JEXLNS.length()); -if (!nsname.isEmpty()) { -if (namespaces == null) { -namespaces = new HashSet<>(); +// declaring a namespace or module +final String[] nsprefixes = { PRAGMA_JEXLNS, PRAGMA_MODULE }; +for(String nsprefix : nsprefixes) { +if (key.startsWith(nsprefix)) { +if (!features.supportsNamespacePragma()) { +throwFeatureException(JexlFeatures.NS_PRAGMA, getToken(0)); } -namespaces.add(nsname); +final String nsname = key.substring(nsprefix.length()); +if (!nsname.isEmpty()) { +if (namespaces == null) { +namespaces = new HashSet<>(); +} +namespaces.add(nsname); +} +break; } } // merge new value into a set created on the fly if key is already mapped
(commons-jexl) branch master updated: JEXL-417: improve number narrowing; updated javadoc; updated test;
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 d894074f JEXL-417: improve number narrowing; updated javadoc; updated test; d894074f is described below commit d894074fb485c8f23ca5111ad1470dc6018bc9fb Author: Henri Biestro AuthorDate: Tue Nov 28 21:42:30 2023 +0100 JEXL-417: improve number narrowing; updated javadoc; updated test; --- .../org/apache/commons/jexl3/JexlArithmetic.java | 167 ++--- .../org/apache/commons/jexl3/ArithmeticTest.java | 12 +- 2 files changed, 91 insertions(+), 88 deletions(-) diff --git a/src/main/java/org/apache/commons/jexl3/JexlArithmetic.java b/src/main/java/org/apache/commons/jexl3/JexlArithmetic.java index 90a1660f..585cf15d 100644 --- a/src/main/java/org/apache/commons/jexl3/JexlArithmetic.java +++ b/src/main/java/org/apache/commons/jexl3/JexlArithmetic.java @@ -41,15 +41,14 @@ import org.apache.commons.jexl3.introspection.JexlMethod; * * The 5 base arithmetic operators (+, - , *, /, %) follow the same evaluation rules regarding their arguments. * - * If both are null, result is 0 - * If either is a BigDecimal, coerce both to BigDecimal and perform operation - * If either is a floating point number, coerce both to Double and perform operation - * Else treat as BigInteger, perform operation and attempt to narrow result: - * - * if both arguments can be narrowed to Integer, narrow result to Integer - * if both arguments can be narrowed to Long, narrow result to Long - * Else return result as BigInteger - * + * If both are null, result is 0 if arithmetic (or operator) is non-strict, ArithmeticException is thrown + * otherwise + * If both arguments are numberable - any kind of integer including boolean -, coerce both to Long and coerce + * result to the most precise argument class (boolean byte short int long); + * if long operation would cause overflow, return a BigInteger + * If either argument is a BigDecimal, coerce both to BigDecimal, operator returns BigDecimal + * If either argument is a floating point number, coerce both to Double, operator returns Double + * Else treat as BigInteger, perform operation and narrow result to the most precise argument class * * * @@ -68,8 +67,8 @@ public class JexlArithmetic { /** Double.MAX_VALUE as BigDecimal. */ protected static final BigDecimal BIGD_DOUBLE_MAX_VALUE = BigDecimal.valueOf(Double.MAX_VALUE); -/** Double.MIN_VALUE as BigDecimal. */ -protected static final BigDecimal BIGD_DOUBLE_MIN_VALUE = BigDecimal.valueOf(Double.MIN_VALUE); +/** -Double.MAX_VALUE as BigDecimal. */ +protected static final BigDecimal BIGD_DOUBLE_MIN_VALUE = BigDecimal.valueOf(-Double.MAX_VALUE); /** Long.MAX_VALUE as BigInteger. */ protected static final BigInteger BIGI_LONG_MAX_VALUE = BigInteger.valueOf(Long.MAX_VALUE); @@ -974,6 +973,18 @@ public class JexlArithmetic { return narrow == null || narrow.equals(source); } +/** + * Narrows a double to a float if there is no information loss. + * @param value the double value + * @param narrow the target narrow class + * @return the narrowed or initial number + */ +private Number narrow(final Class narrow, double value) { +return narrowAccept(narrow, Float.class) && (float) value == value +? (float) value +: value; +} + /** * Given a Number, return the value attempting to narrow it to a target class. * @@ -982,67 +993,55 @@ public class JexlArithmetic { * @return the narrowed number or the source if no narrowing was possible */ public Number narrowNumber(final Number original, final Class narrow) { -if (original == null) { -return null; -} -Number result = original; -if (original instanceof BigDecimal) { -final BigDecimal bigd = (BigDecimal) original; -// if it is bigger than a double, it can not be narrowed -if (bigd.compareTo(BIGD_DOUBLE_MAX_VALUE) > 0 -|| bigd.compareTo(BIGD_DOUBLE_MIN_VALUE) < 0) { -return original; -} -try { -final long l = bigd.longValueExact(); -// coerce to int when possible (int being so often used in method parms) -if (narrowAccept(narrow, Integer.class) -&& l <= Integer.MAX_VALUE -&& l >= Integer.MIN_VALUE) { -return (int) l; +if (original != null) { +final long value; +if (original instanceof BigDecimal) { +final BigDecimal big = (BigDec
(commons-jexl) branch master updated: JEXL-417: unused import;
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 4a7c8256 JEXL-417: unused import; 4a7c8256 is described below commit 4a7c8256bcf73474e837db5fcb6fa66d72d74d95 Author: Henri Biestro AuthorDate: Tue Nov 28 11:17:16 2023 +0100 JEXL-417: unused import; --- src/main/java/org/apache/commons/jexl3/JexlArithmetic.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/org/apache/commons/jexl3/JexlArithmetic.java b/src/main/java/org/apache/commons/jexl3/JexlArithmetic.java index 701422ba..90a1660f 100644 --- a/src/main/java/org/apache/commons/jexl3/JexlArithmetic.java +++ b/src/main/java/org/apache/commons/jexl3/JexlArithmetic.java @@ -29,7 +29,6 @@ import java.math.MathContext; import java.util.Collection; import java.util.Map; import java.util.concurrent.atomic.AtomicBoolean; -import java.util.concurrent.atomic.AtomicInteger; import java.util.regex.Matcher; import java.util.regex.Pattern;
(commons-jexl) branch master updated: JEXL-417: fix precision loss in JexlArithmetic; - added tests;
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 5ab46d99 JEXL-417: fix precision loss in JexlArithmetic; - added tests; 5ab46d99 is described below commit 5ab46d9935c992eab7ab7dce4f1fde196976c789 Author: Henri Biestro AuthorDate: Tue Nov 28 10:48:30 2023 +0100 JEXL-417: fix precision loss in JexlArithmetic; - added tests; --- RELEASE-NOTES.txt | 1 + src/changes/changes.xml| 3 + .../org/apache/commons/jexl3/JexlArithmetic.java | 125 - .../org/apache/commons/jexl3/ArithmeticTest.java | 51 ++--- 4 files changed, 114 insertions(+), 66 deletions(-) diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt index 5de131f8..b53f7d24 100644 --- a/RELEASE-NOTES.txt +++ b/RELEASE-NOTES.txt @@ -37,6 +37,7 @@ New Features in 3.3.1: Bugs Fixed in 3.3.1: === +* JEXL-417: JexlArithmetic looses precision during arithmetic operator execution * JEXL-416: Null-valued pragma throws NPE in 3.3 * JEXL-415: Incorrect template eval result * JEXL-414: SoftCache may suffer from race conditions diff --git a/src/changes/changes.xml b/src/changes/changes.xml index d058c067..e626ca33 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -42,6 +42,9 @@ Allow 'trailing commas' or ellipsis while defining array, map and set literals + +JexlArithmetic looses precision during arithmetic operator execution + Null-valued pragma throws NPE in 3.3 diff --git a/src/main/java/org/apache/commons/jexl3/JexlArithmetic.java b/src/main/java/org/apache/commons/jexl3/JexlArithmetic.java index c51d11a3..701422ba 100644 --- a/src/main/java/org/apache/commons/jexl3/JexlArithmetic.java +++ b/src/main/java/org/apache/commons/jexl3/JexlArithmetic.java @@ -29,6 +29,7 @@ import java.math.MathContext; import java.util.Collection; import java.util.Map; import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicInteger; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -1062,14 +1063,14 @@ public class JexlArithmetic { protected Number narrowBigInteger(final Object lhs, final Object rhs, final BigInteger bigi) { //coerce to long if possible if ((isNumberable(lhs) || isNumberable(rhs)) -&& bigi.compareTo(BIGI_LONG_MAX_VALUE) <= 0 -&& bigi.compareTo(BIGI_LONG_MIN_VALUE) >= 0) { +&& bigi.compareTo(BIGI_LONG_MAX_VALUE) <= 0 +&& bigi.compareTo(BIGI_LONG_MIN_VALUE) >= 0) { // coerce to int if possible final long l = bigi.longValue(); // coerce to int when possible (int being so often used in method parms) if (!(lhs instanceof Long || rhs instanceof Long) -&& l <= Integer.MAX_VALUE -&& l >= Integer.MIN_VALUE) { +&& l <= Integer.MAX_VALUE +&& l >= Integer.MIN_VALUE) { return (int) l; } return l; @@ -1079,7 +1080,7 @@ public class JexlArithmetic { /** * Given a BigDecimal, attempt to narrow it to an Integer or Long if it fits and - * one of the arguments is a numberable. + * one of the arguments is numberable. * * @param lhs the left-hand side operand that lead to the bigd result * @param rhs the right-hand side operand that lead to the bigd result @@ -1144,17 +1145,42 @@ public class JexlArithmetic { /** * Checks if value class is a number that can be represented exactly in a long. + * For convenience, booleans are converted as 1/0 (true/false). * * @param value argument * @return true if argument can be represented by a long */ protected Number asLongNumber(final Object value) { -return value instanceof Long -|| value instanceof Integer -|| value instanceof Short -|| value instanceof Byte -? (Number) value -: null; +return asLongNumber(strict, value); +} + +/** + * Checks if value class is a number that can be represented exactly in a long. + * For convenience, booleans are converted as 1/0 (true/false). + * + * @param strict whether null argument is converted as 0 or remains null + * @param value argument + * @return a non-null value if argument can be represented by a long + */ +protected Number asLongNumber(final boolean strict, final Obj
(commons-jexl) branch master updated: JEXL-416: fixed edge case of null pragma value; - added unit test;
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 0a2e9432 JEXL-416: fixed edge case of null pragma value; - added unit test; 0a2e9432 is described below commit 0a2e94323a642cc224b1b97ce28e87aaf073408e Author: Henri Biestro AuthorDate: Thu Nov 23 17:04:41 2023 +0100 JEXL-416: fixed edge case of null pragma value; - added unit test; --- RELEASE-NOTES.txt | 1 + src/changes/changes.xml| 3 +++ .../apache/commons/jexl3/parser/JexlParser.java| 24 +- .../java/org/apache/commons/jexl3/PragmaTest.java | 9 4 files changed, 27 insertions(+), 10 deletions(-) diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt index ef675164..5de131f8 100644 --- a/RELEASE-NOTES.txt +++ b/RELEASE-NOTES.txt @@ -37,6 +37,7 @@ New Features in 3.3.1: Bugs Fixed in 3.3.1: === +* JEXL-416: Null-valued pragma throws NPE in 3.3 * JEXL-415: Incorrect template eval result * JEXL-414: SoftCache may suffer from race conditions * JEXL-412: Ambiguous syntax between namespace function call and map object definition. diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 48c734d0..d058c067 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -42,6 +42,9 @@ Allow 'trailing commas' or ellipsis while defining array, map and set literals + +Null-valued pragma throws NPE in 3.3 + Incorrect template eval result. diff --git a/src/main/java/org/apache/commons/jexl3/parser/JexlParser.java b/src/main/java/org/apache/commons/jexl3/parser/JexlParser.java index fa5f127f..5b6f1147 100644 --- a/src/main/java/org/apache/commons/jexl3/parser/JexlParser.java +++ b/src/main/java/org/apache/commons/jexl3/parser/JexlParser.java @@ -562,16 +562,20 @@ public abstract class JexlParser extends StringParser { } } // merge new value into a set created on the fly if key is already mapped -pragmas.merge(key, value, (previous, newValue)->{ -if (previous instanceof Set) { -((Set) previous).add(newValue); -return previous; -} -final Set values = new LinkedHashSet<>(); -values.add(previous); -values.add(newValue); -return values; -}); +if (value == null) { +pragmas.putIfAbsent(key, null); +} else { +pragmas.merge(key, value, (previous, newValue) -> { +if (previous instanceof Set) { +((Set) previous).add(newValue); +return previous; +} +final Set values = new LinkedHashSet<>(); +values.add(previous); +values.add(newValue); +return values; +}); +} } /** diff --git a/src/test/java/org/apache/commons/jexl3/PragmaTest.java b/src/test/java/org/apache/commons/jexl3/PragmaTest.java index a80ed537..95ba9068 100644 --- a/src/test/java/org/apache/commons/jexl3/PragmaTest.java +++ b/src/test/java/org/apache/commons/jexl3/PragmaTest.java @@ -376,4 +376,13 @@ public class PragmaTest extends JexlTestCase { final Object result = script.execute(jc); Assert.assertEquals(42, result); } + +@Test +public void testIssue416() { +final JexlEngine jexl = new JexlBuilder().create(); +JexlScript script = jexl.createScript("#pragma myNull null\n"); +Map pragmas = script.getPragmas(); +Assert.assertTrue("pragma key present?", pragmas.containsKey("myNull")); +Assert.assertNull("expected null value", pragmas.get("myNull")); +} }
(commons-jexl) branch master updated: JEXL-414: removed unused import;
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 44963a75 JEXL-414: removed unused import; 44963a75 is described below commit 44963a75e242dbb758fff18b1edd4a3041631d06 Author: Henri Biestro AuthorDate: Thu Nov 23 17:01:45 2023 +0100 JEXL-414: removed unused import; --- src/main/java/org/apache/commons/jexl3/JexlCache.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/main/java/org/apache/commons/jexl3/JexlCache.java b/src/main/java/org/apache/commons/jexl3/JexlCache.java index 1b13c04f..ff6afb1c 100644 --- a/src/main/java/org/apache/commons/jexl3/JexlCache.java +++ b/src/main/java/org/apache/commons/jexl3/JexlCache.java @@ -19,9 +19,6 @@ package org.apache.commons.jexl3; import java.util.Collection; import java.util.Collections; import java.util.Map; -import java.util.function.IntFunction; - -import org.apache.commons.jexl3.internal.SoftCache; /** * Caching scripts or templates interface.
(commons-jexl) branch master updated: JEXL-414: added performance tests; - added another JexlCache implementation for testing; - only kept one implementation as default;
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 2255bb35 JEXL-414: added performance tests; - added another JexlCache implementation for testing; - only kept one implementation as default; 2255bb35 is described below commit 2255bb3584e4102e401b15ab1f888f9169ad8bc8 Author: Henri Biestro AuthorDate: Thu Nov 23 16:42:47 2023 +0100 JEXL-414: added performance tests; - added another JexlCache implementation for testing; - only kept one implementation as default; --- src/test/java/org/apache/commons/jexl3/CachePerformanceTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/org/apache/commons/jexl3/CachePerformanceTest.java b/src/test/java/org/apache/commons/jexl3/CachePerformanceTest.java index 4906f988..86c23052 100644 --- a/src/test/java/org/apache/commons/jexl3/CachePerformanceTest.java +++ b/src/test/java/org/apache/commons/jexl3/CachePerformanceTest.java @@ -124,7 +124,7 @@ public class CachePerformanceTest { for (int c = 0; c < CACHED; ++c) { final int ctl = rnd.nextInt(SCRIPTS); for (int r = 0; r < HIT; ++r) { -JexlScript script = jexl.createScript(Integer.toString(ctl) + " + 42 - 42"); +JexlScript script = jexl.createScript(Integer.toString(ctl)); Object result = script.execute(null); assert ((Number) result).intValue() == ctl; count += 1;
(commons-jexl) branch master updated: JEXL-414: added performance tests; - added another JexlCache implementation for testing; - only kept one implementation as default;
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 b3689079 JEXL-414: added performance tests; - added another JexlCache implementation for testing; - only kept one implementation as default; b3689079 is described below commit b36890794bcbef32acc6b11899e5848f10905609 Author: Henri Biestro AuthorDate: Thu Nov 23 16:39:02 2023 +0100 JEXL-414: added performance tests; - added another JexlCache implementation for testing; - only kept one implementation as default; --- RELEASE-NOTES.txt | 1 + pom.xml| 1 + src/changes/changes.xml| 3 + .../java/org/apache/commons/jexl3/JexlBuilder.java | 3 +- .../java/org/apache/commons/jexl3/JexlCache.java | 24 +-- .../apache/commons/jexl3/internal/SoftCache.java | 144 ++--- .../apache/commons/jexl3/CachePerformanceTest.java | 179 + .../java/org/apache/commons/jexl3/CacheTest.java | 3 +- .../org/apache/commons/jexl3}/ConcurrentCache.java | 15 +- .../java/org/apache/commons/jexl3/SpreadCache.java | 147 + 10 files changed, 397 insertions(+), 123 deletions(-) diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt index 1d173c6f..ef675164 100644 --- a/RELEASE-NOTES.txt +++ b/RELEASE-NOTES.txt @@ -38,6 +38,7 @@ New Features in 3.3.1: Bugs Fixed in 3.3.1: === * JEXL-415: Incorrect template eval result +* JEXL-414: SoftCache may suffer from race conditions * JEXL-412: Ambiguous syntax between namespace function call and map object definition. * JEXL-410: JexlFeatures: ctor does not enable all features * JEXL-409: Disable LEXICAL should disable LEXICAL_SHADE diff --git a/pom.xml b/pom.xml index 04f3cf3b..482ba00b 100644 --- a/pom.xml +++ b/pom.xml @@ -126,6 +126,7 @@ com.googlecode.concurrentlinkedhashmap concurrentlinkedhashmap-lru 1.4.2 +test diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 80fc9107..48c734d0 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -45,6 +45,9 @@ Incorrect template eval result. + +SoftCache may suffer from race conditions + Ambiguous syntax between namespace function call and map object definition. diff --git a/src/main/java/org/apache/commons/jexl3/JexlBuilder.java b/src/main/java/org/apache/commons/jexl3/JexlBuilder.java index b67640d7..babc6655 100644 --- a/src/main/java/org/apache/commons/jexl3/JexlBuilder.java +++ b/src/main/java/org/apache/commons/jexl3/JexlBuilder.java @@ -24,6 +24,7 @@ import java.util.Map; import java.util.function.IntFunction; import org.apache.commons.jexl3.internal.Engine; +import org.apache.commons.jexl3.internal.SoftCache; import org.apache.commons.jexl3.introspection.JexlPermissions; import org.apache.commons.jexl3.introspection.JexlSandbox; import org.apache.commons.jexl3.introspection.JexlUberspect; @@ -134,7 +135,7 @@ public class JexlBuilder { private int cache = -1; /** The cache class factory. */ -private IntFunction> cacheFactory = JexlCache.createConcurrent(); +private IntFunction> cacheFactory = SoftCache::new; /** The stack overflow limit. */ private int stackOverflow = Integer.MAX_VALUE; diff --git a/src/main/java/org/apache/commons/jexl3/JexlCache.java b/src/main/java/org/apache/commons/jexl3/JexlCache.java index c7776e02..1b13c04f 100644 --- a/src/main/java/org/apache/commons/jexl3/JexlCache.java +++ b/src/main/java/org/apache/commons/jexl3/JexlCache.java @@ -21,7 +21,6 @@ import java.util.Collections; import java.util.Map; import java.util.function.IntFunction; -import org.apache.commons.jexl3.internal.ConcurrentCache; import org.apache.commons.jexl3.internal.SoftCache; /** @@ -31,7 +30,14 @@ import org.apache.commons.jexl3.internal.SoftCache; */ public interface JexlCache { /** - * Returns the cache size. + * Returns the cache capacity, the maximum number of elements it can contain. + * + * @return the cache capacity + */ + int capacity(); + + /** + * Returns the cache size, the actual number of elements it contains. * * @return the cache size */ @@ -69,18 +75,4 @@ public interface JexlCache { default Collection> entries() { return Collections.emptyList(); } - - /** - * @return a synchronized cache factory amenable to low concurrency usage - */ - static IntFunction> createSynchronized() { -return SoftCache::new; - } - - /** - * @return a concurrent cache factory amenable to high concurrency usage - */ - static IntFunction> c
(commons-jexl) branch master updated: JEXL-414: fixing wrong import order;
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 d9a31fdd JEXL-414: fixing wrong import order; d9a31fdd is described below commit d9a31fdd184b8e39fd7608729a5d2e5e699764d3 Author: Henri Biestro AuthorDate: Fri Nov 17 22:27:14 2023 -0800 JEXL-414: fixing wrong import order; --- src/main/java/org/apache/commons/jexl3/JexlCache.java| 1 + src/main/java/org/apache/commons/jexl3/internal/ConcurrentCache.java | 2 +- src/main/java/org/apache/commons/jexl3/internal/Engine.java | 2 +- src/main/java/org/apache/commons/jexl3/internal/SoftCache.java | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/apache/commons/jexl3/JexlCache.java b/src/main/java/org/apache/commons/jexl3/JexlCache.java index bd976fa4..c7776e02 100644 --- a/src/main/java/org/apache/commons/jexl3/JexlCache.java +++ b/src/main/java/org/apache/commons/jexl3/JexlCache.java @@ -55,6 +55,7 @@ public interface JexlCache { * * @param keythe cache entry key * @param script the cache entry value + * @return the previously associated value if any */ V put(K key, V script); diff --git a/src/main/java/org/apache/commons/jexl3/internal/ConcurrentCache.java b/src/main/java/org/apache/commons/jexl3/internal/ConcurrentCache.java index d04bfbb8..03c5648e 100644 --- a/src/main/java/org/apache/commons/jexl3/internal/ConcurrentCache.java +++ b/src/main/java/org/apache/commons/jexl3/internal/ConcurrentCache.java @@ -16,10 +16,10 @@ */ package org.apache.commons.jexl3.internal; +import java.lang.ref.SoftReference; import java.util.Collection; import java.util.Collections; import java.util.Map; -import java.lang.ref.SoftReference; import com.googlecode.concurrentlinkedhashmap.ConcurrentLinkedHashMap; diff --git a/src/main/java/org/apache/commons/jexl3/internal/Engine.java b/src/main/java/org/apache/commons/jexl3/internal/Engine.java index bb355b42..7153f827 100644 --- a/src/main/java/org/apache/commons/jexl3/internal/Engine.java +++ b/src/main/java/org/apache/commons/jexl3/internal/Engine.java @@ -34,9 +34,9 @@ import java.util.function.Consumer; import java.util.function.IntFunction; import java.util.function.Predicate; -import org.apache.commons.jexl3.JexlCache; import org.apache.commons.jexl3.JexlArithmetic; import org.apache.commons.jexl3.JexlBuilder; +import org.apache.commons.jexl3.JexlCache; import org.apache.commons.jexl3.JexlContext; import org.apache.commons.jexl3.JexlEngine; import org.apache.commons.jexl3.JexlException; diff --git a/src/main/java/org/apache/commons/jexl3/internal/SoftCache.java b/src/main/java/org/apache/commons/jexl3/internal/SoftCache.java index d5632da8..24db61ac 100644 --- a/src/main/java/org/apache/commons/jexl3/internal/SoftCache.java +++ b/src/main/java/org/apache/commons/jexl3/internal/SoftCache.java @@ -16,13 +16,13 @@ */ package org.apache.commons.jexl3.internal; +import java.lang.ref.SoftReference; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.Map; import java.util.Set; -import java.lang.ref.SoftReference; import org.apache.commons.jexl3.JexlCache;
(commons-jexl) branch master updated: JEXL-414: fixing wrong import order;
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 4ca9468a JEXL-414: fixing wrong import order; 4ca9468a is described below commit 4ca9468a59234b30b14be386795a66578119f13a Author: Henri Biestro AuthorDate: Fri Nov 17 20:45:46 2023 -0800 JEXL-414: fixing wrong import order; --- src/main/java/org/apache/commons/jexl3/internal/ConcurrentCache.java | 2 +- src/main/java/org/apache/commons/jexl3/internal/SoftCache.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/apache/commons/jexl3/internal/ConcurrentCache.java b/src/main/java/org/apache/commons/jexl3/internal/ConcurrentCache.java index 03c5648e..d04bfbb8 100644 --- a/src/main/java/org/apache/commons/jexl3/internal/ConcurrentCache.java +++ b/src/main/java/org/apache/commons/jexl3/internal/ConcurrentCache.java @@ -16,10 +16,10 @@ */ package org.apache.commons.jexl3.internal; -import java.lang.ref.SoftReference; import java.util.Collection; import java.util.Collections; import java.util.Map; +import java.lang.ref.SoftReference; import com.googlecode.concurrentlinkedhashmap.ConcurrentLinkedHashMap; diff --git a/src/main/java/org/apache/commons/jexl3/internal/SoftCache.java b/src/main/java/org/apache/commons/jexl3/internal/SoftCache.java index 24db61ac..d5632da8 100644 --- a/src/main/java/org/apache/commons/jexl3/internal/SoftCache.java +++ b/src/main/java/org/apache/commons/jexl3/internal/SoftCache.java @@ -16,13 +16,13 @@ */ package org.apache.commons.jexl3.internal; -import java.lang.ref.SoftReference; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.Map; import java.util.Set; +import java.lang.ref.SoftReference; import org.apache.commons.jexl3.JexlCache;
(commons-jexl) branch master updated: JEXL-414: fixing wrong import order;
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 75e38cb6 JEXL-414: fixing wrong import order; 75e38cb6 is described below commit 75e38cb6d264e758919c75f847fcd135ed900f07 Author: Henri Biestro AuthorDate: Fri Nov 17 20:44:16 2023 -0800 JEXL-414: fixing wrong import order; --- src/main/java/org/apache/commons/jexl3/JexlCache.java | 6 +++--- .../java/org/apache/commons/jexl3/internal/ConcurrentCache.java | 4 ++-- src/main/java/org/apache/commons/jexl3/internal/SoftCache.java | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/apache/commons/jexl3/JexlCache.java b/src/main/java/org/apache/commons/jexl3/JexlCache.java index 9bd9a734..bd976fa4 100644 --- a/src/main/java/org/apache/commons/jexl3/JexlCache.java +++ b/src/main/java/org/apache/commons/jexl3/JexlCache.java @@ -16,14 +16,14 @@ */ package org.apache.commons.jexl3; -import org.apache.commons.jexl3.internal.ConcurrentCache; -import org.apache.commons.jexl3.internal.SoftCache; - import java.util.Collection; import java.util.Collections; import java.util.Map; import java.util.function.IntFunction; +import org.apache.commons.jexl3.internal.ConcurrentCache; +import org.apache.commons.jexl3.internal.SoftCache; + /** * Caching scripts or templates interface. * @param source diff --git a/src/main/java/org/apache/commons/jexl3/internal/ConcurrentCache.java b/src/main/java/org/apache/commons/jexl3/internal/ConcurrentCache.java index 03a39166..03c5648e 100644 --- a/src/main/java/org/apache/commons/jexl3/internal/ConcurrentCache.java +++ b/src/main/java/org/apache/commons/jexl3/internal/ConcurrentCache.java @@ -16,13 +16,13 @@ */ package org.apache.commons.jexl3.internal; -import com.googlecode.concurrentlinkedhashmap.ConcurrentLinkedHashMap; - import java.lang.ref.SoftReference; import java.util.Collection; import java.util.Collections; import java.util.Map; +import com.googlecode.concurrentlinkedhashmap.ConcurrentLinkedHashMap; + /** * A cache whose underlying map is a ConcurrentLinkedHashMap. * diff --git a/src/main/java/org/apache/commons/jexl3/internal/SoftCache.java b/src/main/java/org/apache/commons/jexl3/internal/SoftCache.java index 60c80884..24db61ac 100644 --- a/src/main/java/org/apache/commons/jexl3/internal/SoftCache.java +++ b/src/main/java/org/apache/commons/jexl3/internal/SoftCache.java @@ -16,8 +16,6 @@ */ package org.apache.commons.jexl3.internal; -import org.apache.commons.jexl3.JexlCache; - import java.lang.ref.SoftReference; import java.util.ArrayList; import java.util.Collection; @@ -26,6 +24,8 @@ import java.util.List; import java.util.Map; import java.util.Set; +import org.apache.commons.jexl3.JexlCache; + /** * A soft referenced cache. *
(commons-jexl) branch master updated: JEXL-414: added cache interface, synchronized & concurrent implementations and factory handling;
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 e4b6b395 JEXL-414: added cache interface, synchronized & concurrent implementations and factory handling; e4b6b395 is described below commit e4b6b3956ed4f7e1404e4523c6629216b2384476 Author: Henri Biestro AuthorDate: Fri Nov 17 20:22:17 2023 -0800 JEXL-414: added cache interface, synchronized & concurrent implementations and factory handling; --- RELEASE-NOTES.txt | 1 + pom.xml| 5 + src/changes/changes.xml| 5 +- .../java/org/apache/commons/jexl3/JexlBuilder.java | 24 - .../java/org/apache/commons/jexl3/JexlCache.java | 85 +++ .../commons/jexl3/internal/ConcurrentCache.java| 58 ++ .../org/apache/commons/jexl3/internal/Engine.java | 12 ++- .../apache/commons/jexl3/internal/SoftCache.java | 118 +++-- .../commons/jexl3/internal/TemplateEngine.java | 5 +- .../java/org/apache/commons/jexl3/CacheTest.java | 15 ++- 10 files changed, 264 insertions(+), 64 deletions(-) diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt index 1dfb7d87..1d173c6f 100644 --- a/RELEASE-NOTES.txt +++ b/RELEASE-NOTES.txt @@ -37,6 +37,7 @@ New Features in 3.3.1: Bugs Fixed in 3.3.1: === +* JEXL-415: Incorrect template eval result * JEXL-412: Ambiguous syntax between namespace function call and map object definition. * JEXL-410: JexlFeatures: ctor does not enable all features * JEXL-409: Disable LEXICAL should disable LEXICAL_SHADE diff --git a/pom.xml b/pom.xml index c5a534dd..04f3cf3b 100644 --- a/pom.xml +++ b/pom.xml @@ -122,6 +122,11 @@ 2.10.1 test + +com.googlecode.concurrentlinkedhashmap +concurrentlinkedhashmap-lru +1.4.2 + diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 9d3c4c38..80fc9107 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -42,9 +42,12 @@ Allow 'trailing commas' or ellipsis while defining array, map and set literals + +Incorrect template eval result. + Ambiguous syntax between namespace function call and map object definition. -action> + JexlFeatures: ctor does not enable all features diff --git a/src/main/java/org/apache/commons/jexl3/JexlBuilder.java b/src/main/java/org/apache/commons/jexl3/JexlBuilder.java index 01656fef..b67640d7 100644 --- a/src/main/java/org/apache/commons/jexl3/JexlBuilder.java +++ b/src/main/java/org/apache/commons/jexl3/JexlBuilder.java @@ -21,6 +21,7 @@ import java.nio.charset.Charset; import java.util.Arrays; import java.util.Collection; import java.util.Map; +import java.util.function.IntFunction; import org.apache.commons.jexl3.internal.Engine; import org.apache.commons.jexl3.introspection.JexlPermissions; @@ -132,6 +133,9 @@ public class JexlBuilder { /** The cache size. */ private int cache = -1; +/** The cache class factory. */ +private IntFunction> cacheFactory = JexlCache.createConcurrent(); + /** The stack overflow limit. */ private int stackOverflow = Integer.MAX_VALUE; @@ -615,11 +619,29 @@ public class JexlBuilder { return this; } +/** + * Sets the expression cache size the engine will use. + * + * @param factory the function to produce a cache. + * @return this builder + */ +public JexlBuilder cacheFactory(final IntFunction> factory) { + this.cacheFactory = factory; + return this; +} + /** * @return the cache size */ public int cache() { -return cache; + return cache; +} + +/** + * @return the cache factory + */ +public IntFunction> cacheFactory() { + return this.cacheFactory; } /** diff --git a/src/main/java/org/apache/commons/jexl3/JexlCache.java b/src/main/java/org/apache/commons/jexl3/JexlCache.java new file mode 100644 index ..9bd9a734 --- /dev/null +++ b/src/main/java/org/apache/commons/jexl3/JexlCache.java @@ -0,0 +1,85 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + *
(commons-jexl) branch master updated: JEXL-415: fix handling of deferred/immediate characters not followed by curly bracket;
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 b2431dd4 JEXL-415: fix handling of deferred/immediate characters not followed by curly bracket; b2431dd4 is described below commit b2431dd4bdc5ede8a2a7b163d039b3e8056c3110 Author: Henri Biestro AuthorDate: Fri Nov 17 20:01:38 2023 -0800 JEXL-415: fix handling of deferred/immediate characters not followed by curly bracket; --- .../commons/jexl3/internal/TemplateEngine.java | 104 +++-- .../org/apache/commons/jexl3/Issues400Test.java| 23 + 2 files changed, 76 insertions(+), 51 deletions(-) diff --git a/src/main/java/org/apache/commons/jexl3/internal/TemplateEngine.java b/src/main/java/org/apache/commons/jexl3/internal/TemplateEngine.java index 8e15b9d1..6737f11e 100644 --- a/src/main/java/org/apache/commons/jexl3/internal/TemplateEngine.java +++ b/src/main/java/org/apache/commons/jexl3/internal/TemplateEngine.java @@ -838,8 +838,10 @@ public final class TemplateEngine extends JxltEngine { } else { // revert to CONST strb.append(immediateChar); -strb.append(c); state = ParseState.CONST; +// 'unread' the current character +column -= 1; +continue; } break; case DEFERRED0: // # @@ -854,8 +856,10 @@ public final class TemplateEngine extends JxltEngine { } else { // revert to CONST strb.append(deferredChar); -strb.append(c); state = ParseState.CONST; +// 'unread' the current character +column -= 1; +continue; } break; case IMMEDIATE1: // ${... @@ -884,59 +888,57 @@ public final class TemplateEngine extends JxltEngine { break; case DEFERRED1: // #{... // skip inner strings (for '}') - // nested immediate in deferred; need to balance count of '{' & '}' - // closing '}' switch (c) { -case '"': -case '\'': -strb.append(c); -column = StringParser.readString(strb, expr, column + 1, c); -continue; -case '{': -if (expr.charAt(column - 1) == immediateChar) { -inner1 += 1; -strb.deleteCharAt(strb.length() - 1); -nested = true; -} else { -deferred1 += 1; -strb.append(c); -} -continue; -case '}': -// balance nested immediate -if (deferred1 > 0) { -deferred1 -= 1; -strb.append(c); -} else if (inner1 > 0) { -inner1 -= 1; -} else { -// materialize the nested/deferred expr -final String src = strb.toString(); -TemplateExpression dexpr; -if (nested) { -dexpr = new NestedExpression( -expr.substring(inested, column + 1), -jexl.parse(info.at(lineno, column), noscript, src, scope), -null); -} else { -dexpr = new DeferredExpression( -strb.toString(), -jexl.parse(info.at(lineno, column), noscript, src, scope), -null); +case '"': +case '\'': +strb.append(c); +column = StringParser.readString(strb, expr, column + 1, c); +continue; +case '{': +if (expr.charAt(column - 1) == immediateChar) { +inner1 += 1; +strb.deleteCharAt(strb.length() - 1); +nested = true; +} else { +deferred1 += 1; +strb.append(c); +} +continue; +
(commons-jexl) branch master updated: JEXL-413: added option and tests;
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 e0e3e690 JEXL-413: added option and tests; e0e3e690 is described below commit e0e3e690fa86312896ca313f61a10321fc24f899 Author: Henri Biestro AuthorDate: Sun Nov 12 12:33:41 2023 -0800 JEXL-413: added option and tests; --- .../org/apache/commons/jexl3/JexlException.java| 5 +- .../java/org/apache/commons/jexl3/JexlOptions.java | 23 +++- .../org/apache/commons/jexl3/internal/Engine.java | 3 ++ .../apache/commons/jexl3/internal/Interpreter.java | 17 +++--- .../commons/jexl3/internal/InterpreterBase.java| 10 .../org/apache/commons/jexl3/Issues400Test.java| 61 +++--- 6 files changed, 104 insertions(+), 15 deletions(-) diff --git a/src/main/java/org/apache/commons/jexl3/JexlException.java b/src/main/java/org/apache/commons/jexl3/JexlException.java index a6f10ec6..c60b7296 100644 --- a/src/main/java/org/apache/commons/jexl3/JexlException.java +++ b/src/main/java/org/apache/commons/jexl3/JexlException.java @@ -504,7 +504,9 @@ public class JexlException extends RuntimeException { /** The variable is already declared. */ REDEFINED, /** The variable has a null value. */ -NULLVALUE; +NULLVALUE, +/** THe variable is const and an attempt is made to assign it*/ +CONST; /** * Stringifies the variable issue. @@ -515,6 +517,7 @@ public class JexlException extends RuntimeException { switch(this) { case NULLVALUE : return VARQUOTE + var + "' is null"; case REDEFINED : return VARQUOTE + var + "' is already defined"; +case CONST : return VARQUOTE + var + "' is const"; case UNDEFINED : default: return VARQUOTE + var + "' is undefined"; } diff --git a/src/main/java/org/apache/commons/jexl3/JexlOptions.java b/src/main/java/org/apache/commons/jexl3/JexlOptions.java index 66fcaa90..79f51d1c 100644 --- a/src/main/java/org/apache/commons/jexl3/JexlOptions.java +++ b/src/main/java/org/apache/commons/jexl3/JexlOptions.java @@ -42,6 +42,8 @@ import org.apache.commons.jexl3.internal.Engine; * @since 3.2 */ public final class JexlOptions { +/** The const capture bit. */ +private static final int CONST_CAPTURE = 8; /** The shared instance bit. */ private static final int SHARED = 7; /** The local shade bit. */ @@ -60,7 +62,7 @@ public final class JexlOptions { private static final int CANCELLABLE = 0; /** The flag names ordered. */ private static final String[] NAMES = { -"cancellable", "strict", "silent", "safe", "lexical", "antish", "lexicalShade", "sharedInstance" +"cancellable", "strict", "silent", "safe", "lexical", "antish", "lexicalShade", "sharedInstance", "constCapture" }; /** Default mask .*/ private static int DEFAULT = 1 /*<< CANCELLABLE*/ | 1 << STRICT | 1 << ANTISH | 1 << SAFE; @@ -299,6 +301,25 @@ public final class JexlOptions { } } +/** + * Sets whether lambda captured-variables are const or not. + * + * When disabled, lambda-captured variables are implicitly converted to read-write local variable (let), + * when enabled, those are implicitly converted to read-only local variables (const). + * + * @param flag true to enable, false to disable + */ +public void setConstCapture(final boolean flag) { +flags = set(CONST_CAPTURE, flags, true); +} + +/** + * @return true if lambda captured-variables are const, false otherwise + */ +public boolean isConstCapture() { +return isSet(CONST_CAPTURE, flags); +} + /** * Sets the arithmetic math context. * @param mcontext the context diff --git a/src/main/java/org/apache/commons/jexl3/internal/Engine.java b/src/main/java/org/apache/commons/jexl3/internal/Engine.java index f381fff2..fa304700 100644 --- a/src/main/java/org/apache/commons/jexl3/internal/Engine.java +++ b/src/main/java/org/apache/commons/jexl3/internal/Engine.java @@ -411,6 +411,9 @@ public class Engine extends JexlEngine { if (scriptFeatures.isLexicalShade()) { opts.setLexicalShade(true); } +if (scriptFeatures.supportsConstCapture()) { +opts.setConstCapture(true); +} } if (script != null) { // process script pragmas if any diff --git a/src/main/java/org/apache/commons/jexl3/internal/Interpr
(commons-jexl) 01/01: Merge pull request #209 from apache/dependabot/maven/org.moditect-moditect-maven-plugin-1.1.0
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 commit 8a95dbe421c84eaaa659ed8b0637d46c84d2c1b2 Merge: fd86178a 3c61aefb Author: Henrib AuthorDate: Fri Nov 10 15:58:12 2023 +0100 Merge pull request #209 from apache/dependabot/maven/org.moditect-moditect-maven-plugin-1.1.0 Bump org.moditect:moditect-maven-plugin from 1.0.0.Final to 1.1.0 pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
(commons-jexl) branch master updated (fd86178a -> 8a95dbe4)
This is an automated email from the ASF dual-hosted git repository. henrib pushed a change to branch master in repository https://gitbox.apache.org/repos/asf/commons-jexl.git from fd86178a JEXL: improve example on filter/map; keep inner classes close to usage to ease comprehension when reading code add 3c61aefb Bump org.moditect:moditect-maven-plugin from 1.0.0.Final to 1.1.0 new 8a95dbe4 Merge pull request #209 from apache/dependabot/maven/org.moditect-moditect-maven-plugin-1.1.0 The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference. Summary of changes: pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
(commons-jexl) branch master updated: JEXL: improve example on filter/map; keep inner classes close to usage to ease comprehension when reading code
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 fd86178a JEXL: improve example on filter/map; keep inner classes close to usage to ease comprehension when reading code fd86178a is described below commit fd86178aac2db17d102cf2e7513fdfde5b7c6af1 Author: Henri Biestro AuthorDate: Wed Nov 8 12:31:23 2023 +0100 JEXL: improve example on filter/map; keep inner classes close to usage to ease comprehension when reading code --- .../apache/commons/jexl3/examples/StreamTest.java | 64 +++--- 1 file changed, 20 insertions(+), 44 deletions(-) diff --git a/src/test/java/org/apache/commons/jexl3/examples/StreamTest.java b/src/test/java/org/apache/commons/jexl3/examples/StreamTest.java index b57cd720..962ca7b7 100644 --- a/src/test/java/org/apache/commons/jexl3/examples/StreamTest.java +++ b/src/test/java/org/apache/commons/jexl3/examples/StreamTest.java @@ -42,6 +42,26 @@ import org.junit.Test; * A test around scripting streams. */ public class StreamTest { + +/** Our engine instance. */ +private final JexlEngine jexl; + +public StreamTest() { +// Restricting features; no loops, no side effects +final JexlFeatures features = new JexlFeatures() +.loops(false) +.sideEffectGlobal(false) +.sideEffect(false); +// Restricted permissions to a safe set but with URI allowed +final JexlPermissions permissions = new ClassPermissions(java.net.URI.class); +// Create the engine +jexl = new JexlBuilder() +.features(features) +.permissions(permissions) +.namespaces(Collections.singletonMap("URI", java.net.URI.class)) +.create(); +} + /** * A MapContext that can operate on streams and collections. */ @@ -65,50 +85,6 @@ public class StreamTest { public Stream map(final Stream stream, final JexlScript mapper) { return stream.map( x -> mapper.execute(this, x)); } - -/** - * This allows using a JEXL lambda as a filter. - * @param collection the collection - * @param filter the lambda to use as filter - * @return the filtered result as a list - */ -public List filter(Collection collection, final JexlScript filter) { -return collection.stream() -.filter(x -> x != null && TRUE.equals(filter.execute(this, x))) -.collect(Collectors.toList()); -} - -/** - * This allows using a JEXL lambda as a mapper. - * @param collection the collection - * @param mapper the lambda to use as mapper - * @return the mapped result as a list - */ -public List map(Collection collection, final JexlScript mapper) { -return collection.stream() -.map(x -> mapper.execute(this, x)) -.filter(Objects::nonNull) -.collect(Collectors.toList()); -} -} - -/** Our engine instance. */ -private final JexlEngine jexl; - -public StreamTest() { -// Restricting features; no loops, no side effects -final JexlFeatures features = new JexlFeatures() -.loops(false) -.sideEffectGlobal(false) -.sideEffect(false); -// Restricted permissions to a safe set but with URI allowed -final JexlPermissions permissions = new ClassPermissions(java.net.URI.class); -// Create the engine -jexl = new JexlBuilder() -.features(features) -.permissions(permissions) -.namespaces(Collections.singletonMap("URI", java.net.URI.class)) -.create(); } @Test
(commons-jexl) branch master updated: JEXL: improve example on filter/map;
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 0c8b1ea0 JEXL: improve example on filter/map; 0c8b1ea0 is described below commit 0c8b1ea02497e1788288f75390fbad5fd6f95405 Author: Henri Biestro AuthorDate: Wed Nov 8 12:06:21 2023 +0100 JEXL: improve example on filter/map; --- .../apache/commons/jexl3/examples/StreamTest.java | 108 - 1 file changed, 103 insertions(+), 5 deletions(-) diff --git a/src/test/java/org/apache/commons/jexl3/examples/StreamTest.java b/src/test/java/org/apache/commons/jexl3/examples/StreamTest.java index 1f72d095..b57cd720 100644 --- a/src/test/java/org/apache/commons/jexl3/examples/StreamTest.java +++ b/src/test/java/org/apache/commons/jexl3/examples/StreamTest.java @@ -20,7 +20,10 @@ import static java.lang.Boolean.TRUE; import java.net.URI; import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; import java.util.List; +import java.util.Objects; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -40,7 +43,7 @@ import org.junit.Test; */ public class StreamTest { /** - * A MapContext that can operate on streams. + * A MapContext that can operate on streams and collections. */ public static class StreamContext extends MapContext { /** @@ -62,6 +65,31 @@ public class StreamTest { public Stream map(final Stream stream, final JexlScript mapper) { return stream.map( x -> mapper.execute(this, x)); } + +/** + * This allows using a JEXL lambda as a filter. + * @param collection the collection + * @param filter the lambda to use as filter + * @return the filtered result as a list + */ +public List filter(Collection collection, final JexlScript filter) { +return collection.stream() +.filter(x -> x != null && TRUE.equals(filter.execute(this, x))) +.collect(Collectors.toList()); +} + +/** + * This allows using a JEXL lambda as a mapper. + * @param collection the collection + * @param mapper the lambda to use as mapper + * @return the mapped result as a list + */ +public List map(Collection collection, final JexlScript mapper) { +return collection.stream() +.map(x -> mapper.execute(this, x)) +.filter(Objects::nonNull) +.collect(Collectors.toList()); +} } /** Our engine instance. */ @@ -76,13 +104,17 @@ public class StreamTest { // Restricted permissions to a safe set but with URI allowed final JexlPermissions permissions = new ClassPermissions(java.net.URI.class); // Create the engine -jexl = new JexlBuilder().features(features).permissions(permissions).create(); +jexl = new JexlBuilder() +.features(features) +.permissions(permissions) +.namespaces(Collections.singletonMap("URI", java.net.URI.class)) +.create(); } @Test -public void testURIStream() throws Exception { +public void testURIStream() { // let's assume a collection of uris need to be processed and transformed to be simplified ; -// we want only http/https ones, only the host part and using an https scheme +// we want only http/https ones, only the host part and using a https scheme final List uris = Arrays.asList( URI.create("http://u...@www.apache.org:8000?qry=true;), URI.create("https://commons.apache.org/releases/prepare.html;), @@ -91,7 +123,7 @@ public class StreamTest { // Create the test control, the expected result of our script evaluation final List control = uris.stream() .map(uri -> uri.getScheme().startsWith("http")? "https://; + uri.getHost() : null) -.filter(x -> x != null) +.filter(Objects::nonNull) .collect(Collectors.toList()); Assert.assertEquals(2, control.size()); @@ -114,4 +146,70 @@ public class StreamTest { Assert.assertTrue(transformed instanceof List); Assert.assertEquals(control, transformed); } + +/** + * A MapContext that can operate on streams and collections. + */ +public static class CollectionContext extends MapContext { +/** + * This allows using a JEXL lambda as a filter. + * @param collection the collection + * @param filter the lambda to use as filter + * @return the filtered result as a list + */ +public List filter(Collection collection, final JexlScript filter) { +
(commons-jexl) branch master updated: JEXL-412: improved ambiguity resolution for namespace funcall;
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 4692b3c6 JEXL-412: improved ambiguity resolution for namespace funcall; 4692b3c6 is described below commit 4692b3c606baca56a2d2f0a4cb34faa85f920eee Author: Henri Biestro AuthorDate: Fri Nov 3 13:17:43 2023 +0100 JEXL-412: improved ambiguity resolution for namespace funcall; --- RELEASE-NOTES.txt | 1 + src/changes/changes.xml| 3 ++ .../apache/commons/jexl3/parser/JexlParser.java| 60 +++--- .../org/apache/commons/jexl3/parser/Parser.jjt | 4 +- .../org/apache/commons/jexl3/Issues400Test.java| 43 5 files changed, 91 insertions(+), 20 deletions(-) diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt index 0334ee79..1dfb7d87 100644 --- a/RELEASE-NOTES.txt +++ b/RELEASE-NOTES.txt @@ -37,6 +37,7 @@ New Features in 3.3.1: Bugs Fixed in 3.3.1: === +* JEXL-412: Ambiguous syntax between namespace function call and map object definition. * JEXL-410: JexlFeatures: ctor does not enable all features * JEXL-409: Disable LEXICAL should disable LEXICAL_SHADE * JEXL-405: Recursive functions corrupt evaluation frame if reassigned diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 97e5fa12..9d3c4c38 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -42,6 +42,9 @@ Allow 'trailing commas' or ellipsis while defining array, map and set literals + +Ambiguous syntax between namespace function call and map object definition. +action> JexlFeatures: ctor does not enable all features diff --git a/src/main/java/org/apache/commons/jexl3/parser/JexlParser.java b/src/main/java/org/apache/commons/jexl3/parser/JexlParser.java index a353c2fc..fa5f127f 100644 --- a/src/main/java/org/apache/commons/jexl3/parser/JexlParser.java +++ b/src/main/java/org/apache/commons/jexl3/parser/JexlParser.java @@ -575,27 +575,51 @@ public abstract class JexlParser extends StringParser { } /** - * Checks whether a name identifies a declared namespace. - * @param token the namespace token - * @return true if the name qualifies a namespace + * Semantic check identifying whether a list of 4 tokens forms a namespace function call. + * This is needed to disambiguate ternary operator, map entries and actual calls. + * Note that this check is performed before syntactic check so the expected parameters need to be + * verified. + * @param ns the namespace token + * @param colon expected to be : + * @param fun the function name + * @param paren expected to be ( + * @return true if the name qualifies a namespace function call + */ +protected boolean isNamespaceFuncall(final Token ns, final Token colon, final Token fun, final Token paren) { +// let's make sure this is a namespace function call +if (!":".equals(colon.image)) { +return false; +} +if (!"(".equals(paren.image)) { +return false; +} +// if namespace name is shared with a variable name, use syntactic hint +final String name = ns.image; +if (isVariable(name)) { +// the namespace sticks to the colon as in 'ns:fun()' (vs 'ns : fun()') +return colon.beginColumn - 1 == ns.endColumn && isNamespace(name); +} +return true; +} + +/** + * Checks whether a name is a declared namespace. + * @param name the namespace name + * @return true if declared, false otherwise */ -protected boolean isDeclaredNamespace(final Token token, final Token colon) { -// syntactic hint, the namespace sticks to the colon -if (colon != null && ":".equals(colon.image) && colon.beginColumn - 1 == token.endColumn) { +private boolean isNamespace(String name) { +// templates +if ("jexl".equals(name) || "$jexl".equals(name)) { return true; } -// if name is shared with a variable name, use syntactic hint -final String name = token.image; -if (!isVariable(name)) { -final Set ns = namespaces; -// declared through local pragma ? -if (ns != null && ns.contains(name)) { -return true; -} -// declared through engine features ? -if (getFeatures().namespaceTest().test(name)) { -return true; -} +final Set ns = namespaces; +// declared through lo
[commons-jexl] branch master updated: JEXL-410: reduced unnecessary public exposure;
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 fc3e19ad JEXL-410: reduced unnecessary public exposure; fc3e19ad is described below commit fc3e19ad1106696711d8ac95b137e44325a4cb52 Author: Henri Biestro AuthorDate: Mon Oct 23 11:05:22 2023 +0200 JEXL-410: reduced unnecessary public exposure; --- src/test/java/org/apache/commons/jexl3/FeaturesTest.java | 8 +--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/test/java/org/apache/commons/jexl3/FeaturesTest.java b/src/test/java/org/apache/commons/jexl3/FeaturesTest.java index 1ab59642..c19a50fc 100644 --- a/src/test/java/org/apache/commons/jexl3/FeaturesTest.java +++ b/src/test/java/org/apache/commons/jexl3/FeaturesTest.java @@ -17,6 +17,7 @@ package org.apache.commons.jexl3; import java.util.Arrays; +import java.util.Collection; import org.junit.Assert; import org.junit.Test; @@ -373,8 +374,8 @@ public class FeaturesTest extends JexlTestCase { @Test public void test410a() { -long x = JexlFeatures.ALL_FEATURES; -Assert.assertEquals(23, Long.bitCount(x)); +long x = JexlFeatures.createAll().getFlags(); +Assert.assertEquals(CONST_CAPTURE + 1, Long.bitCount(x)); Assert.assertTrue((x & (1L << CONST_CAPTURE)) != 0); JexlFeatures all = JexlFeatures.createAll(); @@ -396,7 +397,8 @@ public class FeaturesTest extends JexlTestCase { Assert.assertFalse(features.supportsComparatorNames()); final JexlEngine jexl = new JexlBuilder().features(features).create(); -for(String varName : JexlFeatures.RESERVED_WORDS) { +Collection reserved = features.getReservedNames(); +for(String varName : reserved) { String src = "var " + varName; //JexlScript script = jexl.createScript(src); Assert.assertThrows(JexlException.Feature.class, () -> jexl.createScript(src));
[commons-jexl] branch master updated: JEXL-410: reduced unnecessary public exposure;
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 093cfbd9 JEXL-410: reduced unnecessary public exposure; 093cfbd9 is described below commit 093cfbd9c5003db8634b1a06e564f0debab2ccc0 Author: Henri Biestro AuthorDate: Mon Oct 23 11:05:47 2023 +0200 JEXL-410: reduced unnecessary public exposure; --- src/main/java/org/apache/commons/jexl3/JexlFeatures.java | 15 +++ 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/apache/commons/jexl3/JexlFeatures.java b/src/main/java/org/apache/commons/jexl3/JexlFeatures.java index 71349412..62536618 100644 --- a/src/main/java/org/apache/commons/jexl3/JexlFeatures.java +++ b/src/main/java/org/apache/commons/jexl3/JexlFeatures.java @@ -130,7 +130,7 @@ public final class JexlFeatures { * The default features flag mask. * Meant for compatibility with scripts written before 3.3.1 */ -public static final long DEFAULT_FEATURES = +private static final long DEFAULT_FEATURES = 1L << LOCAL_VAR | 1L << SIDE_EFFECT | 1L << SIDE_EFFECT_GLOBAL @@ -153,7 +153,7 @@ public final class JexlFeatures { * The canonical scripting (since 3.3.1) features flag mask based on the original default. * Adds lexical, lexical-shade and const-capture but removes comparator-names and pragma-anywhere */ -public static final long SCRIPT_FEATURES = +private static final long SCRIPT_FEATURES = ( DEFAULT_FEATURES | 1L << LEXICAL | 1L << LEXICAL_SHADE @@ -164,7 +164,7 @@ public final class JexlFeatures { /** * All features. */ -public static final long ALL_FEATURES = (1L << (CONST_CAPTURE + 1)) - 1L; +private static final long ALL_FEATURES = (1L << (CONST_CAPTURE + 1)) - 1L; /** * Creates an all features enabled set. @@ -221,7 +221,7 @@ public final class JexlFeatures { * try, catch, throw, finally, switch, case, default, class, instanceof, jexl, $jexl * @since 3.3.1 */ -public static final Set RESERVED_WORDS = +private static final Set RESERVED_WORDS = Collections.unmodifiableSet( new HashSet<>((Arrays.asList( "try", "catch", "throw", "finally", "switch", "case", "default", "class", "instanceof", "jexl", "$jexl"; @@ -362,6 +362,13 @@ public final class JexlFeatures { return nameSpaces; } +/** + * @return these featuress flags + */ +public long getFlags() { +return flags; +} + /** * Sets a feature flag. * @param feature the feature ordinal
[commons-jexl] branch master updated: JEXL-410: restored JexlFeatures protected ctor, documented its caveats;
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 2edb8269 JEXL-410: restored JexlFeatures protected ctor, documented its caveats; 2edb8269 is described below commit 2edb826947370d80c5c7826f0b5b6c713bdddb7e Author: Henri Biestro AuthorDate: Sat Oct 21 00:47:12 2023 +0200 JEXL-410: restored JexlFeatures protected ctor, documented its caveats; --- .../java/org/apache/commons/jexl3/JexlFeatures.java | 20 ++-- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/main/java/org/apache/commons/jexl3/JexlFeatures.java b/src/main/java/org/apache/commons/jexl3/JexlFeatures.java index 1e91af8e..71349412 100644 --- a/src/main/java/org/apache/commons/jexl3/JexlFeatures.java +++ b/src/main/java/org/apache/commons/jexl3/JexlFeatures.java @@ -218,13 +218,13 @@ public final class JexlFeatures { /** * Protected future syntactic elements. - * try, catch, throw, finally, switch, case, default, class, instanceof + * try, catch, throw, finally, switch, case, default, class, instanceof, jexl, $jexl * @since 3.3.1 */ public static final Set RESERVED_WORDS = Collections.unmodifiableSet( new HashSet<>((Arrays.asList( -"try", "catch", "throw", "finally", "switch", "case", "default", "class", "instanceof"; +"try", "catch", "throw", "finally", "switch", "case", "default", "class", "instanceof", "jexl", "$jexl"; /** * The modern scripting features set. @@ -264,15 +264,15 @@ public final class JexlFeatures { } /** - * An all member constructor for use by this class only + * An all member constructor for derivation. + * Not respecting immutability or thread-safety constraints for this class constructor arguments will + * likely result in unexpected behavior. * @param f flag - * @param r reserved variable names; must be an immutable Set - * @param n namespace predicate + * @param r reserved variable names; must be an immutable Set or thread-safe (concurrent or synchronized set) + * @param n namespace predicate; must be stateless or thread-safe */ -private JexlFeatures(final long f, final Set r, final Predicate n) { +protected JexlFeatures(final long f, final Set r, final Predicate n) { this.flags = f; -// N.B. reservedNames must be an immutable Set. -// This can only be guaranteed if this ctor is private this.reservedNames = r == null? Collections.emptySet() : r; this.nameSpaces = n == null? TEST_STR_FALSE : n; } @@ -316,8 +316,8 @@ public final class JexlFeatures { } /** - * Sets a collection of reserved names precluding those to be used as local variables or parameter names. - * @param names the names to reserve + * Sets a collection of reserved r precluding those to be used as local variables or parameter r. + * @param names the r to reserve * @return this features instance */ public JexlFeatures reservedNames(final Collection names) {
[commons-jexl] branch master updated: JEXL-410: added createAll() method to create a fully enabled set of JexlFeatures; - updated tests, Javadoc, release notes & changes;
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 5451c305 JEXL-410: added createAll() method to create a fully enabled set of JexlFeatures; - updated tests, Javadoc, release notes & changes; 5451c305 is described below commit 5451c30530af8dc1fc145bbee9ce23df73041b9c Author: Henri Biestro AuthorDate: Fri Oct 20 17:45:22 2023 +0200 JEXL-410: added createAll() method to create a fully enabled set of JexlFeatures; - updated tests, Javadoc, release notes & changes; --- RELEASE-NOTES.txt | 7 +- src/changes/changes.xml| 9 ++ .../org/apache/commons/jexl3/JexlFeatures.java | 103 ++--- .../org/apache/commons/jexl3/FeaturesTest.java | 51 +- 4 files changed, 132 insertions(+), 38 deletions(-) diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt index 109ee9e0..b00c1a95 100644 --- a/RELEASE-NOTES.txt +++ b/RELEASE-NOTES.txt @@ -19,7 +19,7 @@ Its goal is to expose scripting features usable by technical operatives or consu https://commons.apache.org/jexl/ -Release 3.2.1 +Release 3.3.1 Version 3.3.1 is a maintenance release. @@ -30,12 +30,15 @@ Version 3.3.1 is source and binary compatible with 3.3. New Features in 3.3.1: +* JEXL-408: Using JexlFeatures is tedious * JEXL-404: Support array-access safe navigation (x?[y]) * JEXL-401: Captured variables should be read-only * JEXL-398: Allow 'trailing commas' or ellipsis while defining array, map and set literals Bugs Fixed in 3.3.1: === +* JEXL-410: JexlFeatures: ctor does not enable all features +* JEXL-409: Disable LEXICAL should disable LEXICAL_SHADE * JEXL-405: Recursive functions corrupt evaluation frame if reassigned * JEXL-403: Exception while evaluating template literal used in array assignment in loop. * JEXL-402: parse failed with empty return value. @@ -57,7 +60,7 @@ accessible through scripts has a real impact on your application security and st an informed review and conscious choice on your end. To mitigate the change, you can revert to the previous behavior with one line of code (see JexlPermissions, JexlBuilder and JexlScriptEngine) or use this opportunity to reduce exposure. Whether Files, URLs, networking, processes, -class-loaders or reflection classes or whether loops or side-effects are accessible are part of your choice to make. +class-loaders or reflection classes or whether loops or side effects are accessible are part of your choice to make. What's new in 3.3: == diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 0916150f..97e5fa12 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -29,6 +29,9 @@ + +Using JexlFeatures is tedious + Support array-access safe navigation (x?[y]) @@ -39,6 +42,12 @@ Allow 'trailing commas' or ellipsis while defining array, map and set literals + +JexlFeatures: ctor does not enable all features + + +Disable LEXICAL should disable LEXICAL_SHADE + Recursive functions corrupt evaluation frame if reassigned diff --git a/src/main/java/org/apache/commons/jexl3/JexlFeatures.java b/src/main/java/org/apache/commons/jexl3/JexlFeatures.java index 02d3e26a..1e91af8e 100644 --- a/src/main/java/org/apache/commons/jexl3/JexlFeatures.java +++ b/src/main/java/org/apache/commons/jexl3/JexlFeatures.java @@ -16,8 +16,10 @@ */ package org.apache.commons.jexl3; +import java.util.Arrays; import java.util.Collection; import java.util.Collections; +import java.util.HashSet; import java.util.Objects; import java.util.Set; import java.util.TreeSet; @@ -25,8 +27,13 @@ import java.util.function.Predicate; /** * A set of language feature options. + * * These control syntactical constructs that will throw JexlException.Feature exceptions (a * subclass of JexlException.Parsing) when disabled. + * + * It is recommended to be explicit in choosing the features you need rather than rely on the default + * constructor: the 2 convenience methods {@link JexlFeatures#createNone()} and {@link JexlFeatures#createAll()} + * are the recommended starting points to selectively enable or disable chosen features. * * Registers:
[commons-jexl] branch master updated: JEXL-410: Javadoc
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 2e0e8e94 JEXL-410: Javadoc 2e0e8e94 is described below commit 2e0e8e940cbfb0feb146ccfec99abeacbb164972 Author: Henri Biestro AuthorDate: Wed Oct 18 15:40:00 2023 +0200 JEXL-410: Javadoc --- src/main/java/org/apache/commons/jexl3/JexlFeatures.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/apache/commons/jexl3/JexlFeatures.java b/src/main/java/org/apache/commons/jexl3/JexlFeatures.java index 4ed1f8d7..56939d30 100644 --- a/src/main/java/org/apache/commons/jexl3/JexlFeatures.java +++ b/src/main/java/org/apache/commons/jexl3/JexlFeatures.java @@ -169,7 +169,7 @@ public final class JexlFeatures { * Creates a default features set suitable for basic scripting needs. * Meant for legacy (before 3.3) scripting checks. * The following scripting features are enabled: - * + * * local variable {@link JexlFeatures#supportsLocalVar()} * side effect {@link JexlFeatures#supportsSideEffect()} * global side effect {@link JexlFeatures#supportsSideEffectGlobal()} @@ -186,7 +186,7 @@ public final class JexlFeatures { * namespace pragma {@link JexlFeatures#supportsNamespacePragma()} * import pragma {@link JexlFeatures#supportsImportPragma()} * pragma anywhere {@link JexlFeatures#supportsPragmaAnywhere()} - * + * * @return a new instance of a default scripting features set * @since 3.3.1 */
[commons-jexl] branch master updated: Javadoc, comments, formatting tidbits
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 891a6d7d Javadoc, comments, formatting tidbits 891a6d7d is described below commit 891a6d7d3f7afd8c1d14581c21fc589c56190e6b Author: Henri Biestro AuthorDate: Wed Oct 18 15:31:12 2023 +0200 Javadoc, comments, formatting tidbits --- .../org/apache/commons/jexl3/JexlArithmetic.java | 9 ++--- .../org/apache/commons/jexl3/internal/Debugger.java | 20 ++-- .../commons/jexl3/introspection/JexlPermissions.java | 9 + 3 files changed, 21 insertions(+), 17 deletions(-) diff --git a/src/main/java/org/apache/commons/jexl3/JexlArithmetic.java b/src/main/java/org/apache/commons/jexl3/JexlArithmetic.java index f92a0274..fc6ad8a4 100644 --- a/src/main/java/org/apache/commons/jexl3/JexlArithmetic.java +++ b/src/main/java/org/apache/commons/jexl3/JexlArithmetic.java @@ -1393,9 +1393,12 @@ public class JexlArithmetic { protected static boolean isMultiplyExact(final long x, final long y, final long r) { final long ax = Math.abs(x); final long ay = Math.abs(y); -return !((ax | ay) >>> Integer.SIZE - 1 != 0 - && (y != 0 && r / y != x - || x == Long.MIN_VALUE && y == -1)); +// Some bits greater than 2^31 that might cause overflow +// Check the result using the divide operator +// and check for the special case of Long.MIN_VALUE * -1 +return !(((ax | ay) >>> (Integer.SIZE - 1) != 0) + && ((y != 0 && r / y != x) + || (x == Long.MIN_VALUE && y == -1))); } /** diff --git a/src/main/java/org/apache/commons/jexl3/internal/Debugger.java b/src/main/java/org/apache/commons/jexl3/internal/Debugger.java index b0683ece..710cae8d 100644 --- a/src/main/java/org/apache/commons/jexl3/internal/Debugger.java +++ b/src/main/java/org/apache/commons/jexl3/internal/Debugger.java @@ -439,7 +439,7 @@ public class Debugger extends ParserVisitor implements JexlInfo.Detail { /** * Checks if a terminal node is the cause to debug adds its representation to the rebuilt expression. * @param node the child node - * @param image the child node token image (may be null) + * @param image the child node token image (optionally null) * @param data visitor pattern argument * @return visitor pattern value */ @@ -802,7 +802,7 @@ public class Debugger extends ParserVisitor implements JexlInfo.Detail { * (but underscore, at-sign, sharp-sign and dollar). */ protected static final Pattern QUOTED_IDENTIFIER = -Pattern.compile("[\\s]|[\\p{Punct}&&[^@#$_]]"); +Pattern.compile("\\s|\\p{Punct}&&[^@#$_]"); /** * Checks whether an identifier should be quoted or not. @@ -897,7 +897,9 @@ public class Debugger extends ParserVisitor implements JexlInfo.Detail { for (final Map.Entry pragma : pragmas.entrySet()) { final String key = pragma.getKey(); final Object value = pragma.getValue(); -final Set values = value instanceof Set ? (Set) value : Collections.singleton(value); +final Set values = value instanceof Set +? (Set) value +: Collections.singleton(value); for (final Object pragmaValue : values) { builder.append("#pragma "); builder.append(key); @@ -1054,8 +1056,6 @@ public class Debugger extends ParserVisitor implements JexlInfo.Detail { for (int i = 1; i < num; ++i) { if (!first) { builder.append(", "); -} else { -first = true; } accept(node.jjtGetChild(i), data); } @@ -1275,15 +1275,15 @@ public class Debugger extends ParserVisitor implements JexlInfo.Detail { if (child instanceof ASTAssignment) { final ASTAssignment assign = (ASTAssignment) child; final int nc = assign.jjtGetNumChildren(); -final ASTVar var = (ASTVar) assign.jjtGetChild(0); -builder.append(var.getName()); +final ASTVar avar = (ASTVar) assign.jjtGetChild(0); +builder.append(avar.getName()); if (nc > 1) { builder.append(" = "); accept(assign.jjtGetChild(1), data); } } else if (child instanceof ASTVar) { -final ASTVar var = (ASTVar) child; -
[commons-jexl] branch master updated: JEXL-410, JEXL-409, JEXL-408: added new methods to instantiate JexlFeatures with no/default/scripting features set; - fixed lexical/lexicalShade missing relations
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 41d69998 JEXL-410, JEXL-409, JEXL-408: added new methods to instantiate JexlFeatures with no/default/scripting features set; - fixed lexical/lexicalShade missing relationship; - updated doc; 41d69998 is described below commit 41d6999840bc54ad4b044924060406738337ffeb Author: Henri Biestro AuthorDate: Wed Oct 18 15:28:24 2023 +0200 JEXL-410, JEXL-409, JEXL-408: added new methods to instantiate JexlFeatures with no/default/scripting features set; - fixed lexical/lexicalShade missing relationship; - updated doc; --- .../org/apache/commons/jexl3/JexlFeatures.java | 135 - .../org/apache/commons/jexl3/FeaturesTest.java | 50 +++- 2 files changed, 155 insertions(+), 30 deletions(-) diff --git a/src/main/java/org/apache/commons/jexl3/JexlFeatures.java b/src/main/java/org/apache/commons/jexl3/JexlFeatures.java index c5a23926..4ed1f8d7 100644 --- a/src/main/java/org/apache/commons/jexl3/JexlFeatures.java +++ b/src/main/java/org/apache/commons/jexl3/JexlFeatures.java @@ -80,7 +80,7 @@ public final class JexlFeatures { public static final int LOCAL_VAR = 2; /** Side effects feature ordinal. */ public static final int SIDE_EFFECT = 3; -/** Global side-effects feature ordinal. */ +/** Global side effects feature ordinal. */ public static final int SIDE_EFFECT_GLOBAL = 4; /** Array get is allowed on expr. */ public static final int ARRAY_REF_EXPR = 5; @@ -104,7 +104,7 @@ public final class JexlFeatures { public static final int LEXICAL = 14; /** Lexical shade feature ordinal. */ public static final int LEXICAL_SHADE = 15; -/** Fat-arrow lambda syntax. */ +/** Thin-arrow lambda syntax. */ public static final int THIN_ARROW = 16; /** Fat-arrow lambda syntax. */ public static final int FAT_ARROW = 17; @@ -117,36 +117,99 @@ public final class JexlFeatures { /** The pragma anywhere feature ordinal. */ public static final int PRAGMA_ANYWHERE = 21; /** Captured variables are const. */ -public static final int CONST_CAPTURE = 22; +public static final int CONST_CAPTURE = 22; + /** * The default features flag mask. + * Meant for compatibility with scripts written before 3.3.1 */ private static final long DEFAULT_FEATURES = -1L << LOCAL_VAR -| 1L << SIDE_EFFECT -| 1L << SIDE_EFFECT_GLOBAL -| 1L << ARRAY_REF_EXPR -| 1L << NEW_INSTANCE -| 1L << LOOP -| 1L << LAMBDA -| 1L << METHOD_CALL -| 1L << STRUCTURED_LITERAL -| 1L << PRAGMA -| 1L << ANNOTATION -| 1L << SCRIPT -| 1L << THIN_ARROW -| 1L << NS_PRAGMA -| 1L << IMPORT_PRAGMA -| 1L << COMPARATOR_NAMES -| 1L << PRAGMA_ANYWHERE; - -/** - * Creates an all-features-enabled instance. +1L << LOCAL_VAR +| 1L << SIDE_EFFECT +| 1L << SIDE_EFFECT_GLOBAL +| 1L << ARRAY_REF_EXPR +| 1L << NEW_INSTANCE +| 1L << LOOP +| 1L << LAMBDA +| 1L << METHOD_CALL +| 1L << STRUCTURED_LITERAL +| 1L << PRAGMA +| 1L << ANNOTATION +| 1L << SCRIPT +| 1L << THIN_ARROW +| 1L << NS_PRAGMA +| 1L << IMPORT_PRAGMA +| 1L << COMPARATOR_NAMES +| 1L << PRAGMA_ANYWHERE; + +/** + * The canonical scripting (since 3.3.1) features flag mask based on the original default. + * Adds lexical, lexical-shade and const-capture but removes comparator-names and pragma-anywhere + */ +private static final long SCRIPT_FEATURES = +DEFAULT_FEATURES +| 1L << LEXICAL +| 1L << LEXICAL_SHADE +| 1L << CONST_CAPTURE +& ~(1L << COMPARATOR_NAMES) +& ~(1L << PRAGMA_ANYWHERE); + +/** + * Creates an empty feature set. + * This is the strictest base-set since no feature is allowed, suitable as-is only + * for the simplest expressions. + * @return a new instance of an empty features set + * @since 3.3.1 + */ +public static JexlFeatures create() { +return new JexlFeatures(0L, null, null); +} + +/** + * Creates a default features set suitable for basic scripting needs. + * Meant for legacy (before 3.3) scripting checks. + * The following scripting features are enabled: + * + * local variab
[commons-jexl] branch master updated: Remove an unnecessary equals override
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 b2023882 Remove an unnecessary equals override new ef037d74 Merge pull request #202 from csamak/master b2023882 is described below commit b20238823a6dc3a01612eeda34fae2a14968e664 Author: Cameron Samak AuthorDate: Wed Oct 11 21:19:45 2023 + Remove an unnecessary equals override to resolve false positive warning about not also overriding hashCode --- .../org/apache/commons/jexl3/internal/introspection/Permissions.java | 5 - 1 file changed, 5 deletions(-) diff --git a/src/main/java/org/apache/commons/jexl3/internal/introspection/Permissions.java b/src/main/java/org/apache/commons/jexl3/internal/introspection/Permissions.java index 1de7ca29..692a35e8 100644 --- a/src/main/java/org/apache/commons/jexl3/internal/introspection/Permissions.java +++ b/src/main/java/org/apache/commons/jexl3/internal/introspection/Permissions.java @@ -75,11 +75,6 @@ public class Permissions implements JexlPermissions { boolean isEmpty() { return nojexl.isEmpty(); } -@Override -public boolean equals(final Object o) { -return o == this; -} - NoJexlClass getNoJexl(final Class clazz) { return nojexl.get(classKey(clazz)); }
[commons-jexl] branch master updated: JEXL-406: exposed TemplateInterpreter.Arguments to allow TemplateInterpreter derivation (internal, not supported api); - added test in different package;
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 f97dd2f8 JEXL-406: exposed TemplateInterpreter.Arguments to allow TemplateInterpreter derivation (internal, not supported api); - added test in different package; f97dd2f8 is described below commit f97dd2f8f969bf8072ce099f34ad7381e10e9c55 Author: Henri Biestro AuthorDate: Fri Sep 22 09:35:03 2023 +0200 JEXL-406: exposed TemplateInterpreter.Arguments to allow TemplateInterpreter derivation (internal, not supported api); - added test in different package; --- .../jexl3/internal/TemplateInterpreter.java| 42 .../org/apache/commons/jexl3/Issues400Test.java| 2 +- src/test/java/org/example/SomeTest.java| 108 + 3 files changed, 127 insertions(+), 25 deletions(-) diff --git a/src/main/java/org/apache/commons/jexl3/internal/TemplateInterpreter.java b/src/main/java/org/apache/commons/jexl3/internal/TemplateInterpreter.java index 11bab2fc..0db40c28 100644 --- a/src/main/java/org/apache/commons/jexl3/internal/TemplateInterpreter.java +++ b/src/main/java/org/apache/commons/jexl3/internal/TemplateInterpreter.java @@ -48,7 +48,7 @@ public class TemplateInterpreter extends Interpreter { * Helper ctor. * Stores the different properties required to create a Template interpreter. */ -static class Arguments { +public static class Arguments { /** The engine. */ Engine jexl; /** The options. */ @@ -120,7 +120,7 @@ public class TemplateInterpreter extends Interpreter { * Creates a template interpreter instance. * @param args the template interpreter arguments */ -TemplateInterpreter(final Arguments args) { +protected TemplateInterpreter(final Arguments args) { super(args.jexl, args.options, args.jcontext, args.jframe); exprs = args.expressions; writer = args.out; @@ -243,17 +243,11 @@ public class TemplateInterpreter extends Interpreter { if ("include".equals(functionName)) { // evaluate the arguments Object[] argv = visit(argNode, null); -if (argv != null && argv.length > 0) { -if (argv[0] instanceof TemplateScript) { -final TemplateScript script = (TemplateScript) argv[0]; -if (argv.length > 1) { -argv = Arrays.copyOfRange(argv, 1, argv.length); -} else { -argv = null; -} -include(script, argv); -return null; -} +if (argv != null && argv.length > 0 && argv[0] instanceof TemplateScript) { +final TemplateScript script = (TemplateScript) argv[0]; +argv = argv.length > 1? Arrays.copyOfRange(argv, 1, argv.length) : null; +include(script, argv); +return null; } } // fail safe @@ -270,24 +264,24 @@ public class TemplateInterpreter extends Interpreter { @Override protected Interpreter createInterpreter(final JexlContext context, final Frame local, final JexlOptions options) { final TemplateInterpreter.Arguments targs = new TemplateInterpreter.Arguments(jexl) -.context(context) -.options(options) -.frame(local) -.expressions(exprs) -.writer(writer); +.context(context) +.options(options) +.frame(local) +.expressions(exprs) +.writer(writer); return jexl.createTemplateInterpreter(targs); } }; } // otherwise... final int numChildren = script.jjtGetNumChildren(); -Object result = null; -for (int i = 0; i < numChildren; i++) { +Object result = null; +for (int i = 0; i < numChildren; i++) { final JexlNode child = script.jjtGetChild(i); -result = child.jjtAccept(this, data); -cancelCheck(child); -} -return result; +result = child.jjtAccept(this, data); +cancelCheck(child); } +return result; +} } diff --git a/src/test/java/org/apache/commons/jexl3/Issues400Test.java b/src/test/java/org/ap
[commons-jexl] branch master updated: JEXL-406: added test/example of context methods
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 fcf59afc JEXL-406: added test/example of context methods fcf59afc is described below commit fcf59afce4900c895b953867cd4fe7204aca52eb Author: Henri Biestro AuthorDate: Fri Sep 22 08:27:51 2023 +0200 JEXL-406: added test/example of context methods --- src/test/java/org/apache/commons/jexl3/Issues400Test.java | 8 +--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/test/java/org/apache/commons/jexl3/Issues400Test.java b/src/test/java/org/apache/commons/jexl3/Issues400Test.java index 9c366351..8f726bc1 100644 --- a/src/test/java/org/apache/commons/jexl3/Issues400Test.java +++ b/src/test/java/org/apache/commons/jexl3/Issues400Test.java @@ -156,6 +156,7 @@ public class Issues400Test { * Overloads are respected. */ public static class XuContext extends MapContext { + public String join(Iterator iterator, String str) { if (!iterator.hasNext()) { return ""; @@ -168,6 +169,7 @@ public class Issues400Test { } return strb.toString(); } + public String join(Iterable list, String str) { return join(list.iterator(), str); } @@ -195,7 +197,7 @@ public class Issues400Test { "join((1 .. 4), '-')")) { JexlScript script = jexl.createScript(src); Object result = script.execute(context); - Assert.assertEquals("1-2-3-4", result); + Assert.assertEquals(src,"1-2-3-4", result); } String src0 = "x.join('*')"; @@ -206,9 +208,9 @@ public class Issues400Test { Arrays.asList(1, 2, 3, 4), new int[]{1, 2, 3, 4})) { Object result = script0.execute(context, x); - Assert.assertEquals("1*2*3*4", result); + Assert.assertEquals(src0, "1*2*3*4", result); result = script1.execute(context, x); - Assert.assertEquals("1*2*3*4", result); + Assert.assertEquals(src1, "1*2*3*4", result); } } }
[commons-jexl] branch master updated: JEXL-406: added test/example of context methods
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 b5c0a18b JEXL-406: added test/example of context methods b5c0a18b is described below commit b5c0a18beee9b6e851bfe6a5fe191d7b75211c3f Author: Henri Biestro AuthorDate: Fri Sep 22 08:24:51 2023 +0200 JEXL-406: added test/example of context methods --- src/test/java/org/apache/commons/jexl3/Issues400Test.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/test/java/org/apache/commons/jexl3/Issues400Test.java b/src/test/java/org/apache/commons/jexl3/Issues400Test.java index 712e81f6..9c366351 100644 --- a/src/test/java/org/apache/commons/jexl3/Issues400Test.java +++ b/src/test/java/org/apache/commons/jexl3/Issues400Test.java @@ -22,7 +22,6 @@ import org.junit.Test; import java.util.Arrays; import java.util.Collections; import java.util.Iterator; -import java.util.List; import java.util.Map; import java.util.Objects;
[commons-jexl] branch master updated: JEXL-406: added test/example of context methods
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 cbc89ed5 JEXL-406: added test/example of context methods cbc89ed5 is described below commit cbc89ed533913590a4f109ca0627ffd484a6a3c8 Author: Henri Biestro AuthorDate: Thu Sep 21 19:56:58 2023 +0200 JEXL-406: added test/example of context methods --- .../org/apache/commons/jexl3/Issues400Test.java| 64 ++ 1 file changed, 64 insertions(+) diff --git a/src/test/java/org/apache/commons/jexl3/Issues400Test.java b/src/test/java/org/apache/commons/jexl3/Issues400Test.java index 863d3b0e..712e81f6 100644 --- a/src/test/java/org/apache/commons/jexl3/Issues400Test.java +++ b/src/test/java/org/apache/commons/jexl3/Issues400Test.java @@ -19,8 +19,12 @@ package org.apache.commons.jexl3; import org.junit.Assert; import org.junit.Test; +import java.util.Arrays; import java.util.Collections; +import java.util.Iterator; +import java.util.List; import java.util.Map; +import java.util.Objects; /** * Test cases for reported issue between JEXL-300 and JEXL-399. @@ -148,4 +152,64 @@ public class Issues400Test { Assert.assertArrayEquals(new String[]{"C"}, (String[]) result); } + /** + * Any function in a context can be used as a method of its first parameter. + * Overloads are respected. + */ + public static class XuContext extends MapContext { +public String join(Iterator iterator, String str) { + if (!iterator.hasNext()) { +return ""; + } + StringBuilder strb = new StringBuilder(256); + strb.append(iterator.next().toString()); + while(iterator.hasNext()) { +strb.append(str); +strb.append(Objects.toString(iterator.next(), "?")); + } + return strb.toString(); +} +public String join(Iterable list, String str) { + return join(list.iterator(), str); +} + +public String join(int[] list, String str) { + return join(Arrays.stream(list).iterator(), str); +} + } + + @Test + public void test406() { +final JexlEngine jexl = new JexlBuilder() +.cache(64) +.strict(true) +.safe(false) +.create(); + +JexlContext context = new XuContext(); +for(String src : Arrays.asList( +"[1, 2, 3, 4, ...].join('-')", // List +"[1, 2, 3, 4,].join('-')", // int[] +"(1 .. 4).join('-')", // iterable +"join([1, 2, 3, 4, ...], '-')", +"join([1, 2, 3, 4], '-')", +"join((1 .. 4), '-')")) { + JexlScript script = jexl.createScript(src); + Object result = script.execute(context); + Assert.assertEquals("1-2-3-4", result); +} + +String src0 = "x.join('*')"; +JexlScript script0 = jexl.createScript(src0, "x"); +String src1 = "join(x, '*')"; +JexlScript script1 = jexl.createScript(src1, "x"); +for(Object x : Arrays.asList( +Arrays.asList(1, 2, 3, 4), +new int[]{1, 2, 3, 4})) { + Object result = script0.execute(context, x); + Assert.assertEquals("1*2*3*4", result); + result = script1.execute(context, x); + Assert.assertEquals("1*2*3*4", result); +} + } }
[commons-jexl] branch master updated: JEXL-405: changes, release notes;
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 8ee8f3c7 JEXL-405: changes, release notes; 8ee8f3c7 is described below commit 8ee8f3c784995b12d4b6d96a3fd46345c18e4b66 Author: Henri Biestro AuthorDate: Fri Sep 1 17:15:14 2023 +0200 JEXL-405: changes, release notes; --- RELEASE-NOTES.txt | 1 + src/changes/changes.xml | 3 +++ 2 files changed, 4 insertions(+) diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt index 197e2010..7369078f 100644 --- a/RELEASE-NOTES.txt +++ b/RELEASE-NOTES.txt @@ -36,6 +36,7 @@ New Features in 3.3.1: Bugs Fixed in 3.3.1: === +* JEXL-405: Recursive functions corrupt evaluation frame if reassigned * JEXL-403: Exception while evaluating template literal used in array assignment in loop. * JEXL-402: parse failed with empty return value. diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 0fa70d8c..97b03d9f 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -39,6 +39,9 @@ Allow 'trailing commas' or ellipsis while defining array, map and set literals + +Recursive functions corrupt evaluation frame if reassigned + Exception while evaluating template literal used in array assignment in loop.
[commons-jexl] 01/01: Merge pull request #191 from apache/dependabot/github_actions/github/codeql-action-2.21.5
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 commit 7953c01c1cc0a09dc9730ba6f612225225731231 Merge: 53eb3dbd cbcb16db Author: Henrib AuthorDate: Fri Sep 1 15:36:34 2023 +0200 Merge pull request #191 from apache/dependabot/github_actions/github/codeql-action-2.21.5 Bump github/codeql-action from 2.21.4 to 2.21.5 .github/workflows/codeql-analysis.yml | 6 +++--- .github/workflows/scorecards-analysis.yml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-)
[commons-jexl] branch master updated (53eb3dbd -> 7953c01c)
This is an automated email from the ASF dual-hosted git repository. henrib pushed a change to branch master in repository https://gitbox.apache.org/repos/asf/commons-jexl.git from 53eb3dbd JEXL-405: simplified and narrowed logic around recursive lambdas; - moved tests to LambdaTest; - various nitpicks; add cbcb16db Bump github/codeql-action from 2.21.4 to 2.21.5 new 7953c01c Merge pull request #191 from apache/dependabot/github_actions/github/codeql-action-2.21.5 The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference. Summary of changes: .github/workflows/codeql-analysis.yml | 6 +++--- .github/workflows/scorecards-analysis.yml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-)
[commons-jexl] branch master updated: JEXL-405: simplified and narrowed logic around recursive lambdas; - moved tests to LambdaTest; - various nitpicks;
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 53eb3dbd JEXL-405: simplified and narrowed logic around recursive lambdas; - moved tests to LambdaTest; - various nitpicks; 53eb3dbd is described below commit 53eb3dbd42d27ba5411197f024ce9ddf2c1bcca6 Author: Henri Biestro AuthorDate: Thu Aug 31 17:31:53 2023 +0200 JEXL-405: simplified and narrowed logic around recursive lambdas; - moved tests to LambdaTest; - various nitpicks; --- .../org/apache/commons/jexl3/internal/Closure.java | 31 +++ .../apache/commons/jexl3/internal/Interpreter.java | 6 +-- .../org/apache/commons/jexl3/Issues400Test.java| 44 ++ .../java/org/apache/commons/jexl3/LambdaTest.java | 31 ++- .../apache/commons/jexl3/PropertyAccessTest.java | 10 + 5 files changed, 67 insertions(+), 55 deletions(-) diff --git a/src/main/java/org/apache/commons/jexl3/internal/Closure.java b/src/main/java/org/apache/commons/jexl3/internal/Closure.java index 733ef85a..ef70ad7f 100644 --- a/src/main/java/org/apache/commons/jexl3/internal/Closure.java +++ b/src/main/java/org/apache/commons/jexl3/internal/Closure.java @@ -102,22 +102,23 @@ public class Closure extends Script { } /** - * Sets the captured index of a given symbol, ie the target index of a parent - * captured symbol in this closure's frame. - * This is meant to allow a locally defined function to "see" and call - * itself as a local (captured) variable; - * in other words, this allows recursive call of a function. + * Enable lambda recursion. + * Assign this lambda in its own frame if the symbol it is assigned to in its definition scope + * is captured in its body. + * This done allow a locally defined function to "see" and call itself as a local (captured) variable. + * Typical case is: const f = (x)->x <= 0? 1 : x*f(x-1). Since assignment of f occurs after + * the lambda creation, we need to patch the lambda frame to expose itself through the captured symbol. + * @param parentFrame the parent calling frame * @param symbol the symbol index (in the caller of this closure) - * @param value the value to set in the local frame */ -public void setCaptured(final int symbol, final Object value) { +void captureSelfIfRecursive(final Frame parentFrame, final int symbol) { if (script instanceof ASTJexlLambda) { -final ASTJexlLambda lambda = (ASTJexlLambda) script; -final Scope scope = lambda.getScope(); -if (scope != null) { -final Integer reg = scope.getCaptured(symbol); +Scope parentScope = parentFrame != null ? parentFrame.getScope() : null; +Scope localScope = frame != null ? frame.getScope() : null; +if (parentScope != null && localScope != null && parentScope == localScope.getParent()) { +final Integer reg = localScope.getCaptured(symbol); if (reg != null) { -frame.set(reg, value); +frame.set(reg, this); } } } @@ -151,10 +152,4 @@ public class Closure extends Script { }; } -boolean hasParent(Scope scope) { -Scope s = frame != null? frame.getScope() : null; -return scope != null && s != null -? scope == s.getParent() -: false; -} } 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 80397f5e..dffae1ea 100644 --- a/src/main/java/org/apache/commons/jexl3/internal/Interpreter.java +++ b/src/main/java/org/apache/commons/jexl3/internal/Interpreter.java @@ -1070,7 +1070,7 @@ public class Interpreter extends InterpreterBase { final int symbol = variable.getSymbol(); frame.set(symbol, closure); // make the closure accessible to itself, ie capture the 'function' variable after frame creation -closure.setCaptured(symbol, closure); +closure.captureSelfIfRecursive(frame, symbol); } return closure; } @@ -1430,9 +1430,7 @@ public class Interpreter extends InterpreterBase { if (right instanceof Closure) { Closure closure = (Closure) right; // the variable scope must be the parent of the lambdas -if (closure.hasParent(frame.getScope())) { -closure.setCaptured(symbol, right); -} +
[commons-jexl] branch master updated: JEXL-405: avoid corrupting frame by ensuring auto-capture of recursive function variable is only called at definition time;
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 37fda79e JEXL-405: avoid corrupting frame by ensuring auto-capture of recursive function variable is only called at definition time; new d59714b4 Merge remote-tracking branch 'origin/master' 37fda79e is described below commit 37fda79ec11d236e745a5dbfadeacf7c61c6819f Author: henrib AuthorDate: Wed Aug 30 20:44:45 2023 +0200 JEXL-405: avoid corrupting frame by ensuring auto-capture of recursive function variable is only called at definition time; --- .../org/apache/commons/jexl3/internal/Closure.java | 7 + .../apache/commons/jexl3/internal/Interpreter.java | 8 -- .../org/apache/commons/jexl3/internal/Scope.java | 4 +++ .../org/apache/commons/jexl3/Issues400Test.java| 32 ++ 4 files changed, 49 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/apache/commons/jexl3/internal/Closure.java b/src/main/java/org/apache/commons/jexl3/internal/Closure.java index aeaaac34..733ef85a 100644 --- a/src/main/java/org/apache/commons/jexl3/internal/Closure.java +++ b/src/main/java/org/apache/commons/jexl3/internal/Closure.java @@ -150,4 +150,11 @@ public class Closure extends Script { } }; } + +boolean hasParent(Scope scope) { +Scope s = frame != null? frame.getScope() : null; +return scope != null && s != null +? scope == s.getParent() +: false; +} } 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 5b6ffdf1..80397f5e 100644 --- a/src/main/java/org/apache/commons/jexl3/internal/Interpreter.java +++ b/src/main/java/org/apache/commons/jexl3/internal/Interpreter.java @@ -1069,7 +1069,7 @@ public class Interpreter extends InterpreterBase { this.visit(variable, data); final int symbol = variable.getSymbol(); frame.set(symbol, closure); -// make the closure accessible to itself, ie capture the currently set variable after frame creation +// make the closure accessible to itself, ie capture the 'function' variable after frame creation closure.setCaptured(symbol, closure); } return closure; @@ -1428,7 +1428,11 @@ public class Interpreter extends InterpreterBase { if (assignop == null) { // make the closure accessible to itself, ie capture the currently set variable after frame creation if (right instanceof Closure) { -((Closure) right).setCaptured(symbol, right); +Closure closure = (Closure) right; +// the variable scope must be the parent of the lambdas +if (closure.hasParent(frame.getScope())) { +closure.setCaptured(symbol, right); +} } frame.set(symbol, right); } else { diff --git a/src/main/java/org/apache/commons/jexl3/internal/Scope.java b/src/main/java/org/apache/commons/jexl3/internal/Scope.java index 3f71c888..3d7028a0 100644 --- a/src/main/java/org/apache/commons/jexl3/internal/Scope.java +++ b/src/main/java/org/apache/commons/jexl3/internal/Scope.java @@ -349,4 +349,8 @@ public final class Scope { return locals.toArray(new String[0]); } + +Scope getParent() { +return parent; +} } diff --git a/src/test/java/org/apache/commons/jexl3/Issues400Test.java b/src/test/java/org/apache/commons/jexl3/Issues400Test.java index f760dae7..b988ff02 100644 --- a/src/test/java/org/apache/commons/jexl3/Issues400Test.java +++ b/src/test/java/org/apache/commons/jexl3/Issues400Test.java @@ -155,4 +155,36 @@ public class Issues400Test { result = script.execute(null, a); Assert.assertEquals(1042, result); } + + @Test + public void test405a() { +final JexlEngine jexl = new JexlBuilder() +.cache(64) +.strict(true) +.safe(false) +.create(); +String libSrc = "var tfn = pfn -> { var fn = pfn; fn() }; { 'theFunction' : tfn }"; +String src1 = "var v0 = 42; var v1 = -42; lib.theFunction(()->{ v1 + v0 }) "; +JexlScript libMap = jexl.createScript(libSrc); +Object theLib = libMap.execute(null); +JexlScript f1 = jexl.createScript(src1, "lib"); +Object result = f1.execute(null, theLib); +Assert.assertEquals(0, result); + } + + @Test + public void test405b() { +final JexlEngine jexl = new JexlBuilder() +.cache(64) +
[commons-jexl] branch master updated: JEXL-404 : add syntax for safe array access ( ?[..] ); - update interpreter and debugger; - add test; - update syntax reference, release notes, changes;
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 589b0888 JEXL-404 : add syntax for safe array access ( ?[..] ); - update interpreter and debugger; - add test; - update syntax reference, release notes, changes; 589b0888 is described below commit 589b0888142541085714bbd7b0fc7e3615ae2727 Author: Henri Biestro AuthorDate: Wed Aug 30 16:29:07 2023 +0200 JEXL-404 : add syntax for safe array access ( ?[..] ); - update interpreter and debugger; - add test; - update syntax reference, release notes, changes; --- RELEASE-NOTES.txt | 1 + src/changes/changes.xml| 3 + .../apache/commons/jexl3/internal/Debugger.java| 3 + .../apache/commons/jexl3/internal/Interpreter.java | 5 +- .../commons/jexl3/parser/ASTArrayAccess.java | 51 .../org/apache/commons/jexl3/parser/Parser.jjt | 12 ++-- src/site/xdoc/reference/syntax.xml | 6 ++ .../org/apache/commons/jexl3/Issues400Test.java| 67 ++ 8 files changed, 143 insertions(+), 5 deletions(-) diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt index d1d73bb2..197e2010 100644 --- a/RELEASE-NOTES.txt +++ b/RELEASE-NOTES.txt @@ -30,6 +30,7 @@ Version 3.3.1 is source and binary compatible with 3.3. New Features in 3.3.1: +* JEXL-404: Support array-access safe navigation (x?[y]) * JEXL-401: Captured variables should be read-only * JEXL-398: Allow 'trailing commas' or ellipsis while defining array, map and set literals diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 9caafabd..e292245a 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -29,6 +29,9 @@ + +Support array-access safe navigation (x?[y]) + Captured variables should be read-only diff --git a/src/main/java/org/apache/commons/jexl3/internal/Debugger.java b/src/main/java/org/apache/commons/jexl3/internal/Debugger.java index ad65b2ba..75b23c89 100644 --- a/src/main/java/org/apache/commons/jexl3/internal/Debugger.java +++ b/src/main/java/org/apache/commons/jexl3/internal/Debugger.java @@ -483,6 +483,9 @@ public class Debugger extends ParserVisitor implements JexlInfo.Detail { protected Object visit(final ASTArrayAccess node, final Object data) { final int num = node.jjtGetNumChildren(); for (int i = 0; i < num; ++i) { +if (node.isSafeChild(i)) { +builder.append('?'); +} builder.append('['); accept(node.jjtGetChild(i), data); builder.append(']'); 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 05721831..5b6ffdf1 100644 --- a/src/main/java/org/apache/commons/jexl3/internal/Interpreter.java +++ b/src/main/java/org/apache/commons/jexl3/internal/Interpreter.java @@ -,7 +,10 @@ public class Interpreter extends InterpreterBase { for (int i = 0; i < numChildren; i++) { final JexlNode nindex = node.jjtGetChild(i); if (object == null) { -return unsolvableProperty(nindex, stringifyProperty(nindex), false, null); +// safe navigation access +return node.isSafeChild(i) +? null +:unsolvableProperty(nindex, stringifyProperty(nindex), false, null); } final Object index = nindex.jjtAccept(this, null); cancelCheck(node); diff --git a/src/main/java/org/apache/commons/jexl3/parser/ASTArrayAccess.java b/src/main/java/org/apache/commons/jexl3/parser/ASTArrayAccess.java new file mode 100644 index ..8cac2993 --- /dev/null +++ b/src/main/java/org/apache/commons/jexl3/parser/ASTArrayAccess.java @@ -0,0 +1,51 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * lim
[commons-jexl] branch master updated: JEXL-403 : cache template expression in literal in a dedicated class member; - clean up interpreter; - update test, release notes, changes;
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 c64ee0df JEXL-403 : cache template expression in literal in a dedicated class member; - clean up interpreter; - update test, release notes, changes; c64ee0df is described below commit c64ee0df87677b82d062fc4096ed1cb6c5e858a0 Author: Henri Biestro AuthorDate: Tue Aug 29 21:13:02 2023 +0200 JEXL-403 : cache template expression in literal in a dedicated class member; - clean up interpreter; - update test, release notes, changes; --- RELEASE-NOTES.txt | 1 + src/changes/changes.xml| 5 ++- .../apache/commons/jexl3/internal/Interpreter.java | 45 -- .../jexl3/parser/ASTIdentifierAccessJxlt.java | 6 +-- .../commons/jexl3/parser/ASTJxltLiteral.java | 18 +++-- .../org/apache/commons/jexl3/Issues400Test.java| 38 ++ 6 files changed, 68 insertions(+), 45 deletions(-) diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt index 4d11ff59..d1d73bb2 100644 --- a/RELEASE-NOTES.txt +++ b/RELEASE-NOTES.txt @@ -35,6 +35,7 @@ New Features in 3.3.1: Bugs Fixed in 3.3.1: === +* JEXL-403: Exception while evaluating template literal used in array assignment in loop. * JEXL-402: parse failed with empty return value. diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 8235f55b..9caafabd 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -36,7 +36,10 @@ Allow 'trailing commas' or ellipsis while defining array, map and set literals - + +Exception while evaluating template literal used in array assignment in loop. + + Parse failed with empty return value. 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 5d3c0ce0..05721831 100644 --- a/src/main/java/org/apache/commons/jexl3/internal/Interpreter.java +++ b/src/main/java/org/apache/commons/jexl3/internal/Interpreter.java @@ -625,7 +625,7 @@ public class Interpreter extends InterpreterBase { final ASTReference loopReference = (ASTReference) node.jjtGetChild(0); final ASTIdentifier loopVariable = (ASTIdentifier) loopReference.jjtGetChild(0); final int symbol = loopVariable.getSymbol(); -final boolean lexical = loopVariable.isLexical() || options.isLexical() ;// && node.getSymbolCount() > 0; +final boolean lexical = loopVariable.isLexical() || options.isLexical(); final LexicalFrame locals = lexical? new LexicalFrame(frame, block) : null; final boolean loopSymbol = symbol >= 0 && loopVariable instanceof ASTVar; if (lexical) { @@ -1065,9 +1065,9 @@ public class Interpreter extends InterpreterBase { // if the function is named, assign in the local frame final JexlNode child0 = script.jjtGetChild(0); if (child0 instanceof ASTVar) { -final ASTVar var = (ASTVar) child0; -this.visit(var, data); -final int symbol = var.getSymbol(); +final ASTVar variable = (ASTVar) child0; +this.visit(variable, data); +final int symbol = variable.getSymbol(); frame.set(symbol, closure); // make the closure accessible to itself, ie capture the currently set variable after frame creation closure.setCaptured(symbol, closure); @@ -1390,24 +1390,24 @@ public class Interpreter extends InterpreterBase { cancelCheck(node); // left contains the reference to assign to final JexlNode left = node.jjtGetChild(0); -final ASTIdentifier var; +final ASTIdentifier variable; Object object = null; final int symbol; // check var decl with assign is ok if (left instanceof ASTIdentifier) { -var = (ASTIdentifier) left; -symbol = var.getSymbol(); -if (symbol >= 0 && (var.isLexical() || options.isLexical())) { -if (var instanceof ASTVar) { -if (!defineVariable((ASTVar) var, block)) { -return redefinedVariable(var, var.getName()); +variable = (ASTIdentifier) left; +symbol = variable.getSymbol(); +if (symbol >= 0 && (variable.isLexical() || options.isLexical())) { +
[commons-jexl] branch master updated: JEXL-403:unit test;
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 cd3db936 JEXL-403:unit test; cd3db936 is described below commit cd3db936723ca8e5c7bf68a62f23f15642ce992a Author: Henri Biestro AuthorDate: Tue Aug 29 15:51:14 2023 +0200 JEXL-403:unit test; --- .../org/apache/commons/jexl3/Issues400Test.java | 21 + 1 file changed, 21 insertions(+) diff --git a/src/test/java/org/apache/commons/jexl3/Issues400Test.java b/src/test/java/org/apache/commons/jexl3/Issues400Test.java index 81d2a56c..4ddc2eac 100644 --- a/src/test/java/org/apache/commons/jexl3/Issues400Test.java +++ b/src/test/java/org/apache/commons/jexl3/Issues400Test.java @@ -61,4 +61,25 @@ public class Issues400Test { Assert.assertNull(o); } } + + @Test + public void test403() { +String src = "var a = {'a': 1};\n" + +"var list = [a, a];\n" + +"let map1 = {:};\n" + +"for (var item : list) {\n" + +" map1[`${item.a}`] = 1;\n" + +"}\n " + +"map1"; +final JexlEngine jexl = new JexlBuilder().create(); +JexlScript script = jexl.createScript(src); +for(int i = 0; i < 2; ++ i) { + Object result = script.execute(null); + Assert.assertTrue(result instanceof Map); + Map map = (Map) result; + Assert.assertEquals(1, map.size()); + Assert.assertTrue(map.containsKey(1)); + Assert.assertTrue(map.containsValue(1)); +} + } }
[commons-jexl] branch master updated: JEXL-402: update release notes, changes;
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 59d9b55d JEXL-402: update release notes, changes; 59d9b55d is described below commit 59d9b55de0d1d5de29b8b1bc7d434f93499d9415 Author: Henri Biestro AuthorDate: Tue Aug 22 17:37:04 2023 +0200 JEXL-402: update release notes, changes; --- RELEASE-NOTES.txt | 1 + src/changes/changes.xml | 3 +++ 2 files changed, 4 insertions(+) diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt index 454820c7..4d11ff59 100644 --- a/RELEASE-NOTES.txt +++ b/RELEASE-NOTES.txt @@ -35,6 +35,7 @@ New Features in 3.3.1: Bugs Fixed in 3.3.1: === +* JEXL-402: parse failed with empty return value. Release 3.3 diff --git a/src/changes/changes.xml b/src/changes/changes.xml index afcece4b..8235f55b 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -36,6 +36,9 @@ Allow 'trailing commas' or ellipsis while defining array, map and set literals + +Parse failed with empty return value. + [StepSecurity] ci: Harden GitHub Actions #180.
[commons-jexl] branch master updated: JEXL-402: update grammar (return with no arg nor semicol) - added test, updated inteerpreter
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 12c0a938 JEXL-402: update grammar (return with no arg nor semicol) - added test, updated inteerpreter 12c0a938 is described below commit 12c0a9389f413ebdc9024ac7290aff7685df4034 Author: Henri Biestro AuthorDate: Tue Aug 22 17:31:18 2023 +0200 JEXL-402: update grammar (return with no arg nor semicol) - added test, updated inteerpreter --- .../apache/commons/jexl3/internal/Interpreter.java | 4 +- .../org/apache/commons/jexl3/parser/Parser.jjt | 2 +- .../org/apache/commons/jexl3/Issues400Test.java| 64 ++ 3 files changed, 68 insertions(+), 2 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 0ce648f7..5d3c0ce0 100644 --- a/src/main/java/org/apache/commons/jexl3/internal/Interpreter.java +++ b/src/main/java/org/apache/commons/jexl3/internal/Interpreter.java @@ -597,7 +597,9 @@ public class Interpreter extends InterpreterBase { @Override protected Object visit(final ASTReturnStatement node, final Object data) { -final Object val = node.jjtGetChild(0).jjtAccept(this, data); +final Object val = node.jjtGetNumChildren() == 1 +? node.jjtGetChild(0).jjtAccept(this, data) +: null; cancelCheck(node); throw new JexlException.Return(node, null, val); } diff --git a/src/main/java/org/apache/commons/jexl3/parser/Parser.jjt b/src/main/java/org/apache/commons/jexl3/parser/Parser.jjt index cfa7a97e..1e286d9f 100644 --- a/src/main/java/org/apache/commons/jexl3/parser/Parser.jjt +++ b/src/main/java/org/apache/commons/jexl3/parser/Parser.jjt @@ -418,7 +418,7 @@ void DoWhileStatement() : {} void ReturnStatement() : {} { - ExpressionStatement() + ( ExpressionStatement() )? } void Continue() #Continue : { diff --git a/src/test/java/org/apache/commons/jexl3/Issues400Test.java b/src/test/java/org/apache/commons/jexl3/Issues400Test.java new file mode 100644 index ..81d2a56c --- /dev/null +++ b/src/test/java/org/apache/commons/jexl3/Issues400Test.java @@ -0,0 +1,64 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.commons.jexl3; + +import org.apache.commons.jexl3.internal.Engine32; +import org.apache.commons.jexl3.internal.OptionsContext; +import static org.apache.commons.jexl3.introspection.JexlPermissions.RESTRICTED; +import org.apache.commons.jexl3.introspection.JexlSandbox; +import org.junit.Assert; +import org.junit.Test; + +import java.io.StringReader; +import java.io.StringWriter; +import java.lang.reflect.Proxy; +import java.math.MathContext; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import static org.apache.commons.jexl3.internal.Util.debuggerCheck; +import static org.junit.Assert.assertEquals; + +/** + * Test cases for reported issue between JEXL-300 and JEXL-399. + */ +public class Issues400Test { + + @Test + public void test402() { +final JexlContext jc = new MapContext(); +final String[] sources = new String[]{ +"if (true) { return }", +"if (true) { 3; return }", +"(x->{ 3; return })()" +}; +final JexlEngine jexl = new JexlBuilder().create(); +for (final String source : sources) { + final JexlScript e = jexl.createScript(source); + final Object o = e.execute(jc); + Assert.assertNull(o); +} + } +}
[commons-jexl] branch master updated: JEXL-401: added constCapture feature flag to control captured variables constness (sic); - added test; - refined debugger output when depth <= 1 to allow for bett
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 3276e2af JEXL-401: added constCapture feature flag to control captured variables constness (sic); - added test; - refined debugger output when depth <= 1 to allow for better feature error reporting; - updated tests accordingly; - changes, release-notes 3276e2af is described below commit 3276e2afe7496b4217b5ad62bf60bfe901749ebf Author: Henri Biestro AuthorDate: Mon Jul 10 17:10:04 2023 +0200 JEXL-401: added constCapture feature flag to control captured variables constness (sic); - added test; - refined debugger output when depth <= 1 to allow for better feature error reporting; - updated tests accordingly; - changes, release-notes --- RELEASE-NOTES.txt | 1 + src/changes/changes.xml| 5 ++- .../org/apache/commons/jexl3/JexlFeatures.java | 26 +++- .../apache/commons/jexl3/internal/Debugger.java| 48 +++--- .../commons/jexl3/parser/FeatureController.java| 8 +++- .../org/apache/commons/jexl3/parser/Parser.jjt | 2 +- .../org/apache/commons/jexl3/FeaturesTest.java | 12 ++ .../jexl3/parser/FeatureControllerTest.java| 32 --- 8 files changed, 101 insertions(+), 33 deletions(-) diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt index a75a5b81..454820c7 100644 --- a/RELEASE-NOTES.txt +++ b/RELEASE-NOTES.txt @@ -30,6 +30,7 @@ Version 3.3.1 is source and binary compatible with 3.3. New Features in 3.3.1: +* JEXL-401: Captured variables should be read-only * JEXL-398: Allow 'trailing commas' or ellipsis while defining array, map and set literals Bugs Fixed in 3.3.1: diff --git a/src/changes/changes.xml b/src/changes/changes.xml index c891b8ff..b6f897f3 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -29,7 +29,10 @@ - + +Captured variables should be read-only + + Allow 'trailing commas' or ellipsis while defining array, map and set literals diff --git a/src/main/java/org/apache/commons/jexl3/JexlFeatures.java b/src/main/java/org/apache/commons/jexl3/JexlFeatures.java index b8d798c4..b7bd6a4b 100644 --- a/src/main/java/org/apache/commons/jexl3/JexlFeatures.java +++ b/src/main/java/org/apache/commons/jexl3/JexlFeatures.java @@ -51,6 +51,7 @@ import java.util.function.Predicate; * lt for , ...) * Pragma anywhere: whether pragma, that are not statements and handled before execution begins, * can appear anywhere in the source or before any statements - ie at the beginning of a script. + * Const Capture: whether variables captured by lambdas are read-only (aka const, same as Java) or read-write. * * @since 3.2 */ @@ -68,7 +69,8 @@ public final class JexlFeatures { "register", "reserved variable", "local variable", "assign/modify", "global assign/modify", "array reference", "create instance", "loop", "function", "method call", "set/map/array literal", "pragma", "annotation", "script", "lexical", "lexicalShade", -"thin-arrow", "fat-arrow", "namespace pragma", "import pragma", "comparator names", "pragma anywhere" +"thin-arrow", "fat-arrow", "namespace pragma", "import pragma", "comparator names", "pragma anywhere", +"const capture" }; /** Registers feature ordinal. */ private static final int REGISTER = 0; @@ -114,6 +116,8 @@ public final class JexlFeatures { public static final int COMPARATOR_NAMES = 20; /** The pragma anywhere feature ordinal. */ public static final int PRAGMA_ANYWHERE = 21; +/** Captured variables are const. */ +public static final int CONST_CAPTURE = 22; /** * The default features flag mask. */ @@ -464,6 +468,26 @@ public final class JexlFeatures { return getFeature(LAMBDA); } +/** + * Sets whether lambda captured-variables are const or not. + * + * When disabled, lambda-captured variables are implicitly converted to read-write local variable (let), + * when enabled, those are implicitly converted to read-only local variables (const). + * @param flag true to enable, false to disable + * @return this features instance + */ +public JexlFeatures constCapture(final boolean flag) { +setFeature(CONST_CAPTURE,
[commons-jexl] branch master updated: JEXL: Bump github/codeql-action from 2.20.1 to 2.20.3 changes
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 299ab452 JEXL: Bump github/codeql-action from 2.20.1 to 2.20.3 changes 299ab452 is described below commit 299ab45211ea402ec9e6723ea1b84f3b68526b8a Author: Henri Biestro AuthorDate: Fri Jul 7 15:32:53 2023 +0200 JEXL: Bump github/codeql-action from 2.20.1 to 2.20.3 changes --- src/changes/changes.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 187a6ed3..c891b8ff 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -37,6 +37,9 @@ [StepSecurity] ci: Harden GitHub Actions #180. + +Bump github/codeql-action from 2.20.1 to 2.20.3 + Bumps ossf/scorecard-action from 2.1.3 to 2.2.0.
[commons-jexl] branch master updated (ab1a6d9c -> cbc1c42b)
This is an automated email from the ASF dual-hosted git repository. henrib pushed a change to branch master in repository https://gitbox.apache.org/repos/asf/commons-jexl.git from ab1a6d9c JEXL-398: implemented trailing comma and ellipsis for array/set/map literals; - Tests, changes and release notes; - A few incidental tweaks here and there (Closure, error reporting); add b490d388 Bump github/codeql-action from 2.20.1 to 2.20.3 new cbc1c42b Merge pull request #183 from apache/dependabot/github_actions/github/codeql-action-2.20.3 The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference. Summary of changes: .github/workflows/codeql-analysis.yml | 6 +++--- .github/workflows/scorecards-analysis.yml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-)
[commons-jexl] 01/01: Merge pull request #183 from apache/dependabot/github_actions/github/codeql-action-2.20.3
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 commit cbc1c42bd53bdf3bcdb09069e29d7f451475f49a Merge: ab1a6d9c b490d388 Author: Henrib AuthorDate: Fri Jul 7 15:26:50 2023 +0200 Merge pull request #183 from apache/dependabot/github_actions/github/codeql-action-2.20.3 Bump github/codeql-action from 2.20.1 to 2.20.3 .github/workflows/codeql-analysis.yml | 6 +++--- .github/workflows/scorecards-analysis.yml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-)
[commons-jexl] branch master updated: JEXL-398: implemented trailing comma and ellipsis for array/set/map literals; - Tests, changes and release notes; - A few incidental tweaks here and there (Closur
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 ab1a6d9c JEXL-398: implemented trailing comma and ellipsis for array/set/map literals; - Tests, changes and release notes; - A few incidental tweaks here and there (Closure, error reporting); ab1a6d9c is described below commit ab1a6d9c3c32fd9c5e49def7fe8f1763dce09d7d Author: Henri Biestro AuthorDate: Thu Jul 6 19:13:56 2023 +0200 JEXL-398: implemented trailing comma and ellipsis for array/set/map literals; - Tests, changes and release notes; - A few incidental tweaks here and there (Closure, error reporting); --- BUILDING.txt | 5 +- RELEASE-NOTES.txt | 17 ++ src/changes/changes.xml| 10 +++- .../org/apache/commons/jexl3/JexlArithmetic.java | 32 +-- .../commons/jexl3/internal/ArrayBuilder.java | 19 +-- .../org/apache/commons/jexl3/internal/Closure.java | 4 +- .../apache/commons/jexl3/internal/Interpreter.java | 60 .../commons/jexl3/internal/InterpreterBase.java| 4 +- .../apache/commons/jexl3/internal/MapBuilder.java | 12 +++- .../apache/commons/jexl3/internal/SetBuilder.java | 12 +++- .../commons/jexl3/parser/ASTArrayLiteral.java | 30 +- .../apache/commons/jexl3/parser/ASTMapLiteral.java | 32 +-- .../apache/commons/jexl3/parser/ASTSetLiteral.java | 29 +- .../commons/jexl3/parser/ExtensibleNode.java | 64 ++ .../org/apache/commons/jexl3/parser/Parser.jjt | 12 +++- .../org/apache/commons/jexl3/ArrayLiteralTest.java | 40 ++ .../commons/jexl3/CollectionLiteralTest.java | 24 .../org/apache/commons/jexl3/Issues300Test.java| 33 +++ .../org/apache/commons/jexl3/MapLiteralTest.java | 31 +++ .../org/apache/commons/jexl3/SetLiteralTest.java | 37 + .../org/apache/commons/jexl3/internal/Util.java| 2 +- .../commons/jexl3/introspection/SandboxTest.java | 2 +- .../commons/jexl3/jexl342/OptionalArithmetic.java | 12 ++-- 23 files changed, 322 insertions(+), 201 deletions(-) diff --git a/BUILDING.txt b/BUILDING.txt index 926eacad..3b67478e 100644 --- a/BUILDING.txt +++ b/BUILDING.txt @@ -1,4 +1,4 @@ -JEXL 3.0 uses Maven 3 as the build tool, and requires Java 6 (or later). +JEXL 3.0 uses Maven 3 as the build tool, and requires Java 8 (or later). The following goals may be useful: * mvn clean - clean up @@ -10,5 +10,4 @@ The following goals may be useful: Note that the Maven build process uses JavaCC to generate some sources. These are created under target/generated sources and automatically compiled. The generated class files are needed to compile some of the ordinary Java source files. -This can cause problems for some IDEs, which will need to be configured accordingly. - \ No newline at end of file +This can cause problems for some IDEs, which will need to be configured accordingly. \ No newline at end of file diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt index 29450e27..a75a5b81 100644 --- a/RELEASE-NOTES.txt +++ b/RELEASE-NOTES.txt @@ -18,6 +18,23 @@ Its goal is to expose scripting features usable by technical operatives or consu https://commons.apache.org/jexl/ + +Release 3.2.1 + + +Version 3.3.1 is a maintenance release. + +Compatibility with previous releases + +Version 3.3.1 is source and binary compatible with 3.3. + +New Features in 3.3.1: + +* JEXL-398: Allow 'trailing commas' or ellipsis while defining array, map and set literals + +Bugs Fixed in 3.3.1: +=== + Release 3.3 diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 251375a1..187a6ed3 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -28,22 +28,26 @@ + + +Allow 'trailing commas' or ellipsis while defining array, map and set literals + [StepSecurity] ci: Harden GitHub Actions #180. - + Bumps ossf/scorecard-action from 2.1.3 to 2.2.0
[commons-jexl] branch master updated: JEXL: dependatbot triggered updates;
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 5511a7f0 JEXL: dependatbot triggered updates; 5511a7f0 is described below commit 5511a7f0e7a9fdac8221504fd5d4dfdd41788f4d Author: Henri Biestro AuthorDate: Fri Jun 30 14:58:09 2023 +0200 JEXL: dependatbot triggered updates; --- src/changes/changes.xml | 6 ++ 1 file changed, 6 insertions(+) diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 437cb00f..251375a1 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -33,6 +33,12 @@ [StepSecurity] ci: Harden GitHub Actions #180. + +Bumps ossf/scorecard-action from 2.1.3 to 2.2.0. + + +Bumps github/codeql-action from 2.1.22 to 2.20.1. + Bump commons-parent from 57 to 58.
[commons-jexl] branch master updated (22398f16 -> b54e4a95)
This is an automated email from the ASF dual-hosted git repository. henrib pushed a change to branch master in repository https://gitbox.apache.org/repos/asf/commons-jexl.git from 22398f16 Merge pull request #181 from apache/dependabot/github_actions/github/codeql-action-2.20.1 add 6dbf525c Bump ossf/scorecard-action from 2.1.3 to 2.2.0 new b54e4a95 Merge pull request #182 from apache/dependabot/github_actions/ossf/scorecard-action-2.2.0 The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference. Summary of changes: .github/workflows/scorecards-analysis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
[commons-jexl] 01/01: Merge pull request #182 from apache/dependabot/github_actions/ossf/scorecard-action-2.2.0
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 commit b54e4a95a2163d41e1860d431f03141e2b390889 Merge: 22398f16 6dbf525c Author: Henrib AuthorDate: Fri Jun 30 14:57:11 2023 +0200 Merge pull request #182 from apache/dependabot/github_actions/ossf/scorecard-action-2.2.0 Bump ossf/scorecard-action from 2.1.3 to 2.2.0 .github/workflows/scorecards-analysis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
[commons-jexl] branch master updated (63c919b5 -> 22398f16)
This is an automated email from the ASF dual-hosted git repository. henrib pushed a change to branch master in repository https://gitbox.apache.org/repos/asf/commons-jexl.git from 63c919b5 Spelling [StepSecurity] ci: Harden GitHub Actions #180 add 57dcc47f Bump github/codeql-action from 2.1.22 to 2.20.1 add 22398f16 Merge pull request #181 from apache/dependabot/github_actions/github/codeql-action-2.20.1 No new revisions were added by this update. Summary of changes: .github/workflows/scorecards-analysis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
[commons-jexl] 01/01: Merge pull request #178 from apache/dependabot/maven/org.moditect-moditect-maven-plugin-1.0.0.Final
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 commit d7cdf145ddb37d740b5b609b74ae4bbe61996951 Merge: 5592c6ca f22a9456 Author: Henrib AuthorDate: Sat May 6 10:33:24 2023 +0200 Merge pull request #178 from apache/dependabot/maven/org.moditect-moditect-maven-plugin-1.0.0.Final Bump moditect-maven-plugin from 1.0.0.RC3 to 1.0.0.Final pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
[commons-jexl] branch master updated (5592c6ca -> d7cdf145)
This is an automated email from the ASF dual-hosted git repository. henrib pushed a change to branch master in repository https://gitbox.apache.org/repos/asf/commons-jexl.git from 5592c6ca Merge remote-tracking branch 'origin/release' add f22a9456 Bump moditect-maven-plugin from 1.0.0.RC3 to 1.0.0.Final new d7cdf145 Merge pull request #178 from apache/dependabot/maven/org.moditect-moditect-maven-plugin-1.0.0.Final The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference. Summary of changes: pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
[commons-jexl] 01/01: Merge remote-tracking branch 'origin/release'
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 commit 5592c6cacb2d5ea28b70b77abefeae0e9eae5841 Merge: 46854b60 33787af3 Author: Henri Biestro AuthorDate: Thu May 4 13:34:04 2023 +0200 Merge remote-tracking branch 'origin/release'
[commons-jexl] branch master updated (46854b60 -> 5592c6ca)
This is an automated email from the ASF dual-hosted git repository. henrib pushed a change to branch master in repository https://gitbox.apache.org/repos/asf/commons-jexl.git from 46854b60 JEXL-397: core permissions allow dynamic proxy introspection; add 37fb9110 Bump to next development version add 3e9546b9 Javadoc: Convert package.html to package-info.java add 33787af3 JEXL-397: core permissions allow dynamic proxy introspection; new 5592c6ca Merge remote-tracking branch 'origin/release' The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference. Summary of changes:
[commons-jexl] branch master updated: JEXL-397: core permissions allow dynamic proxy introspection;
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 46854b60 JEXL-397: core permissions allow dynamic proxy introspection; 46854b60 is described below commit 46854b60a75fba8ec96066fae6051e38c6fe1245 Author: Henri Biestro AuthorDate: Thu May 4 12:55:58 2023 +0200 JEXL-397: core permissions allow dynamic proxy introspection; --- .../jexl3/internal/introspection/Permissions.java | 5 +++ .../org/apache/commons/jexl3/Issues300Test.java| 36 ++ 2 files changed, 41 insertions(+) diff --git a/src/main/java/org/apache/commons/jexl3/internal/introspection/Permissions.java b/src/main/java/org/apache/commons/jexl3/internal/introspection/Permissions.java index cbf5d987..983f9699 100644 --- a/src/main/java/org/apache/commons/jexl3/internal/introspection/Permissions.java +++ b/src/main/java/org/apache/commons/jexl3/internal/introspection/Permissions.java @@ -20,6 +20,7 @@ package org.apache.commons.jexl3.internal.introspection; import java.lang.reflect.Constructor; import java.lang.reflect.Field; import java.lang.reflect.Method; +import java.lang.reflect.Proxy; import java.util.Collections; import java.util.HashSet; import java.util.LinkedHashSet; @@ -406,6 +407,10 @@ public class Permissions implements JexlPermissions { if (!validate(clazz)) { return false; } +// proxy goes through +if (Proxy.isProxyClass(clazz)) { +return true; +} // class must be allowed if (deny(clazz)) { return false; diff --git a/src/test/java/org/apache/commons/jexl3/Issues300Test.java b/src/test/java/org/apache/commons/jexl3/Issues300Test.java index 34b4d008..b44eb879 100644 --- a/src/test/java/org/apache/commons/jexl3/Issues300Test.java +++ b/src/test/java/org/apache/commons/jexl3/Issues300Test.java @@ -18,12 +18,14 @@ package org.apache.commons.jexl3; import org.apache.commons.jexl3.internal.Engine32; import org.apache.commons.jexl3.internal.OptionsContext; +import static org.apache.commons.jexl3.introspection.JexlPermissions.RESTRICTED; import org.apache.commons.jexl3.introspection.JexlSandbox; import org.junit.Assert; import org.junit.Test; import java.io.StringReader; import java.io.StringWriter; +import java.lang.reflect.Proxy; import java.math.MathContext; import java.util.ArrayList; import java.util.Arrays; @@ -1284,4 +1286,38 @@ public class Issues300Test { Assert.assertEquals("foo", x.toString()); } +public interface Interface397i { +String summary(); +} +static private class Class397 implements Interface397i { +@Override public String summary() { +return getClass().getName(); +} +} + T createProxy(final JexlEngine jexl, final Object o, final Class[] clazzz) { +// a JEX-based delegating proxy +return (T) Proxy.newProxyInstance(getClass().getClassLoader(), clazzz, +(proxy, method, args) -> jexl.invokeMethod(o, method.getName(), args) +); +} + +@Test public void testIssue397() { +String result; +final String control = Class397.class.getName(); +final JexlEngine jexl = new JexlBuilder().permissions(RESTRICTED).create(); + +Interface397i instance = new Class397(); +result = (String) jexl.invokeMethod(instance, "summary"); +Assert.assertEquals(control, result); + +Interface397i proxy = createProxy(jexl, instance, new Class[] { Interface397i.class }) ; +result = (String) jexl.invokeMethod(proxy, "summary"); +Assert.assertEquals(control, result); + +JexlScript script = jexl.createScript("dan.summary()", "dan"); +result = (String) script.execute(null, instance); +Assert.assertEquals(control, result); +result = (String) script.execute(null, proxy); +Assert.assertEquals(control, result); +} }
[commons-jexl] 02/02: JEXL-397: core permissions allow dynamic proxy introspection;
This is an automated email from the ASF dual-hosted git repository. henrib pushed a commit to branch release in repository https://gitbox.apache.org/repos/asf/commons-jexl.git commit 33787af3153c80787c14dca6b7d3673a07516ab4 Author: Henri Biestro AuthorDate: Thu May 4 12:55:58 2023 +0200 JEXL-397: core permissions allow dynamic proxy introspection; --- .../jexl3/internal/introspection/Permissions.java | 5 +++ .../org/apache/commons/jexl3/Issues300Test.java| 36 ++ 2 files changed, 41 insertions(+) diff --git a/src/main/java/org/apache/commons/jexl3/internal/introspection/Permissions.java b/src/main/java/org/apache/commons/jexl3/internal/introspection/Permissions.java index cbf5d987..983f9699 100644 --- a/src/main/java/org/apache/commons/jexl3/internal/introspection/Permissions.java +++ b/src/main/java/org/apache/commons/jexl3/internal/introspection/Permissions.java @@ -20,6 +20,7 @@ package org.apache.commons.jexl3.internal.introspection; import java.lang.reflect.Constructor; import java.lang.reflect.Field; import java.lang.reflect.Method; +import java.lang.reflect.Proxy; import java.util.Collections; import java.util.HashSet; import java.util.LinkedHashSet; @@ -406,6 +407,10 @@ public class Permissions implements JexlPermissions { if (!validate(clazz)) { return false; } +// proxy goes through +if (Proxy.isProxyClass(clazz)) { +return true; +} // class must be allowed if (deny(clazz)) { return false; diff --git a/src/test/java/org/apache/commons/jexl3/Issues300Test.java b/src/test/java/org/apache/commons/jexl3/Issues300Test.java index a63239d4..a5989e6d 100644 --- a/src/test/java/org/apache/commons/jexl3/Issues300Test.java +++ b/src/test/java/org/apache/commons/jexl3/Issues300Test.java @@ -18,12 +18,14 @@ package org.apache.commons.jexl3; import org.apache.commons.jexl3.internal.Engine32; import org.apache.commons.jexl3.internal.OptionsContext; +import static org.apache.commons.jexl3.introspection.JexlPermissions.RESTRICTED; import org.apache.commons.jexl3.introspection.JexlSandbox; import org.junit.Assert; import org.junit.Test; import java.io.StringReader; import java.io.StringWriter; +import java.lang.reflect.Proxy; import java.math.MathContext; import java.util.ArrayList; import java.util.Arrays; @@ -1284,4 +1286,38 @@ public class Issues300Test { Assert.assertEquals("foo", x.toString()); } +public interface Interface397i { +String summary(); +} +static private class Class397 implements Interface397i { +@Override public String summary() { +return getClass().getName(); +} +} + T createProxy(final JexlEngine jexl, final Object o, final Class[] clazzz) { +// a JEX-based delegating proxy +return (T) Proxy.newProxyInstance(getClass().getClassLoader(), clazzz, +(proxy, method, args) -> jexl.invokeMethod(o, method.getName(), args) +); +} + +@Test public void testIssue397() { +String result; +final String control = Class397.class.getName(); +final JexlEngine jexl = new JexlBuilder().permissions(RESTRICTED).create(); + +Interface397i instance = new Class397(); +result = (String) jexl.invokeMethod(instance, "summary"); +Assert.assertEquals(control, result); + +Interface397i proxy = createProxy(jexl, instance, new Class[] { Interface397i.class }) ; +result = (String) jexl.invokeMethod(proxy, "summary"); +Assert.assertEquals(control, result); + +JexlScript script = jexl.createScript("dan.summary()", "dan"); +result = (String) script.execute(null, instance); +Assert.assertEquals(control, result); +result = (String) script.execute(null, proxy); +Assert.assertEquals(control, result); +} }
[commons-jexl] branch release updated (37fb9110 -> 33787af3)
This is an automated email from the ASF dual-hosted git repository. henrib pushed a change to branch release in repository https://gitbox.apache.org/repos/asf/commons-jexl.git from 37fb9110 Bump to next development version new 3e9546b9 Javadoc: Convert package.html to package-info.java new 33787af3 JEXL-397: core permissions allow dynamic proxy introspection; The 2 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference. Summary of changes: .../jexl3/internal/introspection/Permissions.java | 5 +++ .../org/apache/commons/jexl3/Issues300Test.java| 36 + .../apache/commons/jexl3/junit/package-info.java | 43 .../org/apache/commons/jexl3/junit/package.html| 47 -- 4 files changed, 84 insertions(+), 47 deletions(-) create mode 100644 src/test/java/org/apache/commons/jexl3/junit/package-info.java delete mode 100644 src/test/java/org/apache/commons/jexl3/junit/package.html
[commons-jexl] 01/02: Javadoc: Convert package.html to package-info.java
This is an automated email from the ASF dual-hosted git repository. henrib pushed a commit to branch release in repository https://gitbox.apache.org/repos/asf/commons-jexl.git commit 3e9546b9b19fb80b6dc6c774c72c77949053b185 Author: Gary Gregory AuthorDate: Sun Mar 19 12:46:32 2023 -0400 Javadoc: Convert package.html to package-info.java --- .../apache/commons/jexl3/junit/package-info.java | 43 .../org/apache/commons/jexl3/junit/package.html| 47 -- 2 files changed, 43 insertions(+), 47 deletions(-) diff --git a/src/test/java/org/apache/commons/jexl3/junit/package-info.java b/src/test/java/org/apache/commons/jexl3/junit/package-info.java new file mode 100644 index ..db7c7ff8 --- /dev/null +++ b/src/test/java/org/apache/commons/jexl3/junit/package-info.java @@ -0,0 +1,43 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Using JEXL expressions in JUnit assertions. + * Introduction + * + * This package only contains one class, Asserter, which + * allows you to use a JEXL expression in a JUnit assertion. + * The following example demonstrates the use of the Asserter + * class. An instance is created, and the internal JexlContext + * is populated via calls to setVariable(). Calls to + * assertExpression() succeed if the expression evaluates to + * the value of the second parameter, otherwise an + * AssertionFailedException is thrown. + * + * + * + * Asserter asserter = new Asserter(); + * asserter.setVariable("foo", new Foo()); + * asserter.setVariable("person", "James"); + * asserter.assertExpression("person", "James"); + * asserter.assertExpression("size(person)", new Integer(5)); + * + * asserter.assertExpression("foo.getCount()", new Integer(5)); + * asserter.assertExpression("foo.count", new Integer(5)); + * + */ +package org.apache.commons.jexl3.junit; diff --git a/src/test/java/org/apache/commons/jexl3/junit/package.html b/src/test/java/org/apache/commons/jexl3/junit/package.html deleted file mode 100644 index 7d2a89b2.. --- a/src/test/java/org/apache/commons/jexl3/junit/package.html +++ /dev/null @@ -1,47 +0,0 @@ - - - - Package Documentation for org.apache.commons.jexl3.junit Package - - - Using JEXL expressions in JUnit assertions. - Introduction - - This package only contains one class, Asserter, which - allows you to use a JEXL expression in a JUnit assertion. - The following example demonstrates the use of the Asserter - class. An instance is created, and the internal JexlContext - is populated via calls to setVariable(). Calls to - assertExpression() succeed if the expression evaluates to - the value of the second parameter, otherwise an - AssertionFailedException is thrown. - - - - Asserter asserter = new Asserter(); - asserter.setVariable("foo", new Foo()); - asserter.setVariable("person", "James"); - - asserter.assertExpression("person", "James"); - asserter.assertExpression("size(person)", new Integer(5)); - - asserter.assertExpression("foo.getCount()", new Integer(5)); - asserter.assertExpression("foo.count", new Integer(5)); - - -
[commons-jexl] branch master updated: JEXL-296: Add full Java module descriptor
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 f38007cf JEXL-296: Add full Java module descriptor new 71c4027b Merge pull request #177 from aalmiray/JEXL-396/java-modules f38007cf is described below commit f38007cf091e49a8ec0f740a310f6412d54860d5 Author: Andres Almiray AuthorDate: Fri Apr 28 17:08:07 2023 +0200 JEXL-296: Add full Java module descriptor Signed-off-by: Andres Almiray --- pom.xml | 45 + 1 file changed, 45 insertions(+) diff --git a/pom.xml b/pom.xml index 32354bbf..e2ce8c26 100644 --- a/pom.xml +++ b/pom.xml @@ -519,4 +519,49 @@ Dmitri Blinov + + + +java-module + +[9,) + + + + +org.moditect +moditect-maven-plugin +1.0.0.RC3 + + +add-module-infos +package + +add-module-info + + +9 + true + + +${commons.module.name} + + !org.apache.commons.jexl3.parser; + !org.apache.commons.jexl3.internal*; +*; + + true + + + +--multi-release=9 + + + + + + + + +
[commons-jexl] branch master updated: Update README.md
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 35b3de81 Update README.md 35b3de81 is described below commit 35b3de81c742a55ec19aaab27bd120f5cd42209e Author: Henrib AuthorDate: Fri Apr 28 18:54:39 2023 +0200 Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1e030abe..8be517c7 100644 --- a/README.md +++ b/README.md @@ -68,7 +68,7 @@ Alternatively you can pull it from the central Maven repositories: org.apache.commons commons-jexl3 - 3.2.1 + 3.3 ```
[commons-scxml] branch master updated: [ SCXML ] Update to JEXL 3.3
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-scxml.git The following commit(s) were added to refs/heads/master by this push: new 248c049 [ SCXML ] Update to JEXL 3.3 248c049 is described below commit 248c0493e2eb1eef09ddfbefec50b6c5b30d3353 Author: Henri Biestro AuthorDate: Wed Apr 12 08:34:59 2023 +0200 [ SCXML ] Update to JEXL 3.3 --- src/changes/changes.xml | 15 --- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/changes/changes.xml b/src/changes/changes.xml index a8403d0..769597f 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -138,11 +138,11 @@ -[07-12-2015] SCInstance becomes not serialzable after triggering event. +[07-12-2015] SCInstance becomes not serialzable after triggering event. -[07-12-2015] Unit test (ScriptTest) fails on Java 1.8 due to new JS Engine. +[07-12-2015] Unit test (ScriptTest) fails on Java 1.8 due to new JS Engine. @@ -329,6 +329,7 @@ [11-01-2013] Support for JEXL2 Evaluator. + Bump commons-jexl3 from 3.2.1 to 3.3 Bump actions/cache from 2.1.4 to 3.0.11 #31, #47, #50, #78. Bump actions/checkout from 2 to 3.1.0 #34, #75. Bump actions/setup-java from 1.4.0 to 3.6.0 #49, #79. @@ -971,7 +972,7 @@ [02-24-2006] Define ExternalContent interface to mark elements that may contain "body content" (in external namespaces), for - example, the SCXML "send" element. + example, the SCXML "send" element. @@ -1095,7 +1096,7 @@ Firing events on an SCXML engine Standalone testing Fun with EL - + @@ -1106,7 +1107,7 @@ [10-14-2005] Added Commons look and feel (navigation bar) to website. - + [10-10-2005] Added second usecase for Commons SCXML (within ASF projects). Demonstrated the use of SCXML documents for describing Shale dialogs. @@ -1150,7 +1151,7 @@ -[09-15-2005] Now handling outgoing transitions from a Parallel +[09-15-2005] Now handling outgoing transitions from a Parallel (Section 3.4 SCXML WD). @@ -1187,7 +1188,7 @@ -[08-24-2005] RootContext (used in the JSP environment) should override +[08-24-2005] RootContext (used in the JSP environment) should override ELContext#has(String) method.
[commons-scxml] branch master updated: Update to JEXL 3.3
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-scxml.git The following commit(s) were added to refs/heads/master by this push: new 0dbbd2a Update to JEXL 3.3 new 1140b4c Merge pull request #123 from henrib/master 0dbbd2a is described below commit 0dbbd2a0266ad7034d23e5ad0db6a3f321438072 Author: Henri Biestro AuthorDate: Tue Apr 11 17:53:59 2023 +0200 Update to JEXL 3.3 --- pom.xml | 8 .../java/org/apache/commons/scxml2/env/jexl/JexlEvaluator.java| 4 +++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/pom.xml b/pom.xml index 589f6bd..b978963 100644 --- a/pom.xml +++ b/pom.xml @@ -160,7 +160,7 @@ org.apache.commons commons-jexl3 - 3.2.1 + 3.3 true @@ -377,7 +377,7 @@ js 22.0.0 test - + org.graalvm.js js-scriptengine @@ -401,9 +401,9 @@ - + - + rc diff --git a/src/main/java/org/apache/commons/scxml2/env/jexl/JexlEvaluator.java b/src/main/java/org/apache/commons/scxml2/env/jexl/JexlEvaluator.java index 9f181bf..e628ee5 100644 --- a/src/main/java/org/apache/commons/scxml2/env/jexl/JexlEvaluator.java +++ b/src/main/java/org/apache/commons/scxml2/env/jexl/JexlEvaluator.java @@ -23,6 +23,7 @@ import org.apache.commons.jexl3.JexlBuilder; import org.apache.commons.jexl3.JexlExpression; import org.apache.commons.jexl3.JexlEngine; import org.apache.commons.jexl3.JexlScript; +import org.apache.commons.jexl3.introspection.JexlPermissions; import org.apache.commons.scxml2.Context; import org.apache.commons.scxml2.Evaluator; import org.apache.commons.scxml2.EvaluatorProvider; @@ -180,7 +181,8 @@ public class JexlEvaluator extends AbstractBaseEvaluator { // See javadoc of org.apache.commons.jexl2.JexlEngine#setFunctions(Map funcs) for detail. final Map funcs = new HashMap<>(); funcs.put(null, JexlBuiltin.class); -return new JexlBuilder().namespaces(funcs).cache(256).create(); +JexlPermissions permissions = JexlPermissions.RESTRICTED.compose("org.apache.commons.scxml2.*"); +return new JexlBuilder().permissions(permissions).namespaces(funcs).cache(256).create(); } /**
[commons-jexl] 01/01: Merge pull request #173 from apache/dependabot/maven/org.ow2.asm-asm-9.5
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 commit 6691d445d66d5bc2db217bc33c5f270aef0f5bf8 Merge: edd8a65f 2ececbca Author: Henrib <1228870+hen...@users.noreply.github.com> AuthorDate: Fri Mar 31 16:02:00 2023 +0200 Merge pull request #173 from apache/dependabot/maven/org.ow2.asm-asm-9.5 Bump asm from 9.4 to 9.5 pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
[commons-jexl] branch master updated (edd8a65f -> 6691d445)
This is an automated email from the ASF dual-hosted git repository. henrib pushed a change to branch master in repository https://gitbox.apache.org/repos/asf/commons-jexl.git from edd8a65f Merge pull request #174 from apache/dependabot/maven/org.codehaus.mojo-animal-sniffer-maven-plugin-1.23 add 2ececbca Bump asm from 9.4 to 9.5 new 6691d445 Merge pull request #173 from apache/dependabot/maven/org.ow2.asm-asm-9.5 The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference. Summary of changes: pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
[commons-jexl] branch master updated (d1d0dc70 -> edd8a65f)
This is an automated email from the ASF dual-hosted git repository. henrib pushed a change to branch master in repository https://gitbox.apache.org/repos/asf/commons-jexl.git from d1d0dc70 Merge pull request #171 from apache/dependabot/github_actions/actions/setup-java-3.11.0 add 0d482463 Bump animal-sniffer-maven-plugin from 1.22 to 1.23 add edd8a65f Merge pull request #174 from apache/dependabot/maven/org.codehaus.mojo-animal-sniffer-maven-plugin-1.23 No new revisions were added by this update. Summary of changes: pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
svn commit: r1908747 - /commons/cms-site/trunk/doap/doap_jexl.rdf
Author: henrib Date: Mon Mar 27 11:03:43 2023 New Revision: 1908747 URL: http://svn.apache.org/viewvc?rev=1908747=rev Log: JEXL 3.3 release Modified: commons/cms-site/trunk/doap/doap_jexl.rdf Modified: commons/cms-site/trunk/doap/doap_jexl.rdf URL: http://svn.apache.org/viewvc/commons/cms-site/trunk/doap/doap_jexl.rdf?rev=1908747=1908746=1908747=diff == --- commons/cms-site/trunk/doap/doap_jexl.rdf (original) +++ commons/cms-site/trunk/doap/doap_jexl.rdf Mon Mar 27 11:03:43 2023 @@ -36,6 +36,13 @@ commons-jexl3 +2023-03-27 +3.3 + + + + +commons-jexl3 2021-06-25 3.2.1
[commons-jexl] branch master updated: Bump to next development version
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 64c4822c Bump to next development version 64c4822c is described below commit 64c4822c1487d2d556ea18a7ef25a950a92b9006 Author: henrib AuthorDate: Mon Mar 27 10:08:49 2023 +0200 Bump to next development version --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 5f0a9dad..29e438d9 100644 --- a/pom.xml +++ b/pom.xml @@ -24,7 +24,7 @@ commons-jexl3 -3.3 +3.3.1-SNAPSHOT Apache Commons JEXL JEXL is a library intended to facilitate the implementation of scripting features in applications and frameworks written in Java. @@ -79,8 +79,8 @@ ${commons.encoding} -3.2.1 -3.3 +3.3 +3.3.1 true scm:svn:https://dist.apache.org/repos/dist/dev/commons/${commons.componentid} Henri Biestro
[commons-jexl] branch release updated (29a15cbc -> 37fb9110)
This is an automated email from the ASF dual-hosted git repository. henrib pushed a change to branch release in repository https://gitbox.apache.org/repos/asf/commons-jexl.git from 29a15cbc JEXL: getting ready for RC2 ; add 4e91dc63 JEXL: getting ready for RC2 ; new 37fb9110 Bump to next development version The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference. Summary of changes: pom.xml| 6 ++--- .../internal/introspection/PermissionsParser.java | 29 -- .../jexl3/parser/ASTIdentifierAccessJxlt.java | 4 --- 3 files changed, 19 insertions(+), 20 deletions(-)
[commons-jexl] 01/01: Bump to next development version
This is an automated email from the ASF dual-hosted git repository. henrib pushed a commit to branch release in repository https://gitbox.apache.org/repos/asf/commons-jexl.git commit 37fb9110d584fef3de4688efbc8886978e96239d Author: henrib AuthorDate: Mon Mar 27 10:08:49 2023 +0200 Bump to next development version --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 5f0a9dad..29e438d9 100644 --- a/pom.xml +++ b/pom.xml @@ -24,7 +24,7 @@ commons-jexl3 -3.3 +3.3.1-SNAPSHOT Apache Commons JEXL JEXL is a library intended to facilitate the implementation of scripting features in applications and frameworks written in Java. @@ -79,8 +79,8 @@ ${commons.encoding} -3.2.1 -3.3 +3.3 +3.3.1 true scm:svn:https://dist.apache.org/repos/dist/dev/commons/${commons.componentid} Henri Biestro
[commons-jexl] annotated tag rel/commons-jexl-3.3 created (now 9285aeb2)
This is an automated email from the ASF dual-hosted git repository. henrib pushed a change to annotated tag rel/commons-jexl-3.3 in repository https://gitbox.apache.org/repos/asf/commons-jexl.git at 9285aeb2 (tag) tagging 4e91dc63dba73204c8a69295e1ab402c1ab7d3e4 (commit) replaces rel/commons-jexl-3.2.1 by henrib on Mon Mar 27 10:04:34 2023 +0200 - Log - Create Commons JEXL 3.3 release tag -BEGIN PGP SIGNATURE- iQIzBAABCAAdFiEENpLBLH49M2pFK+slTgZuBFnNEJsFAmQhThIACgkQTgZuBFnN EJs3WA//aY0MOZWjv3kiv8vwh1ELyJ4TLGUPLiLJLkUTfpoJXfiYIr4VSZTtF+R2 gY1IVBDuT3W/c1+tL1qaU6jeX92DaC98LNqpuo4m70v47omQwABEgxe7AZJH/UOo V687OsZ5dUQsHfukH3Ey9ls6InITXAtUO/fKhuPkfE9cXjGoEHiRmWwbWS519N7S JCrQ2Z2B68AnmaedVYkavJzfi9abiuX7eyuVhsBBurIN0rbj4syEi/lOdclzY58v h7RDu0Yx0GdsDBM5nV7Xg08fafEpSPBDBwQCOc4IW+ERGgzKJe21/rG4DwqXneQS mTPNVDBBTzHkRl1LCWphYwPuK2mbvCRJm9IZjA7SRyXSKu6e+S5OHYYuiWe6U2OZ QOi6+WL5CKniLshny4eAVc8of0cTUdOrOI5dejiDTNaK11WsInBkEBXKDFz6ZVHG Bd/x/IKqRbSIsdf6KQJEUhpMgmOVusTQt+bXd7dAmBHFmNfsYipeXYXOGgodZP2y 8FL+LtBbcmotz52WecSq9tC0ZYX7N4uk4G7GyWN+vOfIOxOMZJxK4t6H2d0AMpeV Pg1G/jJQv2/wbX7qeW/1b7g9aUlB/OTBjRm7ZZglMfHGe6Xr0X5i+AbYduJlwEqt 9rmWua/PmFoAAAu3wYX5AqT/EFcVZaF+fUk0cyLX1RqqVcBi004= =N7Ot -END PGP SIGNATURE- --- No new revisions were added by this update.
svn commit: r60837 - /dev/commons/jexl/3.3-RC2/ /dev/commons/jexl/3.3-RC2/binaries/ /dev/commons/jexl/3.3-RC2/source/ /release/commons/jexl/ /release/commons/jexl/binaries/ /release/commons/jexl/sourc
Author: henrib Date: Mon Mar 27 07:53:39 2023 New Revision: 60837 Log: Publish commons-jexl 3.3 Release Added: release/commons/jexl/RELEASE-NOTES.txt - copied unchanged from r60836, dev/commons/jexl/3.3-RC2/RELEASE-NOTES.txt release/commons/jexl/binaries/commons-jexl-3.3-bin.tar.gz - copied unchanged from r60836, dev/commons/jexl/3.3-RC2/binaries/commons-jexl-3.3-bin.tar.gz release/commons/jexl/binaries/commons-jexl-3.3-bin.tar.gz.asc - copied unchanged from r60836, dev/commons/jexl/3.3-RC2/binaries/commons-jexl-3.3-bin.tar.gz.asc release/commons/jexl/binaries/commons-jexl-3.3-bin.tar.gz.sha512 - copied unchanged from r60836, dev/commons/jexl/3.3-RC2/binaries/commons-jexl-3.3-bin.tar.gz.sha512 release/commons/jexl/binaries/commons-jexl-3.3-bin.zip - copied unchanged from r60836, dev/commons/jexl/3.3-RC2/binaries/commons-jexl-3.3-bin.zip release/commons/jexl/binaries/commons-jexl-3.3-bin.zip.asc - copied unchanged from r60836, dev/commons/jexl/3.3-RC2/binaries/commons-jexl-3.3-bin.zip.asc release/commons/jexl/binaries/commons-jexl-3.3-bin.zip.sha512 - copied unchanged from r60836, dev/commons/jexl/3.3-RC2/binaries/commons-jexl-3.3-bin.zip.sha512 release/commons/jexl/source/commons-jexl-3.3-src.tar.gz - copied unchanged from r60836, dev/commons/jexl/3.3-RC2/source/commons-jexl-3.3-src.tar.gz release/commons/jexl/source/commons-jexl-3.3-src.tar.gz.asc - copied unchanged from r60836, dev/commons/jexl/3.3-RC2/source/commons-jexl-3.3-src.tar.gz.asc release/commons/jexl/source/commons-jexl-3.3-src.tar.gz.sha512 - copied unchanged from r60836, dev/commons/jexl/3.3-RC2/source/commons-jexl-3.3-src.tar.gz.sha512 release/commons/jexl/source/commons-jexl-3.3-src.zip - copied unchanged from r60836, dev/commons/jexl/3.3-RC2/source/commons-jexl-3.3-src.zip release/commons/jexl/source/commons-jexl-3.3-src.zip.asc - copied unchanged from r60836, dev/commons/jexl/3.3-RC2/source/commons-jexl-3.3-src.zip.asc release/commons/jexl/source/commons-jexl-3.3-src.zip.sha512 - copied unchanged from r60836, dev/commons/jexl/3.3-RC2/source/commons-jexl-3.3-src.zip.sha512 Removed: dev/commons/jexl/3.3-RC2/RELEASE-NOTES.txt dev/commons/jexl/3.3-RC2/binaries/commons-jexl-3.3-bin.tar.gz dev/commons/jexl/3.3-RC2/binaries/commons-jexl-3.3-bin.tar.gz.asc dev/commons/jexl/3.3-RC2/binaries/commons-jexl-3.3-bin.tar.gz.sha512 dev/commons/jexl/3.3-RC2/binaries/commons-jexl-3.3-bin.zip dev/commons/jexl/3.3-RC2/binaries/commons-jexl-3.3-bin.zip.asc dev/commons/jexl/3.3-RC2/binaries/commons-jexl-3.3-bin.zip.sha512 dev/commons/jexl/3.3-RC2/source/commons-jexl-3.3-src.tar.gz dev/commons/jexl/3.3-RC2/source/commons-jexl-3.3-src.tar.gz.asc dev/commons/jexl/3.3-RC2/source/commons-jexl-3.3-src.tar.gz.sha512 dev/commons/jexl/3.3-RC2/source/commons-jexl-3.3-src.zip dev/commons/jexl/3.3-RC2/source/commons-jexl-3.3-src.zip.asc dev/commons/jexl/3.3-RC2/source/commons-jexl-3.3-src.zip.sha512