henrib opened a new pull request, #425:
URL: https://github.com/apache/commons-jexl/pull/425

   [JEXL-476](https://issues.apache.org/jira/browse/JEXL-476), on top of #424 
(JEXL-474).
   
   Safe navigation (`?.`, `?[`, the `safe` option) excuses both *null* (the 
object an access applies to has no value)
   and *undefined* (a variable, property, method or function does not exist), 
and does so differently for properties,
   methods and array accesses. A new option, `safeUndefined`, true by default, 
makes the null-only model available:
   
   ```java
   JexlEngine jexl = new 
JexlBuilder().strict(true).safeUndefined(false).create();
   ```
   
   - `JexlOptions.setSafeUndefined(boolean)` / `isSafeUndefined()`, 
`JexlBuilder.safeUndefined(boolean)`; also a flag
     name (`"-safeUndefined"`) for `JexlOptions.setFlags` and the 
`jexl.options` pragma
   - false: safe navigation only applies to null; an undefined variable, 
property, method or function is an error,
     with or without `?.`, `?[` or the `safe` option
   - true (default): behavior as released, with the safe access operators made 
consistent:
     `x.missing?.y` and `x?['missing']` evaluate as null as `x.missing()?.y` 
and `x?.missing` already do
   - in both cases, `??`, `?:` and the ternary condition tolerate a missing 
method or function, as they do an
     undefined variable or a missing property
   - a safe access no longer hides an exception thrown by a property getter 
(`bean?.boom`)
   
   Two released behaviors are kept with the default and the `safe` option, 
since changing them would affect default
   engines: `x.missing` is an error where `x.missing()` is null, and `var x = 
u` with `u` undefined is null (JEXL-275).
   Neither exists when `safeUndefined` is false.
   
   Tests: `Issues400Test.test476` (expressions x the four 
`safeUndefined`/`safe` combinations); no existing test changed.
   
   - [x] `mvn` default goal passes
   - [x] AI disclosure: written with Claude Code (Claude Fable 5), reviewed by 
the committer.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
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