On Tue, 11 Jun 2024 14:40:02 GMT, Daniel Fuchs <dfu...@openjdk.org> wrote:

> The `jdk.internal.http.common.Utils` class exposes methods that work on lists 
> or arrays of byte buffers, and tell whether or how much remaining data is 
> present in the buffers in the list/array. These methods currently throw 
> `NullPointerException` if the given list/buffer is null.
> 
> This is not in itself an issue, except that these methods are often called in 
> debug statements, or in assert statements, where `null` could be passed and 
> `NullPointerException` are not expected and should not be thrown.
> 
> One such assert statement in `ResponseSubscribers` hid a bug where a 
> `NullPointerException` that  should have been unconditionally thrown was in 
> fact only thrown if asserts were enabled. The test that was supposed to 
> verify that NPEs are thrown was passing because assert are always enabled by 
> default when running tests.
> 
> The proposed change modifies these Utils methods to allow null parameter, 
> returning false or 0 when a null list or array is given. It also fixes the 
> code in ResponseSunscribers that was throwing from the assert to 
> unconditionally check for nulls before the assertion.

Marked as reviewed by jpai (Reviewer).

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

PR Review: https://git.openjdk.org/jdk/pull/19661#pullrequestreview-2112135753

Reply via email to