On Wed, 7 Apr 2021 13:28:32 GMT, Julia Boes <jb...@openjdk.org> wrote:
>> The fix makes the map in sun.net.httpserver.UnmodifiableHeaders unmodifiable >> by wrapping it in an unmodifiable view. > > Julia Boes 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 12 additional commits since > the last revision: > > - Merge branch 'master' into 8263506 > - fix get method and constructor, add tests > - Account for null values and change type in constructor > - Merge branch 'master' into 8263506 > - Merge branch 'master' into 8263506 > - move constructor call in ExchangeImpl and fix indentation > - wrap List<String> with unmodifiable map and update test > - remove map wrapping > - fix imports > - Merge branch 'master' into 8263506 > - ... and 2 more: > https://git.openjdk.java.net/jdk/compare/eed6b83a...4f2247fc src/jdk.httpserver/share/classes/sun/net/httpserver/UnmodifiableHeaders.java line 42: > 40: h.forEach((k, v) -> unmodHeaders.put(k, > Collections.unmodifiableList(v))); > 41: this.map = Collections.unmodifiableMap(unmodHeaders); > 42: this.headers = h; Now that we have `unmodHeaders` we could simply keep it: this.headers = unmodHeaders; we no longer need to keep the original `headers` around. src/jdk.httpserver/share/classes/sun/net/httpserver/UnmodifiableHeaders.java line 56: > 54: List<String> l = headers.get(key); > 55: return l == null ? null : Collections.unmodifiableList(l); > 56: } You could simply return `map.get(key)` here - since map is an unmodifiable map wrapping `unmodHeaders`; Or even `headers.get(key)` if `headers` is `unmodHeaders` as suggested below... ------------- PR: https://git.openjdk.java.net/jdk/pull/3032