Skip to content

Commit a24104b

Browse files
committed
ElasticSearchIllegalStateException: stream marked as compressed, but no compressor found on transport layer, closes #2076.
1 parent 4f6e422 commit a24104b

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/main/java/org/elasticsearch/transport/netty/MessageChannelHandler.java

+5-2
Original file line numberDiff line numberDiff line change
@@ -218,13 +218,16 @@ private void process(ChannelHandlerContext ctx, Channel channel, ChannelBuffer b
218218
byte status = buffer.readByte();
219219
boolean isRequest = TransportStreams.statusIsRequest(status);
220220

221+
// we have additional bytes to read, outside of the header
222+
boolean hasBytesToRead = (size - (TransportStreams.HEADER_SIZE - 4)) != 0;
223+
221224
StreamInput wrappedStream;
222-
if (TransportStreams.statusIsCompress(status) && buffer.readable()) {
225+
if (TransportStreams.statusIsCompress(status) && hasBytesToRead && buffer.readable()) {
223226
Compressor compressor = CompressorFactory.compressor(buffer);
224227
if (compressor == null) {
225228
int maxToRead = Math.min(buffer.readableBytes(), 10);
226229
int offset = buffer.readerIndex();
227-
StringBuilder sb = new StringBuilder("stream marked as compressed, but no compressor found, first [").append(maxToRead).append("] content bytes out of [").append(buffer.readableBytes()).append("] are [");
230+
StringBuilder sb = new StringBuilder("stream marked as compressed, but no compressor found, first [").append(maxToRead).append("] content bytes out of [").append(buffer.readableBytes()).append("] readable bytes with message size [").append(size).append("] ").append("] are [");
228231
for (int i = 0; i < maxToRead; i++) {
229232
sb.append(buffer.getByte(offset + i)).append(",");
230233
}

0 commit comments

Comments
 (0)