Skip to content

Commit 4f6e422

Browse files
committed
better failure message when failing to detect compressor on compressed transport stream
1 parent c6f57aa commit 4f6e422

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,14 @@ private void process(ChannelHandlerContext ctx, Channel channel, ChannelBuffer b
222222
if (TransportStreams.statusIsCompress(status) && buffer.readable()) {
223223
Compressor compressor = CompressorFactory.compressor(buffer);
224224
if (compressor == null) {
225-
throw new ElasticSearchIllegalStateException("stream marked as compressed, but no compressor found");
225+
int maxToRead = Math.min(buffer.readableBytes(), 10);
226+
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 [");
228+
for (int i = 0; i < maxToRead; i++) {
229+
sb.append(buffer.getByte(offset + i)).append(",");
230+
}
231+
sb.append("]");
232+
throw new ElasticSearchIllegalStateException(sb.toString());
226233
}
227234
wrappedStream = CachedStreamInput.cachedHandlesCompressed(compressor, streamIn);
228235
} else {

0 commit comments

Comments
 (0)