Rename SnappyFramedEncoder/Decoder to SnappyFrameEncoder/Decoder
Related issue: #2766 Motivation: Forgot to rename them before the final release by mistake. Modifications: Rename the classes Result: Better naming
This commit is contained in:
parent
6a7fd374a2
commit
2af7a482d9
@ -15,7 +15,6 @@
|
|||||||
*/
|
*/
|
||||||
package io.netty.handler.codec.compression;
|
package io.netty.handler.codec.compression;
|
||||||
|
|
||||||
import static io.netty.handler.codec.compression.Snappy.validateChecksum;
|
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import io.netty.buffer.ByteBufUtil;
|
import io.netty.buffer.ByteBufUtil;
|
||||||
import io.netty.channel.ChannelHandlerContext;
|
import io.netty.channel.ChannelHandlerContext;
|
||||||
@ -24,6 +23,8 @@ import io.netty.handler.codec.ByteToMessageDecoder;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import static io.netty.handler.codec.compression.Snappy.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Uncompresses a {@link ByteBuf} encoded with the Snappy framing format.
|
* Uncompresses a {@link ByteBuf} encoded with the Snappy framing format.
|
||||||
*
|
*
|
||||||
@ -32,10 +33,10 @@ import java.util.List;
|
|||||||
* Note that by default, validation of the checksum header in each chunk is
|
* Note that by default, validation of the checksum header in each chunk is
|
||||||
* DISABLED for performance improvements. If performance is less of an issue,
|
* DISABLED for performance improvements. If performance is less of an issue,
|
||||||
* or if you would prefer the safety that checksum validation brings, please
|
* or if you would prefer the safety that checksum validation brings, please
|
||||||
* use the {@link #SnappyFramedDecoder(boolean)} constructor with the argument
|
* use the {@link #SnappyFrameDecoder(boolean)} constructor with the argument
|
||||||
* set to {@code true}.
|
* set to {@code true}.
|
||||||
*/
|
*/
|
||||||
public class SnappyFramedDecoder extends ByteToMessageDecoder {
|
public class SnappyFrameDecoder extends ByteToMessageDecoder {
|
||||||
|
|
||||||
private enum ChunkType {
|
private enum ChunkType {
|
||||||
STREAM_IDENTIFIER,
|
STREAM_IDENTIFIER,
|
||||||
@ -57,9 +58,9 @@ public class SnappyFramedDecoder extends ByteToMessageDecoder {
|
|||||||
/**
|
/**
|
||||||
* Creates a new snappy-framed decoder with validation of checksums
|
* Creates a new snappy-framed decoder with validation of checksums
|
||||||
* turned OFF. To turn checksum validation on, please use the alternate
|
* turned OFF. To turn checksum validation on, please use the alternate
|
||||||
* {@link #SnappyFramedDecoder(boolean)} constructor.
|
* {@link #SnappyFrameDecoder(boolean)} constructor.
|
||||||
*/
|
*/
|
||||||
public SnappyFramedDecoder() {
|
public SnappyFrameDecoder() {
|
||||||
this(false);
|
this(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,7 +73,7 @@ public class SnappyFramedDecoder extends ByteToMessageDecoder {
|
|||||||
* uncompressed data, and if the checksums do not match, a suitable
|
* uncompressed data, and if the checksums do not match, a suitable
|
||||||
* {@link DecompressionException} will be thrown
|
* {@link DecompressionException} will be thrown
|
||||||
*/
|
*/
|
||||||
public SnappyFramedDecoder(boolean validateChecksums) {
|
public SnappyFrameDecoder(boolean validateChecksums) {
|
||||||
this.validateChecksums = validateChecksums;
|
this.validateChecksums = validateChecksums;
|
||||||
}
|
}
|
||||||
|
|
@ -27,7 +27,7 @@ import static io.netty.handler.codec.compression.Snappy.*;
|
|||||||
*
|
*
|
||||||
* See http://code.google.com/p/snappy/source/browse/trunk/framing_format.txt
|
* See http://code.google.com/p/snappy/source/browse/trunk/framing_format.txt
|
||||||
*/
|
*/
|
||||||
public class SnappyFramedEncoder extends MessageToByteEncoder<ByteBuf> {
|
public class SnappyFrameEncoder extends MessageToByteEncoder<ByteBuf> {
|
||||||
/**
|
/**
|
||||||
* The minimum amount that we'll consider actually attempting to compress.
|
* The minimum amount that we'll consider actually attempting to compress.
|
||||||
* This value is preamble + the minimum length our Snappy service will
|
* This value is preamble + the minimum length our Snappy service will
|
@ -24,12 +24,12 @@ import org.junit.Test;
|
|||||||
import static io.netty.util.ReferenceCountUtil.releaseLater;
|
import static io.netty.util.ReferenceCountUtil.releaseLater;
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
public class SnappyFramedDecoderTest {
|
public class SnappyFrameDecoderTest {
|
||||||
private EmbeddedChannel channel;
|
private EmbeddedChannel channel;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void initChannel() {
|
public void initChannel() {
|
||||||
channel = new EmbeddedChannel(new SnappyFramedDecoder());
|
channel = new EmbeddedChannel(new SnappyFrameDecoder());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = DecompressionException.class)
|
@Test(expected = DecompressionException.class)
|
||||||
@ -133,7 +133,7 @@ public class SnappyFramedDecoderTest {
|
|||||||
|
|
||||||
@Test(expected = DecompressionException.class)
|
@Test(expected = DecompressionException.class)
|
||||||
public void testInvalidChecksumThrowsException() throws Exception {
|
public void testInvalidChecksumThrowsException() throws Exception {
|
||||||
EmbeddedChannel channel = new EmbeddedChannel(new SnappyFramedDecoder(true));
|
EmbeddedChannel channel = new EmbeddedChannel(new SnappyFrameDecoder(true));
|
||||||
|
|
||||||
// checksum here is presented as 0
|
// checksum here is presented as 0
|
||||||
ByteBuf in = Unpooled.wrappedBuffer(new byte[] {
|
ByteBuf in = Unpooled.wrappedBuffer(new byte[] {
|
||||||
@ -146,7 +146,7 @@ public class SnappyFramedDecoderTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testInvalidChecksumDoesNotThrowException() throws Exception {
|
public void testInvalidChecksumDoesNotThrowException() throws Exception {
|
||||||
EmbeddedChannel channel = new EmbeddedChannel(new SnappyFramedDecoder(true));
|
EmbeddedChannel channel = new EmbeddedChannel(new SnappyFrameDecoder(true));
|
||||||
|
|
||||||
// checksum here is presented as a282986f (little endian)
|
// checksum here is presented as a282986f (little endian)
|
||||||
ByteBuf in = Unpooled.wrappedBuffer(new byte[] {
|
ByteBuf in = Unpooled.wrappedBuffer(new byte[] {
|
@ -25,12 +25,12 @@ import org.junit.Test;
|
|||||||
import static io.netty.util.ReferenceCountUtil.*;
|
import static io.netty.util.ReferenceCountUtil.*;
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
public class SnappyFramedEncoderTest {
|
public class SnappyFrameEncoderTest {
|
||||||
private EmbeddedChannel channel;
|
private EmbeddedChannel channel;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
channel = new EmbeddedChannel(new SnappyFramedEncoder());
|
channel = new EmbeddedChannel(new SnappyFrameEncoder());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
@ -33,12 +33,12 @@ public class SnappyIntegrationTest extends IntegrationTest {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected EmbeddedChannel createEncoderEmbeddedChannel() {
|
protected EmbeddedChannel createEncoderEmbeddedChannel() {
|
||||||
return new EmbeddedChannel(new SnappyFramedEncoder());
|
return new EmbeddedChannel(new SnappyFrameEncoder());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected EmbeddedChannel createDecoderEmbeddedChannel() {
|
protected EmbeddedChannel createDecoderEmbeddedChannel() {
|
||||||
return new EmbeddedChannel(new SnappyFramedDecoder());
|
return new EmbeddedChannel(new SnappyFrameDecoder());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
Loading…
Reference in New Issue
Block a user