JavaDoc: NPE in java.net.http.HttpHeaders

Alan Bateman alan.bateman at oracle.com
Tue May 6 06:03:48 UTC 2025


On 05/05/2025 21:05, Steffen Nießing wrote:
> Hello,
>
> recently I've discovered that the JavaDoc of the instance methods of 
> java.net.http.HttpHeaders lacks the throws declarations for 
> NullPointerExceptions. The static creator method `of` contains such a 
> declaration. So the snippet `HttpHeaders.of(null, null)` is documented 
> to throw an NPE, while the snippet `HttpHeaders.of(Map.of(), (k, v) -> 
> true).firstValue(null)` currently isn't.
>
> I'd propose to add the missing JavaDoc throws declarations to the 
> #allValues(String), #firstValueAsLong(String) and #firstValue(String) 
> methods as they all can throw an NPE through `requireNonNull(name);` 
> in the allValues method.
>
> If there's interest in this change, I'd appreciate if anyone would 
> like to sponsor me on this one.
>
Can you bring this to net-dev to discuss? net-dev is where the 
networking API and the HTTP client are maintained.

-Alan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/core-libs-dev/attachments/20250506/71768e83/attachment.htm>


More information about the core-libs-dev mailing list