From 6cd9b92f95374b70eff8e60e4c9f1fd66a6e2e91 Mon Sep 17 00:00:00 2001 From: Shay Banon Date: Sun, 1 Jul 2012 20:26:04 +0200 Subject: [PATCH] ElasticSearchIllegalStateException: stream marked as compressed, but no compressor found on transport layer, closes #2076. --- .../transport/netty/MessageChannelHandler.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/elasticsearch/transport/netty/MessageChannelHandler.java b/src/main/java/org/elasticsearch/transport/netty/MessageChannelHandler.java index 629963c3dc1..8ba1bb8b52c 100644 --- a/src/main/java/org/elasticsearch/transport/netty/MessageChannelHandler.java +++ b/src/main/java/org/elasticsearch/transport/netty/MessageChannelHandler.java @@ -218,13 +218,16 @@ public class MessageChannelHandler extends SimpleChannelUpstreamHandler { byte status = buffer.readByte(); boolean isRequest = TransportStreams.statusIsRequest(status); + // we have additional bytes to read, outside of the header + boolean hasBytesToRead = (size - (TransportStreams.HEADER_SIZE - 4)) != 0; + StreamInput wrappedStream; - if (TransportStreams.statusIsCompress(status) && buffer.readable()) { + if (TransportStreams.statusIsCompress(status) && hasBytesToRead && buffer.readable()) { Compressor compressor = CompressorFactory.compressor(buffer); if (compressor == null) { int maxToRead = Math.min(buffer.readableBytes(), 10); int offset = buffer.readerIndex(); - 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 ["); + 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 ["); for (int i = 0; i < maxToRead; i++) { sb.append(buffer.getByte(offset + i)).append(","); }