RFR: 8297211: Expensive fillInStackTrace operation in HttpURLConnection.getOutputStream0 when no content-length in response [v2]

Evgeny Astigeevich eastigeevich at openjdk.org
Mon Nov 21 13:06:44 UTC 2022


On Mon, 21 Nov 2022 12:49:20 GMT, Hannes Greule <duke at openjdk.org> wrote:

>> Jaikiran Pai has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   review suggestion - do a similar change in URLConnection
>
> src/java.base/share/classes/java/net/URLConnection.java line 680:
> 
>> 678:             try {
>> 679:                 return Date.parse(value);
>> 680:             } catch (NumberFormatException e) { }
> 
> (not a reviewer) I think NumberFormatException isn't sufficient here. `Date.parse` might throw an `IllegalArgumentException`.

@SirYwell Thanks for spotting this. You are right: [Date.parse](https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Date.html#parse(java.lang.String))

Attempts to interpret the string s as a representation of a date and time.
If the attempt is successful...
If the attempt fails, an IllegalArgumentException is thrown.

@jaikiran I suggest to use the original code for catching exceptions: `} catch (Exception e) { }`

-------------

PR: https://git.openjdk.org/jdk/pull/11258


More information about the net-dev mailing list