better failure message when failing to detect compressor on compressed transport stream
This commit is contained in:
parent
e5c89def42
commit
743d3f7e4b
|
@ -222,7 +222,14 @@ public class MessageChannelHandler extends SimpleChannelUpstreamHandler {
|
||||||
if (TransportStreams.statusIsCompress(status) && buffer.readable()) {
|
if (TransportStreams.statusIsCompress(status) && buffer.readable()) {
|
||||||
Compressor compressor = CompressorFactory.compressor(buffer);
|
Compressor compressor = CompressorFactory.compressor(buffer);
|
||||||
if (compressor == null) {
|
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);
|
wrappedStream = CachedStreamInput.cachedHandlesCompressed(compressor, streamIn);
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue