RFR: 8288109: HttpExchangeImpl.setAttribute does not allow null value after JDK-8266897

Daniel Fuchs dfuchs at openjdk.org
Fri Mar 31 13:07:14 UTC 2023


On Fri, 31 Mar 2023 10:35:27 GMT, Daniel Jeliński <djelinski at openjdk.org> wrote:

> Please review this fix for a regression in HttpExchange's setAttribute method.
> 
> The specification of setAttribute explicitly states that null values are allowed.
> JDK-8266897 changed `attributes` to `ConcurrentHashMap`, which does not allow null values.
> 
> This patch modifies `setAttribute` to remove the attribute from the map when null value is requested.
> 
> A new test was added to verify that setting attributes works as expected both for null and non-null values.
> 
> Tier1-3 clean.

That's a very elegant solution.

test/jdk/com/sun/net/httpserver/ExchangeAttributeTest.java line 86:

> 84: 
> 85:     static URI uri(HttpServer server, String path) {
> 86:         return URI.create("http://localhost:%s/%s".formatted(server.getAddress().getPort(), path));

Can we use the URIBuilder here instead?

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

Marked as reviewed by dfuchs (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/13264#pullrequestreview-1366901142
PR Review Comment: https://git.openjdk.org/jdk/pull/13264#discussion_r1154450874


More information about the net-dev mailing list