RFR: 8263506: Make sun.net.httpserver.UnmodifiableHeaders unmodifiable
Julia Boes
jboes at openjdk.java.net
Mon Mar 22 15:32:49 UTC 2021
On Tue, 16 Mar 2021 14:30:39 GMT, Michael McMahon <michaelm at openjdk.org> wrote:
>> The fix makes the map in sun.net.httpserver.UnmodifiableHeaders unmodifiable by wrapping it in an unmodifiable view.
>
> src/jdk.httpserver/share/classes/sun/net/httpserver/UnmodifiableHeaders.java line 60:
>
>> 58: map.forEach((k, v) -> headers.add(k, v.get(0)));
>> 59: return headers.getFirst(key);
>> 60: }
>
> Should be possible to just return a reference to the first String in the map rather than instantiating a new Headers and populating it just for the duration of the call.
Headers normalizes the key before any get/getFirst, for example Headers line 131:
`public List<String> get(Object key) {
return map.get(normalize((String)key));
}`
I assume we want to maintain this behaviour, but there might be a better way than creating this local Headers?
-------------
PR: https://git.openjdk.java.net/jdk/pull/3032
More information about the net-dev
mailing list