[ 
https://issues.apache.org/jira/browse/HTTPCLIENT-2319?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Arturo Bernal resolved HTTPCLIENT-2319.
---------------------------------------
    Fix Version/s: 5.4-alpha2
       Resolution: Fixed

> DateUtils.parseStandardDate() throws exception instead of returning null
> ------------------------------------------------------------------------
>
>                 Key: HTTPCLIENT-2319
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-2319
>             Project: HttpComponents HttpClient
>          Issue Type: Bug
>          Components: HttpClient (classic)
>    Affects Versions: 5.3.1
>            Reporter: Bernd Watermann
>            Priority: Minor
>             Fix For: 5.4-alpha2
>
>
> The following line of code
> {code:java}
> org.apache.hc.client5.http.utils.DateUtils.parseStandardDate("Thu Feb 22 
> 17:20:18 2024");{code}
> throws an exception with the following stack trace:
> {noformat}
> java.time.DateTimeException: Unable to obtain Instant from TemporalAccessor: 
> {},ISO resolved to 2024-02-22T17:20:18 of type java.time.format.Parsed
>     at java.base/java.time.Instant.from(Instant.java:380)
>     at 
> org.apache.hc.client5.http.utils.DateUtils.parseDate(DateUtils.java:165)
>     at 
> org.apache.hc.client5.http.utils.DateUtils.parseStandardDate(DateUtils.java:183){noformat}
> The documentation for parseStandardDate(), however, says:
> ??Returns: the parsed instant or null if input could not be parsed??
> Throwing an exception does not seem to conform to that spec.
> Note that I don't care (at present) if the given string should actually be 
> parseable or not. The primary issue is error handling and the fact that any 
> error should lead to a null result and not to an exception being thrown.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@hc.apache.org
For additional commands, e-mail: dev-h...@hc.apache.org

Reply via email to