eclipse-ee4j / eclipse-ee4j/jersey

Client using Netty connector throws `NullPointerException` when non-empty response has no `Content-Length` and is not `chunked`

Open
#4,794 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
730
Forks
382
PR merge metrics
No merged PRs in 30d

Description

In cases when neither the `Content-Length` header is set nor the `Transfer-Encoding` header is set to `chunked`, the HTTP 1.1 specification prescribes that the content length be determined by when the server closes the connection (for responses with status codes that are allowed to provide content). https://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.4

However, the implementation of `channelRead0` in the `JerseyClientHandler` class in `jersey-netty-connector` instantiates (as its `nis` field) a `NettyInputStream` if and only if one of the above headers is set (and is nonzero, in the case of `Content-Length`), within the `if` block at https://github.com/eclipse-ee4j/jersey/blob/e129ced692959513a14a8d2d0e4e117aeaaee8ee/connectors/netty-connector/src/main/java/org/glassfish/jersey/netty/connector/JerseyClientHandler.java#L117-L118

This results in a `NullPointerException` at https://github.com/eclipse-ee4j/jersey/blob/e129ced692959513a14a8d2d0e4e117aeaaee8ee/connectors/netty-connector/src/main/java/org/glassfish/jersey/netty/connector/JerseyClientHandler.java#L141 when processing the first `HttpContent` objects representing the bodies (when present) of such responses.

I observed the error using `jersey-netty-connector` `2.32` and `netty-all` `4.1.29.Final`.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.