From 743d3f7e4bac5b89888fc3227a98e355ba67619e Mon Sep 17 00:00:00 2001 From: Shay Banon Date: Sun, 1 Jul 2012 18:34:58 +0200 Subject: [PATCH] better failure message when failing to detect compressor on compressed transport stream --- .../transport/netty/MessageChannelHandler.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/elasticsearch/transport/netty/MessageChannelHandler.java b/src/main/java/org/elasticsearch/transport/netty/MessageChannelHandler.java index 67ce1a04244..629963c3dc1 100644 --- a/src/main/java/org/elasticsearch/transport/netty/MessageChannelHandler.java +++ b/src/main/java/org/elasticsearch/transport/netty/MessageChannelHandler.java @@ -222,7 +222,14 @@ public class MessageChannelHandler extends SimpleChannelUpstreamHandler { if (TransportStreams.statusIsCompress(status) && buffer.readable()) { Compressor compressor = CompressorFactory.compressor(buffer); if (compressor == null) { - throw new ElasticSearchIllegalStateException("stream marked as compressed, but no compressor found"); + 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 ["); + for (int i = 0; i < maxToRead; i++) { + sb.append(buffer.getByte(offset + i)).append(","); + } + sb.append("]"); + throw new ElasticSearchIllegalStateException(sb.toString()); } wrappedStream = CachedStreamInput.cachedHandlesCompressed(compressor, streamIn); } else {