RFR: 8353453: URLDecoder should use HexFormat

Daniel Fuchs dfuchs at openjdk.org
Wed Apr 2 10:08:13 UTC 2025


On Tue, 1 Apr 2025 22:59:07 GMT, Chen Liang <liach at openjdk.org> wrote:

>> src/java.base/share/classes/java/net/URLDecoder.java line 208:
>> 
>>> 206:                     while ( ((i+2) < numChars) &&
>>> 207:                             (c=='%')) {
>>> 208:                         int v = HexFormat.fromHexDigits(s, i + 1, i + 3);
>> 
>> Its worth noting that the exceptions thrown by HexFormat.fromHexDigits are different than those thrown by Integer.parseInt, as to the specific type and exception message.
>
> They are both NumberFormatException that is immediately handled by an enclosing catch block. This change should only affect the exception message for inputs fragments like %-F.

Right. And `NumberFormatException` is a subclass of `IllegalArgumentException` so that would remain compatible even if it were not caught and replaced by plain IAE.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/24314#discussion_r2024512784


More information about the net-dev mailing list