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. This pull request has now been integrated. Changeset: 81ca0ece Author: Daniel Fuchs <dfu...@openjdk.org> URL: https://git.openjdk.org/jdk/commit/81ca0ece2e69477b3d22a40c51e044d56e13b6e4 Stats: 22 lines in 3 files changed: 18 ins; 0 del; 4 mod 8334028: HttpClient: NPE thrown from assert statement Reviewed-by: jpai ------------- PR: https://git.openjdk.org/jdk/pull/19661