Browse Source

properly support global transport compression with new bytes transport request optimization

Shay Banon 12 years ago
parent
commit
0469cca4be

+ 3 - 1
src/main/java/org/elasticsearch/transport/netty/NettyTransport.java

@@ -542,7 +542,9 @@ public class NettyTransport extends AbstractLifecycleComponent<Transport> implem
         BytesStreamOutput bStream = new BytesStreamOutput();
         BytesStreamOutput bStream = new BytesStreamOutput();
         bStream.skip(NettyHeader.HEADER_SIZE);
         bStream.skip(NettyHeader.HEADER_SIZE);
         StreamOutput stream = bStream;
         StreamOutput stream = bStream;
-        if (options.compress()) {
+        // only compress if asked, and, the request is not bytes, since then only
+        // the header part is compressed, and the "body" can't be extracted as compressed
+        if (options.compress() && (!(request instanceof BytesTransportRequest))) {
             status = TransportStatus.setCompress(status);
             status = TransportStatus.setCompress(status);
             stream = CompressorFactory.defaultCompressor().streamOutput(stream);
             stream = CompressorFactory.defaultCompressor().streamOutput(stream);
         }
         }