IllegalStateException when sending an Elasticsearch request with a content-length

Description

When content-length is defined, the encoder is a LengthDelimitedEncoder, and even a 0-length write will trigger an exception when the content length has been reached.
The current code allows 0-length writes, and we should protect ourselves against that.

Note: this problem only affects 5.8.0.CR1, but was only witnessed while working on HSEARCH-2849. It is possible that the bug never actually happens in 5.8.0.CR1 because makes it content-length definition rarer.

Environment

None

Assignee

Yoann Rodière

Reporter

Yoann Rodière

Labels

None

Suitable for new contributors

None

Feedback Requested

None

Components

Fix versions

Affects versions

Priority

Major
Configure