On Wed, 2 Dec 2026 15:40:42 GMT, Daniel Fuchs <[email protected]> wrote:
>> Please find here a fix that improves URL and URI normalization algorithm. >> The patch introduces a new static package-private normalize method in >> java.net.URI that both URL and URI can share. The new method is based on the >> pre-existing URI normalization algorithm, but avoids multiple backtacking >> passes in the presence of .. segments. >> >> This is globally similar to what was done for Path in >> https://github.com/openjdk/jdk/pull/33799 >> >> When applying normalization, `URLStreamHandler` now uses the shared method >> instead of rolling up its own. >> The `jar:` `Handler` now also uses the new method to normalize the resource >> path (after the bang `!` separator) >> >> URI normalization output remained unchanged, but this patch revealed a few >> corner case bugs in the existing URL normalization which can be observed and >> have been fixed along. A system property >> `jdk.net.urlDisableNormalizationOptimization=true|false` is introduced to >> revert to the old behaviour. >> A CSR will be logged to cover the addition of this new system property. >> >> I also have added a micro-benchmark for both URL and URI, taking inspiration >> from the micro-benchmark in https://github.com/openjdk/jdk/pull/33799. I >> have pasted the [results in a >> comment](https://github.com/openjdk/jdk/pull/33898#issuecomment-6922625690) >> in this PR. >> >> --------- >> - [x] I confirm that I make this contribution in accordance with the >> [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai). > > Daniel Fuchs has updated the pull request with a new target base due to a > merge or a rebase. The incremental webrev excludes the unrelated changes > brought in by the merge/rebase. The pull request contains 17 additional > commits since the last revision: > > - Merge branch 'master' into URL-normalize-8396940 > - Add some mix /../ and /./ tests to URL/Constructor.java; Test pass before > and after > - Fix copyright years > - Fix copyright years > - Review feedback: adding more cases to URI/Test.java > - Reduce formatting noise > - Merge branch 'master' into URL-normalize-8396940 > - Merge branch 'master' into URL-normalize-8396940 > - Merge branch 'master' into URL-normalize-8396940 > - Merge branch 'master' into URL-normalize-8396940 > - ... and 7 more: https://git.openjdk.org/jdk/compare/0de6bda5...da1412c9 Marked as reviewed by vyazici (Reviewer). test/micro/org/openjdk/bench/java/net/URLNormalize.java line 97: > 95: > 96: @Benchmark > 97: // this method does not normalize *Nit:* It took a while for me to understand the existing comment. You may consider adding some explanation: Suggestion: // Since the 2nd argument to `URL#new(URL context, String spec)` is // absolute, this method effectively does not exercise any normalization. ------------- PR Review: https://git.openjdk.org/jdk/pull/33898#pullrequestreview-6156534713 PR Review Comment: https://git.openjdk.org/jdk/pull/33898#discussion_r4774033794
