mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-26 22:34:27 +02:00
8319640: ClassicFormat::parseObject (from DateTimeFormatter) does not conform to the javadoc and may leak DateTimeException
Reviewed-by: rriggs, iris, jlu, joehw
This commit is contained in:
parent
1802cb566e
commit
fe0ccdf5f8
2 changed files with 42 additions and 16 deletions
|
@ -2296,29 +2296,23 @@ public final class DateTimeFormatter {
|
|||
DateTimeParseContext context;
|
||||
try {
|
||||
context = formatter.parseUnresolved0(text, pos);
|
||||
} catch (IndexOutOfBoundsException ex) {
|
||||
if (pos.getErrorIndex() < 0) {
|
||||
pos.setErrorIndex(0);
|
||||
if (context == null) {
|
||||
if (pos.getErrorIndex() < 0) {
|
||||
pos.setErrorIndex(0);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
if (context == null) {
|
||||
if (pos.getErrorIndex() < 0) {
|
||||
pos.setErrorIndex(0);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
TemporalAccessor resolved = context.toResolved(formatter.resolverStyle, formatter.resolverFields);
|
||||
if (parseType == null) {
|
||||
return resolved;
|
||||
}
|
||||
return resolved.query(parseType);
|
||||
} catch (RuntimeException ex) {
|
||||
pos.setErrorIndex(0);
|
||||
if (pos.getErrorIndex() < 0) {
|
||||
pos.setErrorIndex(0);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue