Issue Details (XML | Word | Printable)

Key: JEXL-17
Type: Improvement Improvement
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Unassigned
Reporter: Kohsuke Kawaguchi
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
Commons JEXL

ExpressionFactory.createNewExpression should throw an Exception in case of a parsing error, not Error

Created: 05/Aug/06 07:01 PM   Updated: 09/Aug/06 04:33 AM
Return to search
Component/s: None
Affects Version/s: 1.0
Fix Version/s: 1.1

Time Tracking:
Not Specified

File Attachments:
  Size
File Licensed for inclusion in ASF works JEXL-17.diff 2006-08-05 07:02 PM Kohsuke Kawaguchi 3 kB

Resolution Date: 06/Aug/06 06:37 PM


 Description  « Hide
When ExpressionFactory.createNewExpression(...) takes an syntactically incorrect expression, JEXL throws TokenMgrError. However, typical callers (such as Jelly) don't expect such syntax error to be a java.lang.Error, so it fails to catch it.

A typical outcome is therefore the thread to die completely, and even worse the stack trace doesn't report neither what was the expression that was being parsed, nor does it report any contextual information (again in case of Jelly, that would be where in the jelly script this error happened.)

This makes the error diagnosis unnecessarily hard. I believe the proper thing to do is to wrap such an exception into java.lang.Exception or its sub-class, allowing the caller to catch it.



 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Kohsuke Kawaguchi added a comment - 05/Aug/06 07:02 PM
Patch for this change.

Rahul Akolkar added a comment - 06/Aug/06 02:50 AM
Can you supply a test case (just the expression String should do) where this happens? Usually, I see oacj.parser.ParseException if the expression is malformed. It would seem more appropriate to (re)use that here, if needed, rather than defining a new exception.

Kohsuke Kawaguchi added a comment - 06/Aug/06 05:59 AM
For example, "a?b:c" should do, since the lexer wouldn't understand '?'.
I overlooked that existing exception, and I agree that it's better to reuse it.

Rahul Akolkar added a comment - 06/Aug/06 06:37 PM
Thanks, fixed in r429169:

http://svn.apache.org/viewvc?view=rev&revision=429169

Reused the existing ParseException and added a couple of test cases to ensure the Error is rethrown as this Exception.