lihongyi87 opened a new pull request, #1040:
URL: https://github.com/apache/tomcat/pull/1040
## Problem
Coercion to `java.time.Instant` (added for Tomcat 12) can leak unchecked
exceptions instead of the `ELException` required by the EL specification.
In `ELSupport.coerceToInstant()`:
- `Instant.parse("not-a-date")` throws
`java.time.format.DateTimeParseException`
- `Instant.from(LocalDate.of(...))` throws `java.time.DateTimeException` /
`UnsupportedTemporalTypeException`
Both are `RuntimeException` subclasses that propagate directly to the
caller, while the method contract (and the rest of `ELSupport`, e.g.
`coerceToNumber`) requires a `jakarta.el.ELException`.
## Fix
Wrap the failures from `Instant.from()` and `Instant.parse()` in
`ELException`, matching the pattern already used by `coerceToNumber` for
`NumberFormatException`.
## Testing
Added three tests to `TestELSupport`:
- `testCoerceToInstant01` — valid string coerces to `Instant`
- `testCoerceToInstant02` — invalid string throws `ELException`
- `testCoerceToInstant03` — `LocalDate` (no timezone) throws `ELException`
`TestELSupport` passes (54 tests, 0 failures) on JDK 23.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]