On Tue, 6 Apr 2021 13:10:59 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 10 additional commits since 
> the last revision:
> 
>  - 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
>  - fix UnmodifiableHeaders impl
>  - add initial test

src/jdk.httpserver/share/classes/sun/net/httpserver/UnmodifiableHeaders.java 
line 41:

> 39:         var unmodHeaders = new Headers();
> 40:         h.forEach((k, v) -> {
> 41:                 List<String> l = v == null ? List.of() : 
> Collections.unmodifiableList(v);

If v is `null` it should be mapped to `null` - not to `List.of()`, to preserve 
map equality.

test/jdk/com/sun/net/httpserver/UnmodifiableHeadersTest.java line 89:

> 87:     }
> 88: 
> 89:     static void assertUnmodifiableList(Headers headers) {

Maybe the test should be extended to double check that:

var headers = ...
var unmodifiableHeaders = new UnmodifiableHeaders(headers);
assertEquals(unmodifiableHeaders, headers);
assertEquals(unmodifiableHeaders.hashCode(), headers.hashCode());

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

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

Reply via email to