From 2ec932798f7e81a3c13182838b91babb096d238b Mon Sep 17 00:00:00 2001 From: Trustin Lee Date: Thu, 31 Jan 2013 23:39:57 +0900 Subject: [PATCH] Replace .readable() and .writable() to .isReadable() and .isWritable() --- .../io/netty/buffer/AbstractByteBufTest.java | 82 +++++++++---------- .../buffer/AbstractCompositeByteBufTest.java | 3 +- .../io/netty/buffer/ByteBufStreamTest.java | 7 +- .../java/io/netty/buffer/UnpooledTest.java | 28 +++---- .../codec/http/HttpContentDecoder.java | 2 +- .../codec/http/HttpContentEncoder.java | 4 +- .../codec/http/HttpObjectAggregator.java | 2 +- .../handler/codec/http/HttpObjectDecoder.java | 4 +- .../multipart/HttpPostRequestDecoder.java | 28 +++---- .../websocketx/WebSocket08FrameDecoder.java | 2 +- .../handler/codec/ByteToByteDecoder.java | 4 +- .../handler/codec/ByteToByteEncoder.java | 2 +- .../handler/codec/ByteToMessageDecoder.java | 4 +- .../codec/DelimiterBasedFrameDecoder.java | 2 +- .../netty/handler/codec/ReplayingDecoder.java | 6 +- .../handler/codec/ReplayingDecoderBuffer.java | 3 + .../compression/SnappyFramedDecoder.java | 4 +- .../compression/SnappyFramedEncoder.java | 2 +- .../marshalling/ChannelBufferByteInput.java | 5 +- .../ProtobufVarint32FrameDecoder.java | 5 +- .../codec/ReplayingDecoderBufferTest.java | 7 +- .../stream/ChunkedWriteHandlerTest.java | 6 +- .../sctp/SctpMessageCompletionHandler.java | 6 +- .../channel/DefaultChannelHandlerContext.java | 8 +- .../embedded/AbstractEmbeddedChannel.java | 6 +- .../channel/embedded/EmbeddedByteChannel.java | 4 +- .../channel/socket/aio/AioSocketChannel.java | 6 +- .../socket/nio/AbstractNioByteChannel.java | 6 +- 28 files changed, 125 insertions(+), 123 deletions(-) diff --git a/buffer/src/test/java/io/netty/buffer/AbstractByteBufTest.java b/buffer/src/test/java/io/netty/buffer/AbstractByteBufTest.java index 8f9cd26972..419934d350 100644 --- a/buffer/src/test/java/io/netty/buffer/AbstractByteBufTest.java +++ b/buffer/src/test/java/io/netty/buffer/AbstractByteBufTest.java @@ -473,7 +473,7 @@ public abstract class AbstractByteBufTest { @Test public void testSetZero() { buffer.clear(); - while (buffer.writable()) { + while (buffer.isWritable()) { buffer.writeByte((byte) 0xFF); } @@ -494,26 +494,26 @@ public abstract class AbstractByteBufTest { for (int i = 0; i < buffer.capacity(); i ++) { byte value = (byte) random.nextInt(); assertEquals(i, buffer.writerIndex()); - assertTrue(buffer.writable()); + assertTrue(buffer.isWritable()); buffer.writeByte(value); } assertEquals(0, buffer.readerIndex()); assertEquals(buffer.capacity(), buffer.writerIndex()); - assertFalse(buffer.writable()); + assertFalse(buffer.isWritable()); random.setSeed(seed); for (int i = 0; i < buffer.capacity(); i ++) { byte value = (byte) random.nextInt(); assertEquals(i, buffer.readerIndex()); - assertTrue(buffer.readable()); + assertTrue(buffer.isReadable()); assertEquals(value, buffer.readByte()); } assertEquals(buffer.capacity(), buffer.readerIndex()); assertEquals(buffer.capacity(), buffer.writerIndex()); - assertFalse(buffer.readable()); - assertFalse(buffer.writable()); + assertFalse(buffer.isReadable()); + assertFalse(buffer.isWritable()); } @Test @@ -522,26 +522,26 @@ public abstract class AbstractByteBufTest { for (int i = 0; i < buffer.capacity(); i ++) { byte value = (byte) random.nextInt(); assertEquals(i, buffer.writerIndex()); - assertTrue(buffer.writable()); + assertTrue(buffer.isWritable()); buffer.writeByte(value); } assertEquals(0, buffer.readerIndex()); assertEquals(buffer.capacity(), buffer.writerIndex()); - assertFalse(buffer.writable()); + assertFalse(buffer.isWritable()); random.setSeed(seed); for (int i = 0; i < buffer.capacity(); i ++) { int value = random.nextInt() & 0xFF; assertEquals(i, buffer.readerIndex()); - assertTrue(buffer.readable()); + assertTrue(buffer.isReadable()); assertEquals(value, buffer.readUnsignedByte()); } assertEquals(buffer.capacity(), buffer.readerIndex()); assertEquals(buffer.capacity(), buffer.writerIndex()); - assertFalse(buffer.readable()); - assertFalse(buffer.writable()); + assertFalse(buffer.isReadable()); + assertFalse(buffer.isWritable()); } @Test @@ -550,26 +550,26 @@ public abstract class AbstractByteBufTest { for (int i = 0; i < buffer.capacity(); i += 2) { short value = (short) random.nextInt(); assertEquals(i, buffer.writerIndex()); - assertTrue(buffer.writable()); + assertTrue(buffer.isWritable()); buffer.writeShort(value); } assertEquals(0, buffer.readerIndex()); assertEquals(buffer.capacity(), buffer.writerIndex()); - assertFalse(buffer.writable()); + assertFalse(buffer.isWritable()); random.setSeed(seed); for (int i = 0; i < buffer.capacity(); i += 2) { short value = (short) random.nextInt(); assertEquals(i, buffer.readerIndex()); - assertTrue(buffer.readable()); + assertTrue(buffer.isReadable()); assertEquals(value, buffer.readShort()); } assertEquals(buffer.capacity(), buffer.readerIndex()); assertEquals(buffer.capacity(), buffer.writerIndex()); - assertFalse(buffer.readable()); - assertFalse(buffer.writable()); + assertFalse(buffer.isReadable()); + assertFalse(buffer.isWritable()); } @Test @@ -578,26 +578,26 @@ public abstract class AbstractByteBufTest { for (int i = 0; i < buffer.capacity(); i += 2) { short value = (short) random.nextInt(); assertEquals(i, buffer.writerIndex()); - assertTrue(buffer.writable()); + assertTrue(buffer.isWritable()); buffer.writeShort(value); } assertEquals(0, buffer.readerIndex()); assertEquals(buffer.capacity(), buffer.writerIndex()); - assertFalse(buffer.writable()); + assertFalse(buffer.isWritable()); random.setSeed(seed); for (int i = 0; i < buffer.capacity(); i += 2) { int value = random.nextInt() & 0xFFFF; assertEquals(i, buffer.readerIndex()); - assertTrue(buffer.readable()); + assertTrue(buffer.isReadable()); assertEquals(value, buffer.readUnsignedShort()); } assertEquals(buffer.capacity(), buffer.readerIndex()); assertEquals(buffer.capacity(), buffer.writerIndex()); - assertFalse(buffer.readable()); - assertFalse(buffer.writable()); + assertFalse(buffer.isReadable()); + assertFalse(buffer.isWritable()); } @Test @@ -606,7 +606,7 @@ public abstract class AbstractByteBufTest { for (int i = 0; i < buffer.capacity() / 3 * 3; i += 3) { int value = random.nextInt(); assertEquals(i, buffer.writerIndex()); - assertTrue(buffer.writable()); + assertTrue(buffer.isWritable()); buffer.writeMedium(value); } @@ -618,7 +618,7 @@ public abstract class AbstractByteBufTest { for (int i = 0; i < buffer.capacity() / 3 * 3; i += 3) { int value = random.nextInt() << 8 >> 8; assertEquals(i, buffer.readerIndex()); - assertTrue(buffer.readable()); + assertTrue(buffer.isReadable()); assertEquals(value, buffer.readMedium()); } @@ -634,7 +634,7 @@ public abstract class AbstractByteBufTest { for (int i = 0; i < buffer.capacity() / 3 * 3; i += 3) { int value = random.nextInt() & 0x00FFFFFF; assertEquals(i, buffer.writerIndex()); - assertTrue(buffer.writable()); + assertTrue(buffer.isWritable()); buffer.writeMedium(value); } @@ -646,7 +646,7 @@ public abstract class AbstractByteBufTest { for (int i = 0; i < buffer.capacity() / 3 * 3; i += 3) { int value = random.nextInt() & 0x00FFFFFF; assertEquals(i, buffer.readerIndex()); - assertTrue(buffer.readable()); + assertTrue(buffer.isReadable()); assertEquals(value, buffer.readUnsignedMedium()); } @@ -662,26 +662,26 @@ public abstract class AbstractByteBufTest { for (int i = 0; i < buffer.capacity(); i += 4) { int value = random.nextInt(); assertEquals(i, buffer.writerIndex()); - assertTrue(buffer.writable()); + assertTrue(buffer.isWritable()); buffer.writeInt(value); } assertEquals(0, buffer.readerIndex()); assertEquals(buffer.capacity(), buffer.writerIndex()); - assertFalse(buffer.writable()); + assertFalse(buffer.isWritable()); random.setSeed(seed); for (int i = 0; i < buffer.capacity(); i += 4) { int value = random.nextInt(); assertEquals(i, buffer.readerIndex()); - assertTrue(buffer.readable()); + assertTrue(buffer.isReadable()); assertEquals(value, buffer.readInt()); } assertEquals(buffer.capacity(), buffer.readerIndex()); assertEquals(buffer.capacity(), buffer.writerIndex()); - assertFalse(buffer.readable()); - assertFalse(buffer.writable()); + assertFalse(buffer.isReadable()); + assertFalse(buffer.isWritable()); } @Test @@ -690,26 +690,26 @@ public abstract class AbstractByteBufTest { for (int i = 0; i < buffer.capacity(); i += 4) { int value = random.nextInt(); assertEquals(i, buffer.writerIndex()); - assertTrue(buffer.writable()); + assertTrue(buffer.isWritable()); buffer.writeInt(value); } assertEquals(0, buffer.readerIndex()); assertEquals(buffer.capacity(), buffer.writerIndex()); - assertFalse(buffer.writable()); + assertFalse(buffer.isWritable()); random.setSeed(seed); for (int i = 0; i < buffer.capacity(); i += 4) { long value = random.nextInt() & 0xFFFFFFFFL; assertEquals(i, buffer.readerIndex()); - assertTrue(buffer.readable()); + assertTrue(buffer.isReadable()); assertEquals(value, buffer.readUnsignedInt()); } assertEquals(buffer.capacity(), buffer.readerIndex()); assertEquals(buffer.capacity(), buffer.writerIndex()); - assertFalse(buffer.readable()); - assertFalse(buffer.writable()); + assertFalse(buffer.isReadable()); + assertFalse(buffer.isWritable()); } @Test @@ -718,26 +718,26 @@ public abstract class AbstractByteBufTest { for (int i = 0; i < buffer.capacity(); i += 8) { long value = random.nextLong(); assertEquals(i, buffer.writerIndex()); - assertTrue(buffer.writable()); + assertTrue(buffer.isWritable()); buffer.writeLong(value); } assertEquals(0, buffer.readerIndex()); assertEquals(buffer.capacity(), buffer.writerIndex()); - assertFalse(buffer.writable()); + assertFalse(buffer.isWritable()); random.setSeed(seed); for (int i = 0; i < buffer.capacity(); i += 8) { long value = random.nextLong(); assertEquals(i, buffer.readerIndex()); - assertTrue(buffer.readable()); + assertTrue(buffer.isReadable()); assertEquals(value, buffer.readLong()); } assertEquals(buffer.capacity(), buffer.readerIndex()); assertEquals(buffer.capacity(), buffer.writerIndex()); - assertFalse(buffer.readable()); - assertFalse(buffer.writable()); + assertFalse(buffer.isReadable()); + assertFalse(buffer.isWritable()); } @Test @@ -1254,7 +1254,7 @@ public abstract class AbstractByteBufTest { } buffer.clear(); - while (buffer.writable()) { + while (buffer.isWritable()) { buffer.writeByte((byte) 0xFF); } diff --git a/buffer/src/test/java/io/netty/buffer/AbstractCompositeByteBufTest.java b/buffer/src/test/java/io/netty/buffer/AbstractCompositeByteBufTest.java index 67bb41bb12..6e56f4a1e1 100644 --- a/buffer/src/test/java/io/netty/buffer/AbstractCompositeByteBufTest.java +++ b/buffer/src/test/java/io/netty/buffer/AbstractCompositeByteBufTest.java @@ -28,6 +28,7 @@ import static org.junit.Assert.*; /** * An abstract test class for composite channel buffers */ +@SuppressWarnings("ZeroLengthArrayAllocation") public abstract class AbstractCompositeByteBufTest extends AbstractByteBufTest { @@ -76,7 +77,7 @@ public abstract class AbstractCompositeByteBufTest extends assertEquals(length, buffer.capacity()); assertEquals(length, buffer.readableBytes()); - assertFalse(buffer.writable()); + assertFalse(buffer.isWritable()); buffer.writerIndex(0); return buffer; } diff --git a/buffer/src/test/java/io/netty/buffer/ByteBufStreamTest.java b/buffer/src/test/java/io/netty/buffer/ByteBufStreamTest.java index 29bb044207..c725f87751 100644 --- a/buffer/src/test/java/io/netty/buffer/ByteBufStreamTest.java +++ b/buffer/src/test/java/io/netty/buffer/ByteBufStreamTest.java @@ -15,17 +15,18 @@ */ package io.netty.buffer; -import static org.junit.Assert.*; +import org.junit.Test; import java.io.EOFException; import java.nio.charset.Charset; -import org.junit.Test; +import static org.junit.Assert.*; /** * Tests channel buffer streams */ +@SuppressWarnings("ZeroLengthArrayAllocation") public class ByteBufStreamTest { @Test @@ -93,7 +94,7 @@ public class ByteBufStreamTest { in.mark(Integer.MAX_VALUE); assertEquals(buf.writerIndex(), in.skip(Long.MAX_VALUE)); - assertFalse(buf.readable()); + assertFalse(buf.isReadable()); in.reset(); assertEquals(0, buf.readerIndex()); diff --git a/buffer/src/test/java/io/netty/buffer/UnpooledTest.java b/buffer/src/test/java/io/netty/buffer/UnpooledTest.java index 717e07a467..62f4c95402 100644 --- a/buffer/src/test/java/io/netty/buffer/UnpooledTest.java +++ b/buffer/src/test/java/io/netty/buffer/UnpooledTest.java @@ -409,7 +409,7 @@ public class UnpooledTest { ByteBuf buffer = copyInt(42); assertEquals(4, buffer.capacity()); assertEquals(42, buffer.readInt()); - assertFalse(buffer.readable()); + assertFalse(buffer.isReadable()); } @Test @@ -418,7 +418,7 @@ public class UnpooledTest { assertEquals(8, buffer.capacity()); assertEquals(1, buffer.readInt()); assertEquals(4, buffer.readInt()); - assertFalse(buffer.readable()); + assertFalse(buffer.isReadable()); assertEquals(0, Unpooled.copyInt(null).capacity()); assertEquals(0, Unpooled.copyInt(new int[0]).capacity()); @@ -429,7 +429,7 @@ public class UnpooledTest { ByteBuf buffer = copyShort(42); assertEquals(2, buffer.capacity()); assertEquals(42, buffer.readShort()); - assertFalse(buffer.readable()); + assertFalse(buffer.isReadable()); } @Test @@ -438,7 +438,7 @@ public class UnpooledTest { assertEquals(4, buffer.capacity()); assertEquals(1, buffer.readShort()); assertEquals(4, buffer.readShort()); - assertFalse(buffer.readable()); + assertFalse(buffer.isReadable()); assertEquals(0, Unpooled.copyShort((short[]) null).capacity()); assertEquals(0, Unpooled.copyShort(new short[0]).capacity()); @@ -450,7 +450,7 @@ public class UnpooledTest { assertEquals(4, buffer.capacity()); assertEquals(1, buffer.readShort()); assertEquals(4, buffer.readShort()); - assertFalse(buffer.readable()); + assertFalse(buffer.isReadable()); assertEquals(0, Unpooled.copyShort((int[]) null).capacity()); assertEquals(0, Unpooled.copyShort(new int[0]).capacity()); @@ -461,7 +461,7 @@ public class UnpooledTest { ByteBuf buffer = copyMedium(42); assertEquals(3, buffer.capacity()); assertEquals(42, buffer.readMedium()); - assertFalse(buffer.readable()); + assertFalse(buffer.isReadable()); } @Test @@ -470,7 +470,7 @@ public class UnpooledTest { assertEquals(6, buffer.capacity()); assertEquals(1, buffer.readMedium()); assertEquals(4, buffer.readMedium()); - assertFalse(buffer.readable()); + assertFalse(buffer.isReadable()); assertEquals(0, Unpooled.copyMedium(null).capacity()); assertEquals(0, Unpooled.copyMedium(new int[0]).capacity()); @@ -481,7 +481,7 @@ public class UnpooledTest { ByteBuf buffer = copyLong(42); assertEquals(8, buffer.capacity()); assertEquals(42, buffer.readLong()); - assertFalse(buffer.readable()); + assertFalse(buffer.isReadable()); } @Test @@ -490,7 +490,7 @@ public class UnpooledTest { assertEquals(16, buffer.capacity()); assertEquals(1, buffer.readLong()); assertEquals(4, buffer.readLong()); - assertFalse(buffer.readable()); + assertFalse(buffer.isReadable()); assertEquals(0, Unpooled.copyLong(null).capacity()); assertEquals(0, Unpooled.copyLong(new long[0]).capacity()); @@ -501,7 +501,7 @@ public class UnpooledTest { ByteBuf buffer = copyFloat(42); assertEquals(4, buffer.capacity()); assertEquals(42, buffer.readFloat(), 0.01); - assertFalse(buffer.readable()); + assertFalse(buffer.isReadable()); } @Test @@ -510,7 +510,7 @@ public class UnpooledTest { assertEquals(8, buffer.capacity()); assertEquals(1, buffer.readFloat(), 0.01); assertEquals(4, buffer.readFloat(), 0.01); - assertFalse(buffer.readable()); + assertFalse(buffer.isReadable()); assertEquals(0, Unpooled.copyFloat(null).capacity()); assertEquals(0, Unpooled.copyFloat(new float[0]).capacity()); @@ -521,7 +521,7 @@ public class UnpooledTest { ByteBuf buffer = copyDouble(42); assertEquals(8, buffer.capacity()); assertEquals(42, buffer.readDouble(), 0.01); - assertFalse(buffer.readable()); + assertFalse(buffer.isReadable()); } @Test @@ -530,7 +530,7 @@ public class UnpooledTest { assertEquals(16, buffer.capacity()); assertEquals(1, buffer.readDouble(), 0.01); assertEquals(4, buffer.readDouble(), 0.01); - assertFalse(buffer.readable()); + assertFalse(buffer.isReadable()); assertEquals(0, Unpooled.copyDouble(null).capacity()); assertEquals(0, Unpooled.copyDouble(new double[0]).capacity()); @@ -542,7 +542,7 @@ public class UnpooledTest { assertEquals(2, buffer.capacity()); assertTrue(buffer.readBoolean()); assertFalse(buffer.readBoolean()); - assertFalse(buffer.readable()); + assertFalse(buffer.isReadable()); assertEquals(0, Unpooled.copyBoolean(null).capacity()); assertEquals(0, Unpooled.copyBoolean(new boolean[0]).capacity()); diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/HttpContentDecoder.java b/codec-http/src/main/java/io/netty/handler/codec/http/HttpContentDecoder.java index 4e98b035ae..b50fe7a56f 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/HttpContentDecoder.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/HttpContentDecoder.java @@ -134,7 +134,7 @@ public abstract class HttpContentDecoder extends MessageToMessageDecoder // Generate an additional chunk if the decoder produced // the last product on closure, - if (lastProduct.readable()) { + if (lastProduct.isReadable()) { if (header == null) { return new Object[] { new DefaultHttpContent(newContent), new DefaultLastHttpContent(lastProduct)}; } else { diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/HttpContentEncoder.java b/codec-http/src/main/java/io/netty/handler/codec/http/HttpContentEncoder.java index b60f3c6f6e..d156491596 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/HttpContentEncoder.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/HttpContentEncoder.java @@ -85,7 +85,7 @@ public abstract class HttpContentEncoder extends MessageToMessageCodec { } // Append the content of the chunk - if (chunk.data().readable()) { + if (chunk.data().isReadable()) { content.addComponent(chunk.data()); content.writerIndex(content.writerIndex() + chunk.data().readableBytes()); } else { diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/HttpObjectDecoder.java b/codec-http/src/main/java/io/netty/handler/codec/http/HttpObjectDecoder.java index 2aab6bf900..8491d07981 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/HttpObjectDecoder.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/HttpObjectDecoder.java @@ -253,7 +253,7 @@ public abstract class HttpObjectDecoder extends ReplayingDecodersuper.actualReadableBytes()) }; * } else { @@ -362,7 +362,7 @@ public abstract class ReplayingDecoder extends ByteToMessageDecoder { public void channelInactive(ChannelHandlerContext ctx) throws Exception { replayable.terminate(); ByteBuf in = cumulation; - if (in.readable()) { + if (in.isReadable()) { callDecode(ctx, in); } @@ -390,7 +390,7 @@ public abstract class ReplayingDecoder extends ByteToMessageDecoder { ByteBuf in = cumulation; boolean decoded = false; - while (in.readable()) { + while (in.isReadable()) { try { int oldReaderIndex = checkpoint = in.readerIndex(); Object result = null; diff --git a/codec/src/main/java/io/netty/handler/codec/ReplayingDecoderBuffer.java b/codec/src/main/java/io/netty/handler/codec/ReplayingDecoderBuffer.java index 7a1cf22f0f..700519567d 100644 --- a/codec/src/main/java/io/netty/handler/codec/ReplayingDecoderBuffer.java +++ b/codec/src/main/java/io/netty/handler/codec/ReplayingDecoderBuffer.java @@ -143,6 +143,7 @@ final class ReplayingDecoderBuffer implements ByteBuf { } @Override + @Deprecated public ByteBuf ensureWritableBytes(int writableBytes) { throw new UnreplayableOperationException(); } @@ -395,6 +396,7 @@ final class ReplayingDecoderBuffer implements ByteBuf { } @Override + @Deprecated public boolean readable() { return isReadable(); } @@ -739,6 +741,7 @@ final class ReplayingDecoderBuffer implements ByteBuf { } @Override + @Deprecated public boolean writable() { return false; } diff --git a/codec/src/main/java/io/netty/handler/codec/compression/SnappyFramedDecoder.java b/codec/src/main/java/io/netty/handler/codec/compression/SnappyFramedDecoder.java index 6060692c9c..f5ddd97c18 100644 --- a/codec/src/main/java/io/netty/handler/codec/compression/SnappyFramedDecoder.java +++ b/codec/src/main/java/io/netty/handler/codec/compression/SnappyFramedDecoder.java @@ -70,11 +70,11 @@ public class SnappyFramedDecoder extends ByteToByteDecoder { @Override protected void decode(ChannelHandlerContext ctx, ByteBuf in, ByteBuf out) throws Exception { - if (!in.readable()) { + if (!in.isReadable()) { return; } - while (in.readable()) { + while (in.isReadable()) { if (chunkLength == 0) { if (in.readableBytes() < 3) { // We need to be at least able to read the chunk type identifier (one byte), diff --git a/codec/src/main/java/io/netty/handler/codec/compression/SnappyFramedEncoder.java b/codec/src/main/java/io/netty/handler/codec/compression/SnappyFramedEncoder.java index ea9eaea0a8..7f7e371307 100644 --- a/codec/src/main/java/io/netty/handler/codec/compression/SnappyFramedEncoder.java +++ b/codec/src/main/java/io/netty/handler/codec/compression/SnappyFramedEncoder.java @@ -47,7 +47,7 @@ public class SnappyFramedEncoder extends ByteToByteEncoder { @Override protected void encode(ChannelHandlerContext ctx, ByteBuf in, ByteBuf out) throws Exception { - if (!in.readable()) { + if (!in.isReadable()) { return; } diff --git a/codec/src/main/java/io/netty/handler/codec/marshalling/ChannelBufferByteInput.java b/codec/src/main/java/io/netty/handler/codec/marshalling/ChannelBufferByteInput.java index cccc380a45..104c056add 100644 --- a/codec/src/main/java/io/netty/handler/codec/marshalling/ChannelBufferByteInput.java +++ b/codec/src/main/java/io/netty/handler/codec/marshalling/ChannelBufferByteInput.java @@ -16,11 +16,10 @@ package io.netty.handler.codec.marshalling; import io.netty.buffer.ByteBuf; +import org.jboss.marshalling.ByteInput; import java.io.IOException; -import org.jboss.marshalling.ByteInput; - /** * {@link ByteInput} implementation which reads its data from a {@link ByteBuf} */ @@ -44,7 +43,7 @@ class ChannelBufferByteInput implements ByteInput { @Override public int read() throws IOException { - if (buffer.readable()) { + if (buffer.isReadable()) { return buffer.readByte() & 0xff; } return -1; diff --git a/codec/src/main/java/io/netty/handler/codec/protobuf/ProtobufVarint32FrameDecoder.java b/codec/src/main/java/io/netty/handler/codec/protobuf/ProtobufVarint32FrameDecoder.java index 48e63237ed..02f01c2020 100644 --- a/codec/src/main/java/io/netty/handler/codec/protobuf/ProtobufVarint32FrameDecoder.java +++ b/codec/src/main/java/io/netty/handler/codec/protobuf/ProtobufVarint32FrameDecoder.java @@ -15,13 +15,12 @@ */ package io.netty.handler.codec.protobuf; +import com.google.protobuf.CodedInputStream; import io.netty.buffer.ByteBuf; import io.netty.channel.ChannelHandlerContext; import io.netty.handler.codec.ByteToMessageDecoder; import io.netty.handler.codec.CorruptedFrameException; -import com.google.protobuf.CodedInputStream; - /** * A decoder that splits the received {@link ByteBuf}s dynamically by the * value of the Google Protocol Buffers @@ -47,7 +46,7 @@ public class ProtobufVarint32FrameDecoder extends ByteToMessageDecoder { in.markReaderIndex(); final byte[] buf = new byte[5]; for (int i = 0; i < buf.length; i ++) { - if (!in.readable()) { + if (!in.isReadable()) { in.resetReaderIndex(); return null; } diff --git a/codec/src/test/java/io/netty/handler/codec/ReplayingDecoderBufferTest.java b/codec/src/test/java/io/netty/handler/codec/ReplayingDecoderBufferTest.java index 2c91cd82bf..22afda9208 100644 --- a/codec/src/test/java/io/netty/handler/codec/ReplayingDecoderBufferTest.java +++ b/codec/src/test/java/io/netty/handler/codec/ReplayingDecoderBufferTest.java @@ -15,15 +15,14 @@ */ package io.netty.handler.codec; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; import io.netty.util.CharsetUtil; import io.netty.util.internal.Signal; - import org.junit.Test; +import static org.junit.Assert.*; + public class ReplayingDecoderBufferTest { /** @@ -76,7 +75,7 @@ public class ReplayingDecoderBufferTest { @Test public void testGetBoolean() { ByteBuf buf = Unpooled.buffer(10); - while(buf.writable()) { + while(buf.isWritable()) { buf.writeBoolean(true); } ReplayingDecoderBuffer buffer = new ReplayingDecoderBuffer(buf); diff --git a/handler/src/test/java/io/netty/handler/stream/ChunkedWriteHandlerTest.java b/handler/src/test/java/io/netty/handler/stream/ChunkedWriteHandlerTest.java index f5718b54d3..7447d71ec5 100644 --- a/handler/src/test/java/io/netty/handler/stream/ChunkedWriteHandlerTest.java +++ b/handler/src/test/java/io/netty/handler/stream/ChunkedWriteHandlerTest.java @@ -15,7 +15,6 @@ */ package io.netty.handler.stream; -import static org.junit.Assert.*; import io.netty.buffer.ByteBuf; import io.netty.buffer.MessageBuf; import io.netty.buffer.Unpooled; @@ -24,6 +23,7 @@ import io.netty.channel.ChannelFutureListener; import io.netty.channel.embedded.EmbeddedByteChannel; import io.netty.channel.embedded.EmbeddedMessageChannel; import io.netty.util.CharsetUtil; +import org.junit.Test; import java.io.ByteArrayInputStream; import java.io.File; @@ -32,7 +32,7 @@ import java.io.IOException; import java.nio.channels.Channels; import java.util.concurrent.atomic.AtomicBoolean; -import org.junit.Test; +import static org.junit.Assert.*; public class ChunkedWriteHandlerTest { private static final byte[] BYTES = new byte[1024 * 64]; @@ -203,7 +203,7 @@ public class ChunkedWriteHandlerTest { if (buffer == null) { break; } - while (buffer.readable()) { + while (buffer.isReadable()) { assertEquals(BYTES[i++], buffer.readByte()); read++; if (i == BYTES.length) { diff --git a/transport-sctp/src/main/java/io/netty/handler/codec/sctp/SctpMessageCompletionHandler.java b/transport-sctp/src/main/java/io/netty/handler/codec/sctp/SctpMessageCompletionHandler.java index 0e618569e0..9b0b803d21 100644 --- a/transport-sctp/src/main/java/io/netty/handler/codec/sctp/SctpMessageCompletionHandler.java +++ b/transport-sctp/src/main/java/io/netty/handler/codec/sctp/SctpMessageCompletionHandler.java @@ -66,13 +66,13 @@ public class SctpMessageCompletionHandler extends ChannelInboundMessageHandlerAd frag = Unpooled.EMPTY_BUFFER; } - if (isComplete && !frag.readable()) { + if (isComplete && !frag.isReadable()) { //data chunk is not fragmented handleAssembledMessage(ctx, msg); - } else if (!isComplete && frag.readable()) { + } else if (!isComplete && frag.isReadable()) { //more message to complete fragments.put(streamIdentifier, Unpooled.wrappedBuffer(frag, byteBuf)); - } else if (isComplete && frag.readable()) { + } else if (isComplete && frag.isReadable()) { //last message to complete fragments.remove(streamIdentifier); SctpMessage assembledMsg = new SctpMessage( diff --git a/transport/src/main/java/io/netty/channel/DefaultChannelHandlerContext.java b/transport/src/main/java/io/netty/channel/DefaultChannelHandlerContext.java index 86cc780d7e..33f89b74ea 100755 --- a/transport/src/main/java/io/netty/channel/DefaultChannelHandlerContext.java +++ b/transport/src/main/java/io/netty/channel/DefaultChannelHandlerContext.java @@ -198,7 +198,7 @@ final class DefaultChannelHandlerContext extends DefaultAttributeMap implements } void forwardBufferContent() { - if (hasOutboundByteBuffer() && outboundByteBuffer().readable()) { + if (hasOutboundByteBuffer() && outboundByteBuffer().isReadable()) { nextOutboundByteBuffer().writeBytes(outboundByteBuffer()); flush(); } @@ -207,7 +207,7 @@ final class DefaultChannelHandlerContext extends DefaultAttributeMap implements flush(); } } - if (hasInboundByteBuffer() && inboundByteBuffer().readable()) { + if (hasInboundByteBuffer() && inboundByteBuffer().isReadable()) { nextInboundByteBuffer().writeBytes(inboundByteBuffer()); fireInboundBufferUpdated(); } @@ -1833,7 +1833,7 @@ final class DefaultChannelHandlerContext extends DefaultAttributeMap implements } private void fill() { - if (!byteBuf.readable()) { + if (!byteBuf.isReadable()) { return; } @@ -1851,7 +1851,7 @@ final class DefaultChannelHandlerContext extends DefaultAttributeMap implements } private void flush(ByteBuf out) { - while (out.writable()) { + while (out.isWritable()) { ByteBuf data = exchangeBuf.peek(); if (data == null) { break; diff --git a/transport/src/main/java/io/netty/channel/embedded/AbstractEmbeddedChannel.java b/transport/src/main/java/io/netty/channel/embedded/AbstractEmbeddedChannel.java index 271dbc4c9a..81bd9eb084 100755 --- a/transport/src/main/java/io/netty/channel/embedded/AbstractEmbeddedChannel.java +++ b/transport/src/main/java/io/netty/channel/embedded/AbstractEmbeddedChannel.java @@ -135,7 +135,7 @@ public abstract class AbstractEmbeddedChannel extends AbstractChannel { * Return received data from this {@link Channel} */ public Object readInbound() { - if (lastInboundByteBuffer.readable()) { + if (lastInboundByteBuffer.isReadable()) { try { return lastInboundByteBuffer.readBytes(lastInboundByteBuffer.readableBytes()); } finally { @@ -275,7 +275,7 @@ public abstract class AbstractEmbeddedChannel extends AbstractChannel { close(); runPendingTasks(); checkException(); - return lastInboundByteBuffer().readable() || !lastInboundMessageBuffer().isEmpty() || + return lastInboundByteBuffer().isReadable() || !lastInboundMessageBuffer().isEmpty() || hasReadableOutboundBuffer(); } @@ -291,7 +291,7 @@ public abstract class AbstractEmbeddedChannel extends AbstractChannel { pipeline().fireInboundBufferUpdated(); runPendingTasks(); checkException(); - return lastInboundByteBuffer().readable() || !lastInboundMessageBuffer().isEmpty(); + return lastInboundByteBuffer().isReadable() || !lastInboundMessageBuffer().isEmpty(); } /** diff --git a/transport/src/main/java/io/netty/channel/embedded/EmbeddedByteChannel.java b/transport/src/main/java/io/netty/channel/embedded/EmbeddedByteChannel.java index 15de0062d3..421a3b30ca 100644 --- a/transport/src/main/java/io/netty/channel/embedded/EmbeddedByteChannel.java +++ b/transport/src/main/java/io/netty/channel/embedded/EmbeddedByteChannel.java @@ -55,7 +55,7 @@ public class EmbeddedByteChannel extends AbstractEmbeddedChannel { @Override public ByteBuf readOutbound() { - if (!lastOutboundBuffer().readable()) { + if (!lastOutboundBuffer().isReadable()) { return null; } try { @@ -72,7 +72,7 @@ public class EmbeddedByteChannel extends AbstractEmbeddedChannel { @Override protected boolean hasReadableOutboundBuffer() { - return lastOutboundBuffer().readable(); + return lastOutboundBuffer().isReadable(); } @Override diff --git a/transport/src/main/java/io/netty/channel/socket/aio/AioSocketChannel.java b/transport/src/main/java/io/netty/channel/socket/aio/AioSocketChannel.java index bf133b2e3d..f039d06096 100755 --- a/transport/src/main/java/io/netty/channel/socket/aio/AioSocketChannel.java +++ b/transport/src/main/java/io/netty/channel/socket/aio/AioSocketChannel.java @@ -239,7 +239,7 @@ public class AioSocketChannel extends AbstractAioChannel implements SocketChanne inDoFlushByteBuffer = true; try { - if (buf.readable()) { + if (buf.isReadable()) { for (;;) { if (buf.isFreed()) { break; @@ -273,7 +273,7 @@ public class AioSocketChannel extends AbstractAioChannel implements SocketChanne // JDK performed the write operation immediately and notified the handler. // We know this because we set asyncWriteInProgress to false in the handler. - if (!buf.readable()) { + if (!buf.isReadable()) { // There's nothing left in the buffer. No need to retry writing. break; } @@ -386,7 +386,7 @@ public class AioSocketChannel extends AbstractAioChannel implements SocketChanne return; } - if (buf.readable()) { + if (buf.isReadable()) { channel.unsafe().flushNow(); } } diff --git a/transport/src/main/java/io/netty/channel/socket/nio/AbstractNioByteChannel.java b/transport/src/main/java/io/netty/channel/socket/nio/AbstractNioByteChannel.java index 0cb75db9bc..890d68a41b 100755 --- a/transport/src/main/java/io/netty/channel/socket/nio/AbstractNioByteChannel.java +++ b/transport/src/main/java/io/netty/channel/socket/nio/AbstractNioByteChannel.java @@ -86,7 +86,7 @@ public abstract class AbstractNioByteChannel extends AbstractNioChannel { if (read) { read = false; pipeline.fireInboundBufferUpdated(); - if (!byteBuf.writable()) { + if (!byteBuf.isWritable()) { throw new IllegalStateException( "an inbound handler whose buffer is full must consume at " + "least one byte."); @@ -130,7 +130,7 @@ public abstract class AbstractNioByteChannel extends AbstractNioChannel { @Override protected void doFlushByteBuffer(ByteBuf buf) throws Exception { - if (!buf.readable()) { + if (!buf.isReadable()) { // Reset reader/writerIndex to 0 if the buffer is empty. buf.clear(); return; @@ -141,7 +141,7 @@ public abstract class AbstractNioByteChannel extends AbstractNioChannel { if (localFlushedAmount > 0) { break; } - if (!buf.readable()) { + if (!buf.isReadable()) { // Reset reader/writerIndex to 0 if the buffer is empty. buf.clear(); break;