RFR: 8297569: URLPermission constructor throws IllegalArgumentException: Invalid characters in hostname after JDK-8294378
Jaikiran Pai
jpai at openjdk.org
Fri Nov 25 01:28:24 UTC 2022
On Thu, 24 Nov 2022 12:19:13 GMT, Jaikiran Pai <jpai at openjdk.org> wrote:
> Can I please get a review of this change which proposes to fix https://bugs.openjdk.org/browse/JDK-8297569?
>
> Recently we fixed a bug in `java.net.URLPermission` where that class used to run into an exception while trying to convert a hostname into lowercase, when run in Turkish locale https://bugs.openjdk.org/browse/JDK-8294378. The approach we decided to take in that fix was to use an internal `HostPortRange.toLowerCase` method which was unaffected by `Locale`s. The other alternative was to use `String.toLowerCase(Locale.ROOT)`, but we decided to use the former since it was already being used in other parts of the code in that area.
>
> The implementation of `HostPortRange.toLowerCase` is very strict and it allows only a specific set of characters. The `_` (underscore character) isn't one of them. Before the change we did there, a `URLPermission` constructor could be passed a string `http://foo_bar` and it used to construct the instance successfully. However, after that change, it now fails with the exception noted in the issue.
>
> The commit here reverts the previous fix and instead now uses `String.toLowerCase(Locale.ROOT)` to lowercase the authority. Additionally, an `else` block that we had introduced in the previous fix has been removed to bring us back to the old behaviour.
>
> The test has been updated to include `http://foo_bar` (and its one more variant) string to construct the `URLPermission` instance.
>
> JCK testing with the changes in this PR passed and other `tier` testing is currently in progress.
Thank you Daniel for the review.
-------------
PR: https://git.openjdk.org/jdk/pull/11353
More information about the net-dev
mailing list