RFR: 8285521: Minor improvements in java.net.URI

ExE Boss duke at openjdk.java.net
Thu May 19 12:22:49 UTC 2022


On Tue, 26 Apr 2022 07:02:55 GMT, Сергей Цыпанов <duke at openjdk.java.net> wrote:

> - use `String.equalsIgnoreCase()` instead of hand-written code relying on `String.charAt()`
> - use `String.compareToIgnoreCase()` instead of hand-written code relying on `String.charAt()`
> - drop branches that are never executed
> - drop unused argument from `URI.resolvePath()`
> - simplify String-related operations

The `String.equalsIgnoreCase(…)` and `String.compareToIgnoreCase(…)` changes are incorrect, as the `String.*IgnoreCase(…)` methods compare all **Unicode** code points case‑insensitively using **Unicode** rules for the current or specified locale, whereas the **URI** specification does case‑insensitive comparison only for characters in the **US‑ASCII** range [[RFC3986]].

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

https://github.com/openjdk/jdk/blob/408a3a8e29006798071cd6f185e415bc2bc62282/src/java.base/share/classes/java/net/URI.java#L1825-L1830 https://github.com/openjdk/jdk/blob/408a3a8e29006798071cd6f185e415bc2bc62282/src/java.base/share/classes/java/net/URI.java#L1832-L1844

[RFC3986]: https://datatracker.ietf.org/doc/html/rfc3986

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

Changes requested by ExE-Boss at github.com (no known OpenJDK username).

PR: https://git.openjdk.java.net/jdk/pull/8397


More information about the net-dev mailing list