RFR: 7105350: HttpExchange's attributes are the same as HttpContext's attributes

Michael McMahon michaelm at openjdk.org
Tue Oct 7 09:28:25 UTC 2025


On Mon, 6 Oct 2025 16:09:40 GMT, Josiah Noel <duke at openjdk.org> wrote:

> Now ExchangeImpl will default to having a separate attribute map for the request duration.

Probably need a test for this as well

src/jdk.httpserver/share/classes/sun/net/httpserver/ExchangeImpl.java line 65:

> 63:     private static final boolean perExchangeAttributes =
> 64:         !System.getProperty("jdk.httpserver.attributes", "")
> 65:               .equals("context");

The property will have to be documented somewhere such as the jdk.httpserver module-info. But, I'm wondering if fairly obscure properties like this might be better off "buried" in the net.properties config file. I think there's a case for putting all such "compatibility" flags somewhere out of the way like that. If we were to do that, you would need to access the property using  `sun.net.NetProperties`. 

Any other views on this?

src/jdk.httpserver/share/classes/sun/net/httpserver/ExchangeImpl.java line 374:

> 372:             throw new NullPointerException("null name parameter");
> 373:         }
> 374:         return attributes.get(name);

Consider replacing this with `Objects.requireNonNull`

src/jdk.httpserver/share/classes/sun/net/httpserver/ExchangeImpl.java line 379:

> 377:     public void setAttribute (String name, Object value) {
> 378:         if (name == null) {
> 379:             throw new NullPointerException("null name parameter");

As above

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

PR Review: https://git.openjdk.org/jdk/pull/27652#pullrequestreview-3309209288
PR Review Comment: https://git.openjdk.org/jdk/pull/27652#discussion_r2409980226
PR Review Comment: https://git.openjdk.org/jdk/pull/27652#discussion_r2409985587
PR Review Comment: https://git.openjdk.org/jdk/pull/27652#discussion_r2409986147


More information about the net-dev mailing list