Copilot commented on code in PR #398:
URL: https://github.com/apache/commons-jexl/pull/398#discussion_r2803834968


##########
src/test/java/org/apache/commons/jexl3/Issues400Test.java:
##########
@@ -1067,5 +1067,80 @@ void testIssue455h() {
         Assertions.assertEquals("World Hello World ! ~", writer.toString());
     }
 
+    @Test
+    void testIssue350_456_strict() {
+        final JexlEngine jexl = new JexlBuilder().strict(true).create();
+        final JxltEngine jxlt = jexl.createJxltEngine();
+        // creation/parse is OK
+        final JxltEngine.Template template = jxlt.createTemplate("$$ var foo = 
'foo';\n$$ var bar = 'bar';\n${foo + bar}");
+        final StringWriter writer = new StringWriter();
+            template.evaluate(null, writer);
+            Assertions.assertEquals("foobar", writer.toString());

Review Comment:
   Inconsistent indentation detected. Lines 1077-1078 should be indented at the 
same level as line 1076 (the previous line with StringWriter declaration). The 
current extra indentation appears to be unintentional.
   ```suggestion
           template.evaluate(null, writer);
           Assertions.assertEquals("foobar", writer.toString());
   ```



##########
src/main/java/org/apache/commons/jexl3/parser/JexlParser.java:
##########
@@ -961,7 +961,13 @@ protected void jjtreeCloseNodeScope(final JexlNode node) {
      */
     @Override
     public ASTJexlScript jxltParse(final JexlInfo info, final JexlFeatures 
features, final String src, final Scope scope) {
-        return new Parser(this).parse(info, features, src, scope);
+        JexlFeatures previous = getFeatures();
+        try {
+            return new Parser(this).parse(info, features, src, scope);
+        } catch (JexlException.Parsing ex) {

Review Comment:
   The catch block only catches JexlException.Parsing, but the child parser can 
also throw JexlException.Tokenization (from TokenMgrException) or other 
JexlException subtypes. Consider catching JexlException (the parent class) 
instead to ensure cleanup happens for all parsing-related exceptions, not just 
parsing syntax errors. This would make the error handling more robust and 
consistent with the finally block in Parser.parse which cleans up regardless of 
exception type.
   ```suggestion
           } catch (JexlException ex) {
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to