Retain root cause for parsing patterns in @DateTimeFormat

The support for fallback parsing patterns in @DateTimeFormat introduced
in gh-20292 introduced a regression in that the original cause of the
parsing exception was no longer retained.

This commit ensures that the original DateTimeParseException is set as
the cause for any newly created DateTimeParseException, thereby
retaining the original exception as the root cause.

Closes gh-26777
This commit is contained in:
Sam Brannen
2021-04-12 19:55:43 +02:00
parent 327e761536
commit 22d9012081
2 changed files with 36 additions and 3 deletions

View File

@@ -101,7 +101,7 @@ public final class TemporalAccessorParser implements Parser<TemporalAccessor> {
if (this.source != null) {
throw new DateTimeParseException(
String.format("Unable to parse date time value \"%s\" using configuration from %s", text, this.source),
text, ex.getErrorIndex());
text, ex.getErrorIndex(), ex);
}
// else rethrow original exception
throw ex;