diff --git a/.gitignore b/.gitignore
index a490df6613..00ec325140 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,7 +5,7 @@
*.ipr
*.iws
.geany
-*/target
+/target
*/target
/reports
*/reports
diff --git a/buffer/src/main/java/io/netty/buffer/AbstractChannelBuffer.java b/buffer/src/main/java/io/netty/buffer/AbstractChannelBuffer.java
index 0350163627..76789fae35 100644
--- a/buffer/src/main/java/io/netty/buffer/AbstractChannelBuffer.java
+++ b/buffer/src/main/java/io/netty/buffer/AbstractChannelBuffer.java
@@ -135,7 +135,7 @@ public abstract class AbstractChannelBuffer implements ChannelBuffer {
@Override
public boolean getBoolean(int index) {
- return (getByte(index) == 1);
+ return getByte(index) != 0;
}
@Override
@@ -278,7 +278,7 @@ public abstract class AbstractChannelBuffer implements ChannelBuffer {
@Override
public boolean readBoolean() {
- return (readByte() == 1);
+ return readByte() != 0;
}
@Override
diff --git a/buffer/src/main/java/io/netty/buffer/BigEndianHeapChannelBuffer.java b/buffer/src/main/java/io/netty/buffer/BigEndianHeapChannelBuffer.java
index 4ba94b8609..854749987f 100644
--- a/buffer/src/main/java/io/netty/buffer/BigEndianHeapChannelBuffer.java
+++ b/buffer/src/main/java/io/netty/buffer/BigEndianHeapChannelBuffer.java
@@ -59,67 +59,67 @@ public class BigEndianHeapChannelBuffer extends HeapChannelBuffer {
@Override
public short getShort(int index) {
- return (short) (array[index] << 8 | array[index+1] & 0xFF);
+ return (short) (array[index] << 8 | array[index + 1] & 0xFF);
}
@Override
public int getUnsignedMedium(int index) {
- return (array[index] & 0xff) << 16 |
- (array[index+1] & 0xff) << 8 |
- (array[index+2] & 0xff) << 0;
+ return (array[index] & 0xff) << 16 |
+ (array[index + 1] & 0xff) << 8 |
+ (array[index + 2] & 0xff) << 0;
}
@Override
public int getInt(int index) {
- return (array[index] & 0xff) << 24 |
- (array[index+1] & 0xff) << 16 |
- (array[index+2] & 0xff) << 8 |
- (array[index+3] & 0xff) << 0;
+ return (array[index] & 0xff) << 24 |
+ (array[index + 1] & 0xff) << 16 |
+ (array[index + 2] & 0xff) << 8 |
+ (array[index + 3] & 0xff) << 0;
}
@Override
public long getLong(int index) {
- return ((long) array[index] & 0xff) << 56 |
- ((long) array[index+1] & 0xff) << 48 |
- ((long) array[index+2] & 0xff) << 40 |
- ((long) array[index+3] & 0xff) << 32 |
- ((long) array[index+4] & 0xff) << 24 |
- ((long) array[index+5] & 0xff) << 16 |
- ((long) array[index+6] & 0xff) << 8 |
- ((long) array[index+7] & 0xff) << 0;
+ return ((long) array[index] & 0xff) << 56 |
+ ((long) array[index + 1] & 0xff) << 48 |
+ ((long) array[index + 2] & 0xff) << 40 |
+ ((long) array[index + 3] & 0xff) << 32 |
+ ((long) array[index + 4] & 0xff) << 24 |
+ ((long) array[index + 5] & 0xff) << 16 |
+ ((long) array[index + 6] & 0xff) << 8 |
+ ((long) array[index + 7] & 0xff) << 0;
}
@Override
public void setShort(int index, int value) {
- array[index ] = (byte) (value >>> 8);
- array[index+1] = (byte) (value >>> 0);
+ array[index] = (byte) (value >>> 8);
+ array[index + 1] = (byte) (value >>> 0);
}
@Override
public void setMedium(int index, int value) {
- array[index ] = (byte) (value >>> 16);
- array[index+1] = (byte) (value >>> 8);
- array[index+2] = (byte) (value >>> 0);
+ array[index] = (byte) (value >>> 16);
+ array[index + 1] = (byte) (value >>> 8);
+ array[index + 2] = (byte) (value >>> 0);
}
@Override
public void setInt(int index, int value) {
- array[index ] = (byte) (value >>> 24);
- array[index+1] = (byte) (value >>> 16);
- array[index+2] = (byte) (value >>> 8);
- array[index+3] = (byte) (value >>> 0);
+ array[index] = (byte) (value >>> 24);
+ array[index + 1] = (byte) (value >>> 16);
+ array[index + 2] = (byte) (value >>> 8);
+ array[index + 3] = (byte) (value >>> 0);
}
@Override
public void setLong(int index, long value) {
- array[index ] = (byte) (value >>> 56);
- array[index+1] = (byte) (value >>> 48);
- array[index+2] = (byte) (value >>> 40);
- array[index+3] = (byte) (value >>> 32);
- array[index+4] = (byte) (value >>> 24);
- array[index+5] = (byte) (value >>> 16);
- array[index+6] = (byte) (value >>> 8);
- array[index+7] = (byte) (value >>> 0);
+ array[index] = (byte) (value >>> 56);
+ array[index + 1] = (byte) (value >>> 48);
+ array[index + 2] = (byte) (value >>> 40);
+ array[index + 3] = (byte) (value >>> 32);
+ array[index + 4] = (byte) (value >>> 24);
+ array[index + 5] = (byte) (value >>> 16);
+ array[index + 6] = (byte) (value >>> 8);
+ array[index + 7] = (byte) (value >>> 0);
}
@Override
diff --git a/buffer/src/main/java/io/netty/buffer/ByteBufferBackedChannelBuffer.java b/buffer/src/main/java/io/netty/buffer/ByteBufferBackedChannelBuffer.java
index 80008af030..9e99c206e3 100644
--- a/buffer/src/main/java/io/netty/buffer/ByteBufferBackedChannelBuffer.java
+++ b/buffer/src/main/java/io/netty/buffer/ByteBufferBackedChannelBuffer.java
@@ -107,9 +107,9 @@ public class ByteBufferBackedChannelBuffer extends AbstractChannelBuffer {
@Override
public int getUnsignedMedium(int index) {
- return (getByte(index) & 0xff) << 16 |
- (getByte(index+1) & 0xff) << 8 |
- (getByte(index+2) & 0xff) << 0;
+ return (getByte(index) & 0xff) << 16 |
+ (getByte(index + 1) & 0xff) << 8 |
+ (getByte(index + 2) & 0xff) << 0;
}
@Override
@@ -172,9 +172,9 @@ public class ByteBufferBackedChannelBuffer extends AbstractChannelBuffer {
@Override
public void setMedium(int index, int value) {
- setByte(index, (byte) (value >>> 16));
- setByte(index+1, (byte) (value >>> 8));
- setByte(index+2, (byte) (value >>> 0));
+ setByte(index, (byte) (value >>> 16));
+ setByte(index + 1, (byte) (value >>> 8));
+ setByte(index + 2, (byte) (value >>> 0));
}
@Override
diff --git a/buffer/src/main/java/io/netty/buffer/ChannelBuffer.java b/buffer/src/main/java/io/netty/buffer/ChannelBuffer.java
index 3c06f9a1fa..bda2401971 100644
--- a/buffer/src/main/java/io/netty/buffer/ChannelBuffer.java
+++ b/buffer/src/main/java/io/netty/buffer/ChannelBuffer.java
@@ -47,7 +47,7 @@ import java.nio.charset.UnsupportedCharsetException;
*
*
* {@link ChannelBuffer} buffer = ...;
- * for (int i = 0; i < buffer.capacity(); i ++) {
+ * for (int i = 0; i < buffer.capacity(); i ++) {
* byte b = buffer.getByte(i);
* System.out.println((char) b);
* }
diff --git a/buffer/src/main/java/io/netty/buffer/ChannelBuffers.java b/buffer/src/main/java/io/netty/buffer/ChannelBuffers.java
index fd4df8a3d7..5f540b0a8f 100644
--- a/buffer/src/main/java/io/netty/buffer/ChannelBuffers.java
+++ b/buffer/src/main/java/io/netty/buffer/ChannelBuffers.java
@@ -84,7 +84,7 @@ import io.netty.util.CharsetUtil;
* @apiviz.landmark
* @apiviz.has io.netty.buffer.ChannelBuffer oneway - - creates
*/
-public class ChannelBuffers {
+public final class ChannelBuffers {
/**
* Big endian byte order.
@@ -307,7 +307,11 @@ public class ChannelBuffers {
return EMPTY_BUFFER;
}
if (buffer.hasArray()) {
- return wrappedBuffer(buffer.order(), buffer.array(), buffer.arrayOffset() + buffer.position(),buffer.remaining());
+ return wrappedBuffer(
+ buffer.order(),
+ buffer.array(),
+ buffer.arrayOffset() + buffer.position(),
+ buffer.remaining());
} else {
return new ByteBufferBackedChannelBuffer(buffer);
}
diff --git a/buffer/src/main/java/io/netty/buffer/CompositeChannelBuffer.java b/buffer/src/main/java/io/netty/buffer/CompositeChannelBuffer.java
index 3fdefca805..e960ffab18 100644
--- a/buffer/src/main/java/io/netty/buffer/CompositeChannelBuffer.java
+++ b/buffer/src/main/java/io/netty/buffer/CompositeChannelBuffer.java
@@ -347,7 +347,7 @@ public class CompositeChannelBuffer extends AbstractChannelBuffer {
setByte(index + 2, (byte) value);
} else {
setShort(index , (short) value);
- setByte (index + 2, (byte) (value >>> 16));
+ setByte(index + 2, (byte) (value >>> 16));
}
}
diff --git a/buffer/src/main/java/io/netty/buffer/DirectChannelBufferFactory.java b/buffer/src/main/java/io/netty/buffer/DirectChannelBufferFactory.java
index 688614f39b..b86a2f71b0 100644
--- a/buffer/src/main/java/io/netty/buffer/DirectChannelBufferFactory.java
+++ b/buffer/src/main/java/io/netty/buffer/DirectChannelBufferFactory.java
@@ -57,9 +57,9 @@ public class DirectChannelBufferFactory extends AbstractChannelBufferFactory {
private final Object bigEndianLock = new Object();
private final Object littleEndianLock = new Object();
private final int preallocatedBufferCapacity;
- private ChannelBuffer preallocatedBigEndianBuffer = null;
+ private ChannelBuffer preallocatedBigEndianBuffer;
private int preallocatedBigEndianBufferPosition;
- private ChannelBuffer preallocatedLittleEndianBuffer = null;
+ private ChannelBuffer preallocatedLittleEndianBuffer;
private int preallocatedLittleEndianBufferPosition;
/**
diff --git a/buffer/src/main/java/io/netty/buffer/LittleEndianHeapChannelBuffer.java b/buffer/src/main/java/io/netty/buffer/LittleEndianHeapChannelBuffer.java
index 5b097337a6..399cb49afc 100644
--- a/buffer/src/main/java/io/netty/buffer/LittleEndianHeapChannelBuffer.java
+++ b/buffer/src/main/java/io/netty/buffer/LittleEndianHeapChannelBuffer.java
@@ -59,67 +59,67 @@ public class LittleEndianHeapChannelBuffer extends HeapChannelBuffer {
@Override
public short getShort(int index) {
- return (short) (array[index] & 0xFF | array[index+1] << 8);
+ return (short) (array[index] & 0xFF | array[index + 1] << 8);
}
@Override
public int getUnsignedMedium(int index) {
- return (array[index ] & 0xff) << 0 |
- (array[index+1] & 0xff) << 8 |
- (array[index+2] & 0xff) << 16;
+ return (array[index] & 0xff) << 0 |
+ (array[index + 1] & 0xff) << 8 |
+ (array[index + 2] & 0xff) << 16;
}
@Override
public int getInt(int index) {
- return (array[index ] & 0xff) << 0 |
- (array[index+1] & 0xff) << 8 |
- (array[index+2] & 0xff) << 16 |
- (array[index+3] & 0xff) << 24;
+ return (array[index] & 0xff) << 0 |
+ (array[index + 1] & 0xff) << 8 |
+ (array[index + 2] & 0xff) << 16 |
+ (array[index + 3] & 0xff) << 24;
}
@Override
public long getLong(int index) {
- return ((long) array[index] & 0xff) << 0 |
- ((long) array[index+1] & 0xff) << 8 |
- ((long) array[index+2] & 0xff) << 16 |
- ((long) array[index+3] & 0xff) << 24 |
- ((long) array[index+4] & 0xff) << 32 |
- ((long) array[index+5] & 0xff) << 40 |
- ((long) array[index+6] & 0xff) << 48 |
- ((long) array[index+7] & 0xff) << 56;
+ return ((long) array[index] & 0xff) << 0 |
+ ((long) array[index + 1] & 0xff) << 8 |
+ ((long) array[index + 2] & 0xff) << 16 |
+ ((long) array[index + 3] & 0xff) << 24 |
+ ((long) array[index + 4] & 0xff) << 32 |
+ ((long) array[index + 5] & 0xff) << 40 |
+ ((long) array[index + 6] & 0xff) << 48 |
+ ((long) array[index + 7] & 0xff) << 56;
}
@Override
public void setShort(int index, int value) {
- array[index ] = (byte) (value >>> 0);
- array[index+1] = (byte) (value >>> 8);
+ array[index] = (byte) (value >>> 0);
+ array[index + 1] = (byte) (value >>> 8);
}
@Override
public void setMedium(int index, int value) {
- array[index ] = (byte) (value >>> 0);
- array[index+1] = (byte) (value >>> 8);
- array[index+2] = (byte) (value >>> 16);
+ array[index] = (byte) (value >>> 0);
+ array[index + 1] = (byte) (value >>> 8);
+ array[index + 2] = (byte) (value >>> 16);
}
@Override
public void setInt(int index, int value) {
- array[index ] = (byte) (value >>> 0);
- array[index+1] = (byte) (value >>> 8);
- array[index+2] = (byte) (value >>> 16);
- array[index+3] = (byte) (value >>> 24);
+ array[index] = (byte) (value >>> 0);
+ array[index + 1] = (byte) (value >>> 8);
+ array[index + 2] = (byte) (value >>> 16);
+ array[index + 3] = (byte) (value >>> 24);
}
@Override
public void setLong(int index, long value) {
- array[index ] = (byte) (value >>> 0);
- array[index+1] = (byte) (value >>> 8);
- array[index+2] = (byte) (value >>> 16);
- array[index+3] = (byte) (value >>> 24);
- array[index+4] = (byte) (value >>> 32);
- array[index+5] = (byte) (value >>> 40);
- array[index+6] = (byte) (value >>> 48);
- array[index+7] = (byte) (value >>> 56);
+ array[index] = (byte) (value >>> 0);
+ array[index + 1] = (byte) (value >>> 8);
+ array[index + 2] = (byte) (value >>> 16);
+ array[index + 3] = (byte) (value >>> 24);
+ array[index + 4] = (byte) (value >>> 32);
+ array[index + 5] = (byte) (value >>> 40);
+ array[index + 6] = (byte) (value >>> 48);
+ array[index + 7] = (byte) (value >>> 56);
}
@Override
diff --git a/buffer/src/test/java/io/netty/buffer/AbstractChannelBufferTest.java b/buffer/src/test/java/io/netty/buffer/AbstractChannelBufferTest.java
index 62904c15ae..8e3df60f54 100644
--- a/buffer/src/test/java/io/netty/buffer/AbstractChannelBufferTest.java
+++ b/buffer/src/test/java/io/netty/buffer/AbstractChannelBufferTest.java
@@ -69,7 +69,7 @@ public abstract class AbstractChannelBufferTest {
assertEquals(0, buffer.readerIndex());
}
- @Test(expected=IndexOutOfBoundsException.class)
+ @Test(expected = IndexOutOfBoundsException.class)
public void readerIndexBoundaryCheck1() {
try {
buffer.writerIndex(0);
@@ -79,7 +79,7 @@ public abstract class AbstractChannelBufferTest {
buffer.readerIndex(-1);
}
- @Test(expected=IndexOutOfBoundsException.class)
+ @Test(expected = IndexOutOfBoundsException.class)
public void readerIndexBoundaryCheck2() {
try {
buffer.writerIndex(buffer.capacity());
@@ -89,7 +89,7 @@ public abstract class AbstractChannelBufferTest {
buffer.readerIndex(buffer.capacity() + 1);
}
- @Test(expected=IndexOutOfBoundsException.class)
+ @Test(expected = IndexOutOfBoundsException.class)
public void readerIndexBoundaryCheck3() {
try {
buffer.writerIndex(CAPACITY / 2);
@@ -107,12 +107,12 @@ public abstract class AbstractChannelBufferTest {
buffer.readerIndex(buffer.capacity());
}
- @Test(expected=IndexOutOfBoundsException.class)
+ @Test(expected = IndexOutOfBoundsException.class)
public void writerIndexBoundaryCheck1() {
buffer.writerIndex(-1);
}
- @Test(expected=IndexOutOfBoundsException.class)
+ @Test(expected = IndexOutOfBoundsException.class)
public void writerIndexBoundaryCheck2() {
try {
buffer.writerIndex(CAPACITY);
@@ -123,7 +123,7 @@ public abstract class AbstractChannelBufferTest {
buffer.writerIndex(buffer.capacity() + 1);
}
- @Test(expected=IndexOutOfBoundsException.class)
+ @Test(expected = IndexOutOfBoundsException.class)
public void writerIndexBoundaryCheck3() {
try {
buffer.writerIndex(CAPACITY);
@@ -141,72 +141,72 @@ public abstract class AbstractChannelBufferTest {
buffer.writerIndex(CAPACITY);
}
- @Test(expected=IndexOutOfBoundsException.class)
+ @Test(expected = IndexOutOfBoundsException.class)
public void getBooleanBoundaryCheck1() {
buffer.getBoolean(-1);
}
- @Test(expected=IndexOutOfBoundsException.class)
+ @Test(expected = IndexOutOfBoundsException.class)
public void getBooleanBoundaryCheck2() {
buffer.getBoolean(buffer.capacity());
}
- @Test(expected=IndexOutOfBoundsException.class)
+ @Test(expected = IndexOutOfBoundsException.class)
public void getByteBoundaryCheck1() {
buffer.getByte(-1);
}
- @Test(expected=IndexOutOfBoundsException.class)
+ @Test(expected = IndexOutOfBoundsException.class)
public void getByteBoundaryCheck2() {
buffer.getByte(buffer.capacity());
}
- @Test(expected=IndexOutOfBoundsException.class)
+ @Test(expected = IndexOutOfBoundsException.class)
public void getShortBoundaryCheck1() {
buffer.getShort(-1);
}
- @Test(expected=IndexOutOfBoundsException.class)
+ @Test(expected = IndexOutOfBoundsException.class)
public void getShortBoundaryCheck2() {
buffer.getShort(buffer.capacity() - 1);
}
- @Test(expected=IndexOutOfBoundsException.class)
+ @Test(expected = IndexOutOfBoundsException.class)
public void getMediumBoundaryCheck1() {
buffer.getMedium(-1);
}
- @Test(expected=IndexOutOfBoundsException.class)
+ @Test(expected = IndexOutOfBoundsException.class)
public void getMediumBoundaryCheck2() {
buffer.getMedium(buffer.capacity() - 2);
}
- @Test(expected=IndexOutOfBoundsException.class)
+ @Test(expected = IndexOutOfBoundsException.class)
public void getIntBoundaryCheck1() {
buffer.getInt(-1);
}
- @Test(expected=IndexOutOfBoundsException.class)
+ @Test(expected = IndexOutOfBoundsException.class)
public void getIntBoundaryCheck2() {
buffer.getInt(buffer.capacity() - 3);
}
- @Test(expected=IndexOutOfBoundsException.class)
+ @Test(expected = IndexOutOfBoundsException.class)
public void getLongBoundaryCheck1() {
buffer.getLong(-1);
}
- @Test(expected=IndexOutOfBoundsException.class)
+ @Test(expected = IndexOutOfBoundsException.class)
public void getLongBoundaryCheck2() {
buffer.getLong(buffer.capacity() - 7);
}
- @Test(expected=IndexOutOfBoundsException.class)
+ @Test(expected = IndexOutOfBoundsException.class)
public void getByteArrayBoundaryCheck1() {
buffer.getBytes(-1, new byte[0]);
}
- @Test(expected=IndexOutOfBoundsException.class)
+ @Test(expected = IndexOutOfBoundsException.class)
public void getByteArrayBoundaryCheck2() {
buffer.getBytes(-1, new byte[0], 0, 0);
}
@@ -247,42 +247,42 @@ public abstract class AbstractChannelBufferTest {
assertEquals(0, dst[3]);
}
- @Test(expected=IndexOutOfBoundsException.class)
+ @Test(expected = IndexOutOfBoundsException.class)
public void getByteBufferBoundaryCheck() {
buffer.getBytes(-1, ByteBuffer.allocate(0));
}
- @Test(expected=IndexOutOfBoundsException.class)
+ @Test(expected = IndexOutOfBoundsException.class)
public void copyBoundaryCheck1() {
buffer.copy(-1, 0);
}
- @Test(expected=IndexOutOfBoundsException.class)
+ @Test(expected = IndexOutOfBoundsException.class)
public void copyBoundaryCheck2() {
buffer.copy(0, buffer.capacity() + 1);
}
- @Test(expected=IndexOutOfBoundsException.class)
+ @Test(expected = IndexOutOfBoundsException.class)
public void copyBoundaryCheck3() {
buffer.copy(buffer.capacity() + 1, 0);
}
- @Test(expected=IndexOutOfBoundsException.class)
+ @Test(expected = IndexOutOfBoundsException.class)
public void copyBoundaryCheck4() {
buffer.copy(buffer.capacity(), 1);
}
- @Test(expected=IndexOutOfBoundsException.class)
+ @Test(expected = IndexOutOfBoundsException.class)
public void setIndexBoundaryCheck1() {
buffer.setIndex(-1, CAPACITY);
}
- @Test(expected=IndexOutOfBoundsException.class)
+ @Test(expected = IndexOutOfBoundsException.class)
public void setIndexBoundaryCheck2() {
buffer.setIndex(CAPACITY / 2, CAPACITY / 4);
}
- @Test(expected=IndexOutOfBoundsException.class)
+ @Test(expected = IndexOutOfBoundsException.class)
public void setIndexBoundaryCheck3() {
buffer.setIndex(0, CAPACITY + 1);
}
@@ -309,7 +309,7 @@ public abstract class AbstractChannelBufferTest {
assertEquals(0, dst.get(3));
}
- @Test(expected=IndexOutOfBoundsException.class)
+ @Test(expected = IndexOutOfBoundsException.class)
public void getDirectByteBufferBoundaryCheck() {
buffer.getBytes(-1, ByteBuffer.allocateDirect(0));
}
@@ -754,7 +754,7 @@ public abstract class AbstractChannelBufferTest {
@Test
public void testRandomByteArrayTransfer1() {
- byte[] value= new byte[BLOCK_SIZE];
+ byte[] value = new byte[BLOCK_SIZE];
for (int i = 0; i < buffer.capacity() - BLOCK_SIZE + 1; i += BLOCK_SIZE) {
random.nextBytes(value);
buffer.setBytes(i, value);
@@ -774,7 +774,7 @@ public abstract class AbstractChannelBufferTest {
@Test
public void testRandomByteArrayTransfer2() {
- byte[] value= new byte[BLOCK_SIZE * 2];
+ byte[] value = new byte[BLOCK_SIZE * 2];
for (int i = 0; i < buffer.capacity() - BLOCK_SIZE + 1; i += BLOCK_SIZE) {
random.nextBytes(value);
buffer.setBytes(i, value, random.nextInt(BLOCK_SIZE), BLOCK_SIZE);
@@ -891,7 +891,7 @@ public abstract class AbstractChannelBufferTest {
@Test
public void testSequentialByteArrayTransfer1() {
- byte[] value= new byte[BLOCK_SIZE];
+ byte[] value = new byte[BLOCK_SIZE];
buffer.writerIndex(0);
for (int i = 0; i < buffer.capacity() - BLOCK_SIZE + 1; i += BLOCK_SIZE) {
random.nextBytes(value);
@@ -926,7 +926,7 @@ public abstract class AbstractChannelBufferTest {
}
random.setSeed(seed);
- byte[] expectedValue= new byte[BLOCK_SIZE * 2];
+ byte[] expectedValue = new byte[BLOCK_SIZE * 2];
for (int i = 0; i < buffer.capacity() - BLOCK_SIZE + 1; i += BLOCK_SIZE) {
random.nextBytes(expectedValue);
int valueOffset = random.nextInt(BLOCK_SIZE);
diff --git a/buffer/src/test/java/io/netty/buffer/AbstractCompositeChannelBufferTest.java b/buffer/src/test/java/io/netty/buffer/AbstractCompositeChannelBufferTest.java
index ae016cce0a..597ded9905 100644
--- a/buffer/src/test/java/io/netty/buffer/AbstractCompositeChannelBufferTest.java
+++ b/buffer/src/test/java/io/netty/buffer/AbstractCompositeChannelBufferTest.java
@@ -102,16 +102,16 @@ public abstract class AbstractCompositeChannelBufferTest extends
b.skipBytes(6);
b.markReaderIndex();
assertEquals(a.readerIndex(), b.readerIndex());
- a.readerIndex(a.readerIndex()-1);
- b.readerIndex(b.readerIndex()-1);
+ a.readerIndex(a.readerIndex() - 1);
+ b.readerIndex(b.readerIndex() - 1);
assertEquals(a.readerIndex(), b.readerIndex());
- a.writerIndex(a.writerIndex()-1);
+ a.writerIndex(a.writerIndex() - 1);
a.markWriterIndex();
- b.writerIndex(b.writerIndex()-1);
+ b.writerIndex(b.writerIndex() - 1);
b.markWriterIndex();
assertEquals(a.writerIndex(), b.writerIndex());
- a.writerIndex(a.writerIndex()+1);
- b.writerIndex(b.writerIndex()+1);
+ a.writerIndex(a.writerIndex() + 1);
+ b.writerIndex(b.writerIndex() + 1);
assertEquals(a.writerIndex(), b.writerIndex());
assertTrue(ChannelBuffers.equals(a, b));
// now discard
@@ -256,7 +256,7 @@ public abstract class AbstractCompositeChannelBufferTest extends
a = wrappedBuffer(order, new byte[] { 1 });
b = wrappedBuffer(wrappedBuffer(order, new byte[] { 1 }, new byte[1]));
// to enable writeBytes
- b.writerIndex(b.writerIndex()-1);
+ b.writerIndex(b.writerIndex() - 1);
b.writeBytes(
wrappedBuffer(order, new byte[] { 2 }));
assertFalse(ChannelBuffers.equals(a, b));
@@ -265,7 +265,7 @@ public abstract class AbstractCompositeChannelBufferTest extends
a = wrappedBuffer(order, new byte[] { 1, 2, 3 });
b = wrappedBuffer(wrappedBuffer(order, new byte[] { 1 }, new byte[2]));
// to enable writeBytes
- b.writerIndex(b.writerIndex()-2);
+ b.writerIndex(b.writerIndex() - 2);
b.writeBytes(
wrappedBuffer(order, new byte[] { 2 }));
b.writeBytes(wrappedBuffer(order, new byte[] { 3 }));
@@ -275,7 +275,7 @@ public abstract class AbstractCompositeChannelBufferTest extends
a = wrappedBuffer(order, new byte[] { 1, 2, 3 });
b = wrappedBuffer(wrappedBuffer(order, new byte[] { 0, 1, 2, 3, 4 }, 1, 3));
// to enable writeBytes
- b.writerIndex(b.writerIndex()-1);
+ b.writerIndex(b.writerIndex() - 1);
b.writeBytes(
wrappedBuffer(order, new byte[] { 0, 1, 2, 3, 4 }, 3, 1));
assertTrue(ChannelBuffers.equals(a, b));
@@ -284,7 +284,7 @@ public abstract class AbstractCompositeChannelBufferTest extends
a = wrappedBuffer(order, new byte[] { 1, 2, 3 });
b = wrappedBuffer(wrappedBuffer(order, new byte[] { 1, 2 }, new byte[1]));
// to enable writeBytes
- b.writerIndex(b.writerIndex()-1);
+ b.writerIndex(b.writerIndex() - 1);
b.writeBytes(
wrappedBuffer(order, new byte[] { 4 }));
assertFalse(ChannelBuffers.equals(a, b));
@@ -293,7 +293,7 @@ public abstract class AbstractCompositeChannelBufferTest extends
a = wrappedBuffer(order, new byte[] { 1, 2, 3 });
b = wrappedBuffer(wrappedBuffer(order, new byte[] { 0, 1, 2, 4, 5 }, 1, 3));
// to enable writeBytes
- b.writerIndex(b.writerIndex()-1);
+ b.writerIndex(b.writerIndex() - 1);
b.writeBytes(
wrappedBuffer(order, new byte[] { 0, 1, 2, 4, 5 }, 3, 1));
assertFalse(ChannelBuffers.equals(a, b));
@@ -302,7 +302,7 @@ public abstract class AbstractCompositeChannelBufferTest extends
a = wrappedBuffer(order, new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 });
b = wrappedBuffer(wrappedBuffer(order, new byte[] { 1, 2, 3 }, new byte[7]));
// to enable writeBytes
- b.writerIndex(b.writerIndex()-7);
+ b.writerIndex(b.writerIndex() - 7);
b.writeBytes(
wrappedBuffer(order, new byte[] { 4, 5, 6 }));
b.writeBytes(
@@ -313,7 +313,7 @@ public abstract class AbstractCompositeChannelBufferTest extends
a = wrappedBuffer(order, new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 });
b = wrappedBuffer(wrappedBuffer(order, new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}, 1, 10));
// to enable writeBytes
- b.writerIndex(b.writerIndex()-5);
+ b.writerIndex(b.writerIndex() - 5);
b.writeBytes(
wrappedBuffer(order, new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}, 6, 5));
assertTrue(ChannelBuffers.equals(a, b));
@@ -322,7 +322,7 @@ public abstract class AbstractCompositeChannelBufferTest extends
a = wrappedBuffer(order, new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 });
b = wrappedBuffer(wrappedBuffer(order, new byte[] { 1, 2, 3, 4, 6 }, new byte[5]));
// to enable writeBytes
- b.writerIndex(b.writerIndex()-5);
+ b.writerIndex(b.writerIndex() - 5);
b.writeBytes(
wrappedBuffer(order, new byte[] { 7, 8, 5, 9, 10 }));
assertFalse(ChannelBuffers.equals(a, b));
@@ -331,7 +331,7 @@ public abstract class AbstractCompositeChannelBufferTest extends
a = wrappedBuffer(order, new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 });
b = wrappedBuffer(wrappedBuffer(order, new byte[] { 0, 1, 2, 3, 4, 6, 7, 8, 5, 9, 10, 11 }, 1, 10));
// to enable writeBytes
- b.writerIndex(b.writerIndex()-5);
+ b.writerIndex(b.writerIndex() - 5);
b.writeBytes(
wrappedBuffer(order, new byte[] { 0, 1, 2, 3, 4, 6, 7, 8, 5, 9, 10, 11 }, 6, 5));
assertFalse(ChannelBuffers.equals(a, b));
diff --git a/build/pom.xml b/build/pom.xml
new file mode 100644
index 0000000000..74f3f595bf
--- /dev/null
+++ b/build/pom.xml
@@ -0,0 +1,55 @@
+
+
+
+
+ 4.0.0
+
+ io.netty
+ netty-parent
+ 4.0.0.Alpha1-SNAPSHOT
+
+
+ io.netty
+ netty-build
+ 1-SNAPSHOT
+ jar
+
+ Netty/Build
+
+
+
+ com.puppycrawl.tools
+ checkstyle
+ 5.5
+
+
+
+
+
+
+ maven-checkstyle-plugin
+
+
+ check-style
+ none
+
+
+
+
+
+
+
diff --git a/build/src/main/java/io/netty/build/checkstyle/SuppressionFilter.java b/build/src/main/java/io/netty/build/checkstyle/SuppressionFilter.java
new file mode 100644
index 0000000000..86db7aa132
--- /dev/null
+++ b/build/src/main/java/io/netty/build/checkstyle/SuppressionFilter.java
@@ -0,0 +1,23 @@
+package io.netty.build.checkstyle;
+
+import java.util.regex.Pattern;
+
+import com.puppycrawl.tools.checkstyle.api.AuditEvent;
+import com.puppycrawl.tools.checkstyle.api.AutomaticBean;
+import com.puppycrawl.tools.checkstyle.api.Filter;
+import com.puppycrawl.tools.checkstyle.api.FilterSet;
+
+public class SuppressionFilter extends AutomaticBean implements Filter {
+
+ private FilterSet filters = new FilterSet();
+ private Pattern pattern;
+
+ public void setPattern(String pattern) {
+ this.pattern = Pattern.compile(pattern);
+ }
+
+ @Override
+ public boolean accept(AuditEvent evt) {
+ return !pattern.matcher(evt.getFileName()).find();
+ }
+}
diff --git a/build/src/main/resources/io/netty/LICENSE.txt b/build/src/main/resources/io/netty/LICENSE.txt
new file mode 100644
index 0000000000..d645695673
--- /dev/null
+++ b/build/src/main/resources/io/netty/LICENSE.txt
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/build/src/main/resources/io/netty/checkstyle.xml b/build/src/main/resources/io/netty/checkstyle.xml
new file mode 100644
index 0000000000..2c49ccbde3
--- /dev/null
+++ b/build/src/main/resources/io/netty/checkstyle.xml
@@ -0,0 +1,83 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/AbstractDiskHttpData.java b/codec-http/src/main/java/io/netty/handler/codec/http/AbstractDiskHttpData.java
index e25bfaf81b..ebb4290b5d 100644
--- a/codec-http/src/main/java/io/netty/handler/codec/http/AbstractDiskHttpData.java
+++ b/codec-http/src/main/java/io/netty/handler/codec/http/AbstractDiskHttpData.java
@@ -32,14 +32,11 @@ import io.netty.buffer.ChannelBuffers;
*/
public abstract class AbstractDiskHttpData extends AbstractHttpData {
- protected File file = null;
+ protected File file;
+ private boolean isRenamed;
+ private FileChannel fileChannel;
- private boolean isRenamed = false;
-
- private FileChannel fileChannel = null;
-
- public AbstractDiskHttpData(String name, Charset charset, long size)
- throws NullPointerException, IllegalArgumentException {
+ public AbstractDiskHttpData(String name, Charset charset, long size) {
super(name, charset, size);
}
@@ -191,7 +188,7 @@ public abstract class AbstractDiskHttpData extends AbstractHttpData {
file = tempFile();
FileOutputStream outputStream = new FileOutputStream(file);
FileChannel localfileChannel = outputStream.getChannel();
- byte[] bytes = new byte[4096*4];
+ byte[] bytes = new byte[4096 * 4];
ByteBuffer byteBuffer = ByteBuffer.wrap(bytes);
int read = inputStream.read(bytes);
int written = 0;
diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/AbstractHttpData.java b/codec-http/src/main/java/io/netty/handler/codec/http/AbstractHttpData.java
index 3d2b38c9e9..89a5752dd5 100644
--- a/codec-http/src/main/java/io/netty/handler/codec/http/AbstractHttpData.java
+++ b/codec-http/src/main/java/io/netty/handler/codec/http/AbstractHttpData.java
@@ -23,17 +23,12 @@ import java.nio.charset.Charset;
public abstract class AbstractHttpData implements HttpData {
protected final String name;
-
- protected long definedSize = 0;
-
- protected long size = 0;
-
+ protected long definedSize;
+ protected long size;
protected Charset charset = HttpCodecUtil.DEFAULT_CHARSET;
+ protected boolean completed;
- protected boolean completed = false;
-
- public AbstractHttpData(String name, Charset charset, long size)
- throws NullPointerException, IllegalArgumentException {
+ public AbstractHttpData(String name, Charset charset, long size) {
if (name == null) {
throw new NullPointerException("name");
}
diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/AbstractMemoryHttpData.java b/codec-http/src/main/java/io/netty/handler/codec/http/AbstractMemoryHttpData.java
index 7a324a257a..bdd24455f3 100644
--- a/codec-http/src/main/java/io/netty/handler/codec/http/AbstractMemoryHttpData.java
+++ b/codec-http/src/main/java/io/netty/handler/codec/http/AbstractMemoryHttpData.java
@@ -32,14 +32,11 @@ import io.netty.buffer.ChannelBuffers;
*/
public abstract class AbstractMemoryHttpData extends AbstractHttpData {
- private ChannelBuffer channelBuffer = null;
+ private ChannelBuffer channelBuffer;
+ private int chunkPosition;
+ protected boolean isRenamed;
- private int chunkPosition = 0;
-
- protected boolean isRenamed = false;
-
- public AbstractMemoryHttpData(String name, Charset charset, long size)
- throws NullPointerException, IllegalArgumentException {
+ public AbstractMemoryHttpData(String name, Charset charset, long size) {
super(name, charset, size);
}
@@ -64,7 +61,7 @@ public abstract class AbstractMemoryHttpData extends AbstractHttpData {
throw new NullPointerException("inputStream");
}
ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- byte[] bytes = new byte[4096*4];
+ byte[] bytes = new byte[4096 * 4];
int read = inputStream.read(bytes);
int written = 0;
while (read > 0) {
diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/CookieDecoder.java b/codec-http/src/main/java/io/netty/handler/codec/http/CookieDecoder.java
index e6f772abd6..e0c3e83ad2 100644
--- a/codec-http/src/main/java/io/netty/handler/codec/http/CookieDecoder.java
+++ b/codec-http/src/main/java/io/netty/handler/codec/http/CookieDecoder.java
@@ -41,10 +41,10 @@ import java.util.regex.Pattern;
*/
public class CookieDecoder {
- private final static Pattern PATTERN =
+ private static final Pattern PATTERN =
Pattern.compile("(?:\\s|[;,])*\\$*([^;=]+)(?:=(?:[\"']((?:\\\\.|[^\"])*)[\"']|([^;,]*)))?(\\s*(?:[;,]+\\s*|$))");
- private final static String COMMA = ",";
+ private static final String COMMA = ",";
private final boolean lenient;
diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/CookieEncoder.java b/codec-http/src/main/java/io/netty/handler/codec/http/CookieEncoder.java
index 845e5ac9e4..a8de9a8e46 100644
--- a/codec-http/src/main/java/io/netty/handler/codec/http/CookieEncoder.java
+++ b/codec-http/src/main/java/io/netty/handler/codec/http/CookieEncoder.java
@@ -145,7 +145,7 @@ public class CookieEncoder {
addQuoted(sb, CookieHeaderNames.COMMENTURL, cookie.getCommentUrl());
}
- if(!cookie.getPorts().isEmpty()) {
+ if (!cookie.getPorts().isEmpty()) {
sb.append(CookieHeaderNames.PORT);
sb.append((char) HttpCodecUtil.EQUALS);
sb.append((char) HttpCodecUtil.DOUBLE_QUOTE);
@@ -189,7 +189,7 @@ public class CookieEncoder {
}
if (cookie.getVersion() >= 1) {
- if(!cookie.getPorts().isEmpty()) {
+ if (!cookie.getPorts().isEmpty()) {
sb.append('$');
sb.append(CookieHeaderNames.PORT);
sb.append((char) HttpCodecUtil.EQUALS);
@@ -204,8 +204,10 @@ public class CookieEncoder {
}
}
- if(sb.length() > 0)
- sb.setLength(sb.length() - 1);
+ if (sb.length() > 0) {
+ sb.setLength(sb.length() - 1);
+ }
+
return sb.toString();
}
diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/DefaultCookie.java b/codec-http/src/main/java/io/netty/handler/codec/http/DefaultCookie.java
index d724406ed9..eaaa7a8dd3 100644
--- a/codec-http/src/main/java/io/netty/handler/codec/http/DefaultCookie.java
+++ b/codec-http/src/main/java/io/netty/handler/codec/http/DefaultCookie.java
@@ -283,7 +283,7 @@ public class DefaultCookie implements Cookie {
} else if (that.getDomain() == null) {
return false;
}
- return getDomain().equalsIgnoreCase(that.getDomain());
+ return getDomain().equalsIgnoreCase(that.getDomain());
}
@Override
diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/DefaultHttpDataFactory.java b/codec-http/src/main/java/io/netty/handler/codec/http/DefaultHttpDataFactory.java
index ef6feabe45..9d5bc79b12 100644
--- a/codec-http/src/main/java/io/netty/handler/codec/http/DefaultHttpDataFactory.java
+++ b/codec-http/src/main/java/io/netty/handler/codec/http/DefaultHttpDataFactory.java
@@ -35,11 +35,11 @@ public class DefaultHttpDataFactory implements HttpDataFactory {
*/
public static long MINSIZE = 0x4000;
- private boolean useDisk = false;
+ private boolean useDisk;
- private boolean checkSize = false;
+ private boolean checkSize;
- private long minSize = 0L;
+ private long minSize;
/**
* Keep all HttpDatas until cleanAllHttpDatas() is called.
@@ -91,8 +91,7 @@ public class DefaultHttpDataFactory implements HttpDataFactory {
}
@Override
- public Attribute createAttribute(HttpRequest request, String name) throws NullPointerException,
- IllegalArgumentException {
+ public Attribute createAttribute(HttpRequest request, String name) {
if (useDisk) {
Attribute attribute = new DiskAttribute(name);
List fileToDelete = getList(request);
@@ -111,8 +110,7 @@ public class DefaultHttpDataFactory implements HttpDataFactory {
* @see io.netty.handler.codec.http2.HttpDataFactory#createAttribute(java.lang.String, java.lang.String)
*/
@Override
- public Attribute createAttribute(HttpRequest request, String name, String value)
- throws NullPointerException, IllegalArgumentException {
+ public Attribute createAttribute(HttpRequest request, String name, String value) {
if (useDisk) {
Attribute attribute;
try {
@@ -143,7 +141,7 @@ public class DefaultHttpDataFactory implements HttpDataFactory {
@Override
public FileUpload createFileUpload(HttpRequest request, String name, String filename,
String contentType, String contentTransferEncoding, Charset charset,
- long size) throws NullPointerException, IllegalArgumentException {
+ long size) {
if (useDisk) {
FileUpload fileUpload = new DiskFileUpload(name, filename, contentType,
contentTransferEncoding, charset, size);
diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/DiskAttribute.java b/codec-http/src/main/java/io/netty/handler/codec/http/DiskAttribute.java
index e85e4caa9c..77072c00eb 100644
--- a/codec-http/src/main/java/io/netty/handler/codec/http/DiskAttribute.java
+++ b/codec-http/src/main/java/io/netty/handler/codec/http/DiskAttribute.java
@@ -24,7 +24,7 @@ import io.netty.buffer.ChannelBuffers;
* Disk implementation of Attributes
*/
public class DiskAttribute extends AbstractDiskHttpData implements Attribute {
- public static String baseDirectory = null;
+ public static String baseDirectory;
public static boolean deleteOnExitTemporaryFile = true;
@@ -47,8 +47,7 @@ public class DiskAttribute extends AbstractDiskHttpData implements Attribute {
* @throws IllegalArgumentException
* @throws IOException
*/
- public DiskAttribute(String name, String value)
- throws NullPointerException, IllegalArgumentException, IOException {
+ public DiskAttribute(String name, String value) throws IOException {
super(name, HttpCodecUtil.DEFAULT_CHARSET, 0); // Attribute have no default size
setValue(value);
}
@@ -133,7 +132,7 @@ public class DiskAttribute extends AbstractDiskHttpData implements Attribute {
@Override
protected String getDiskFilename() {
- return getName()+postfix;
+ return getName() + postfix;
}
@Override
diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/DiskFileUpload.java b/codec-http/src/main/java/io/netty/handler/codec/http/DiskFileUpload.java
index 938cd5b12c..544637958c 100644
--- a/codec-http/src/main/java/io/netty/handler/codec/http/DiskFileUpload.java
+++ b/codec-http/src/main/java/io/netty/handler/codec/http/DiskFileUpload.java
@@ -22,7 +22,7 @@ import java.nio.charset.Charset;
* Disk FileUpload implementation that stores file into real files
*/
public class DiskFileUpload extends AbstractDiskHttpData implements FileUpload {
- public static String baseDirectory = null;
+ public static String baseDirectory;
public static boolean deleteOnExitTemporaryFile = true;
@@ -30,15 +30,14 @@ public class DiskFileUpload extends AbstractDiskHttpData implements FileUpload {
public static String postfix = ".tmp";
- private String filename = null;
+ private String filename;
- private String contentType = null;
+ private String contentType;
- private String contentTransferEncoding = null;
+ private String contentTransferEncoding;
public DiskFileUpload(String name, String filename, String contentType,
- String contentTransferEncoding, Charset charset, long size)
- throws NullPointerException, IllegalArgumentException {
+ String contentTransferEncoding, Charset charset, long size) {
super(name, charset, size);
setFilename(filename);
setContentType(contentType);
@@ -127,12 +126,12 @@ public class DiskFileUpload extends AbstractDiskHttpData implements FileUpload {
@Override
public String toString() {
- return HttpPostBodyUtil.CONTENT_DISPOSITION+": "+
- HttpPostBodyUtil.FORM_DATA+"; "+HttpPostBodyUtil.NAME+"=\"" + getName() +
- "\"; "+HttpPostBodyUtil.FILENAME+"=\"" + filename + "\"\r\n" +
- HttpHeaders.Names.CONTENT_TYPE+": " + contentType +
- (charset != null? "; "+HttpHeaders.Values.CHARSET+"=" + charset + "\r\n" : "\r\n") +
- HttpHeaders.Names.CONTENT_LENGTH+": " + length() + "\r\n" +
+ return HttpPostBodyUtil.CONTENT_DISPOSITION + ": " +
+ HttpPostBodyUtil.FORM_DATA + "; " + HttpPostBodyUtil.NAME + "=\"" + getName() +
+ "\"; " + HttpPostBodyUtil.FILENAME + "=\"" + filename + "\"\r\n" +
+ HttpHeaders.Names.CONTENT_TYPE + ": " + contentType +
+ (charset != null? "; " + HttpHeaders.Values.CHARSET + "=" + charset + "\r\n" : "\r\n") +
+ HttpHeaders.Names.CONTENT_LENGTH + ": " + length() + "\r\n" +
"Completed: " + isCompleted() +
"\r\nIsInMemory: " + isInMemory() + "\r\nRealFile: " +
file.getAbsolutePath() + " DefaultDeleteAfter: " +
diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/HttpCodecUtil.java b/codec-http/src/main/java/io/netty/handler/codec/http/HttpCodecUtil.java
index 6652672bee..065f8579ab 100644
--- a/codec-http/src/main/java/io/netty/handler/codec/http/HttpCodecUtil.java
+++ b/codec-http/src/main/java/io/netty/handler/codec/http/HttpCodecUtil.java
@@ -22,7 +22,7 @@ import io.netty.util.CharsetUtil;
/**
*/
-class HttpCodecUtil {
+final class HttpCodecUtil {
//space ' '
static final byte SP = 32;
diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/HttpDataFactory.java b/codec-http/src/main/java/io/netty/handler/codec/http/HttpDataFactory.java
index 678853d9fe..2999bad731 100644
--- a/codec-http/src/main/java/io/netty/handler/codec/http/HttpDataFactory.java
+++ b/codec-http/src/main/java/io/netty/handler/codec/http/HttpDataFactory.java
@@ -29,8 +29,7 @@ public interface HttpDataFactory {
* @throws NullPointerException
* @throws IllegalArgumentException
*/
- Attribute createAttribute(HttpRequest request, String name)
- throws NullPointerException, IllegalArgumentException;
+ Attribute createAttribute(HttpRequest request, String name);
/**
*
@@ -41,8 +40,7 @@ public interface HttpDataFactory {
* @throws NullPointerException
* @throws IllegalArgumentException
*/
- Attribute createAttribute(HttpRequest request, String name, String value)
- throws NullPointerException, IllegalArgumentException;
+ Attribute createAttribute(HttpRequest request, String name, String value);
/**
*
@@ -56,7 +54,7 @@ public interface HttpDataFactory {
*/
FileUpload createFileUpload(HttpRequest request, String name, String filename,
String contentType, String contentTransferEncoding, Charset charset,
- long size) throws NullPointerException, IllegalArgumentException;
+ long size);
/**
* Remove the given InterfaceHttpData from clean list (will not delete the file, except if the file
diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/HttpHeaders.java b/codec-http/src/main/java/io/netty/handler/codec/http/HttpHeaders.java
index fc318957ef..ab844236e6 100644
--- a/codec-http/src/main/java/io/netty/handler/codec/http/HttpHeaders.java
+++ b/codec-http/src/main/java/io/netty/handler/codec/http/HttpHeaders.java
@@ -49,7 +49,7 @@ public class HttpHeaders {
/**
* {@code "Accept-Encoding"}
*/
- public static final String ACCEPT_ENCODING= "Accept-Encoding";
+ public static final String ACCEPT_ENCODING = "Accept-Encoding";
/**
* {@code "Accept-Language"}
*/
@@ -57,11 +57,11 @@ public class HttpHeaders {
/**
* {@code "Accept-Ranges"}
*/
- public static final String ACCEPT_RANGES= "Accept-Ranges";
+ public static final String ACCEPT_RANGES = "Accept-Ranges";
/**
* {@code "Accept-Patch"}
*/
- public static final String ACCEPT_PATCH= "Accept-Patch";
+ public static final String ACCEPT_PATCH = "Accept-Patch";
/**
* {@code "Age"}
*/
@@ -93,7 +93,7 @@ public class HttpHeaders {
/**
* {@code "Content-Language"}
*/
- public static final String CONTENT_LANGUAGE= "Content-Language";
+ public static final String CONTENT_LANGUAGE = "Content-Language";
/**
* {@code "Content-Length"}
*/
@@ -117,7 +117,7 @@ public class HttpHeaders {
/**
* {@code "Content-Type"}
*/
- public static final String CONTENT_TYPE= "Content-Type";
+ public static final String CONTENT_TYPE = "Content-Type";
/**
* {@code "Cookie"}
*/
@@ -161,7 +161,7 @@ public class HttpHeaders {
/**
* {@code "If-Range"}
*/
- public static final String IF_RANGE= "If-Range";
+ public static final String IF_RANGE = "If-Range";
/**
* {@code "If-Unmodified-Since"}
*/
@@ -229,15 +229,15 @@ public class HttpHeaders {
/**
* {@code "Sec-WebSocket-Version"}
*/
- public static final String SEC_WEBSOCKET_VERSION = "Sec-WebSocket-Version";
+ public static final String SEC_WEBSOCKET_VERSION = "Sec-WebSocket-Version";
/**
* {@code "Sec-WebSocket-Key"}
*/
- public static final String SEC_WEBSOCKET_KEY = "Sec-WebSocket-Key";
+ public static final String SEC_WEBSOCKET_KEY = "Sec-WebSocket-Key";
/**
* {@code "Sec-WebSocket-Accept"}
*/
- public static final String SEC_WEBSOCKET_ACCEPT = "Sec-WebSocket-Accept";
+ public static final String SEC_WEBSOCKET_ACCEPT = "Sec-WebSocket-Accept";
/**
* {@code "Server"}
*/
diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/HttpMessageDecoder.java b/codec-http/src/main/java/io/netty/handler/codec/http/HttpMessageDecoder.java
index 5059fba641..128aa46fe2 100644
--- a/codec-http/src/main/java/io/netty/handler/codec/http/HttpMessageDecoder.java
+++ b/codec-http/src/main/java/io/netty/handler/codec/http/HttpMessageDecoder.java
@@ -568,11 +568,9 @@ public abstract class HttpMessageDecoder extends ReplayingDecoder= maxLineLength) {
// TODO: Respond with Bad Request and discard the traffic
// or close the connection.
diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/HttpPostBodyUtil.java b/codec-http/src/main/java/io/netty/handler/codec/http/HttpPostBodyUtil.java
index c49cbcc488..e74e1ecdc0 100644
--- a/codec-http/src/main/java/io/netty/handler/codec/http/HttpPostBodyUtil.java
+++ b/codec-http/src/main/java/io/netty/handler/codec/http/HttpPostBodyUtil.java
@@ -23,7 +23,8 @@ import io.netty.util.CharsetUtil;
/**
* Shared Static object between HttpMessageDecoder, HttpPostRequestDecoder and HttpPostRequestEncoder
*/
-public class HttpPostBodyUtil {
+final class HttpPostBodyUtil {
+
public static int chunkSize = 8096;
/**
* HTTP content disposition header name.
diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/HttpPostRequestDecoder.java b/codec-http/src/main/java/io/netty/handler/codec/http/HttpPostRequestDecoder.java
index dce84caeb3..df4cf79a21 100644
--- a/codec-http/src/main/java/io/netty/handler/codec/http/HttpPostRequestDecoder.java
+++ b/codec-http/src/main/java/io/netty/handler/codec/http/HttpPostRequestDecoder.java
@@ -50,12 +50,12 @@ public class HttpPostRequestDecoder {
/**
* Does request have a body to decode
*/
- private boolean bodyToDecode = false;
+ private boolean bodyToDecode;
/**
* Does the last chunk already received
*/
- private boolean isLastChunk = false;
+ private boolean isLastChunk;
/**
* HttpDatas from Body
@@ -71,28 +71,28 @@ public class HttpPostRequestDecoder {
/**
* The current channelBuffer
*/
- private ChannelBuffer undecodedChunk = null;
+ private ChannelBuffer undecodedChunk;
/**
* Does this request is a Multipart request
*/
- private boolean isMultipart = false;
+ private boolean isMultipart;
/**
* Body HttpDatas current position
*/
- private int bodyListHttpDataRank = 0;
+ private int bodyListHttpDataRank;
/**
* If multipart, this is the boundary for the flobal multipart
*/
- private String multipartDataBoundary = null;
+ private String multipartDataBoundary;
/**
* If multipart, there could be internal multiparts (mixed) to the global multipart.
* Only one level is allowed.
*/
- private String multipartMixedBoundary = null;
+ private String multipartMixedBoundary;
/**
* Current status
@@ -102,17 +102,17 @@ public class HttpPostRequestDecoder {
/**
* Used in Multipart
*/
- private Map currentFieldAttributes = null;
+ private Map currentFieldAttributes;
/**
* The current FileUpload that is currently in decode process
*/
- private FileUpload currentFileUpload = null;
+ private FileUpload currentFileUpload;
/**
* The current Attribute that is currently in decode process
*/
- private Attribute currentAttribute = null;
+ private Attribute currentAttribute;
/**
*
@@ -122,8 +122,7 @@ public class HttpPostRequestDecoder {
* @throws ErrorDataDecoderException if the default charset was wrong when decoding or other errors
*/
public HttpPostRequestDecoder(HttpRequest request)
- throws ErrorDataDecoderException, IncompatibleDataDecoderException,
- NullPointerException {
+ throws ErrorDataDecoderException, IncompatibleDataDecoderException {
this(new DefaultHttpDataFactory(DefaultHttpDataFactory.MINSIZE),
request, HttpCodecUtil.DEFAULT_CHARSET);
}
@@ -137,8 +136,7 @@ public class HttpPostRequestDecoder {
* @throws ErrorDataDecoderException if the default charset was wrong when decoding or other errors
*/
public HttpPostRequestDecoder(HttpDataFactory factory, HttpRequest request)
- throws ErrorDataDecoderException, IncompatibleDataDecoderException,
- NullPointerException {
+ throws ErrorDataDecoderException, IncompatibleDataDecoderException {
this(factory, request, HttpCodecUtil.DEFAULT_CHARSET);
}
@@ -153,7 +151,7 @@ public class HttpPostRequestDecoder {
*/
public HttpPostRequestDecoder(HttpDataFactory factory, HttpRequest request,
Charset charset) throws ErrorDataDecoderException,
- IncompatibleDataDecoderException, NullPointerException {
+ IncompatibleDataDecoderException {
if (factory == null) {
throw new NullPointerException("factory");
}
@@ -446,9 +444,9 @@ public class HttpPostRequestDecoder {
case DISPOSITION:// search '='
if (read == '=') {
currentStatus = MultiPartStatus.FIELD;
- equalpos = currentpos-1;
+ equalpos = currentpos - 1;
String key = decodeAttribute(
- undecodedChunk.toString(firstpos, equalpos-firstpos, charset),
+ undecodedChunk.toString(firstpos, equalpos - firstpos, charset),
charset);
currentAttribute = factory.createAttribute(request, key);
firstpos = currentpos;
@@ -467,8 +465,8 @@ public class HttpPostRequestDecoder {
case FIELD:// search '&' or end of line
if (read == '&') {
currentStatus = MultiPartStatus.DISPOSITION;
- ampersandpos = currentpos-1;
- setFinalBuffer(undecodedChunk.slice(firstpos, ampersandpos-firstpos));
+ ampersandpos = currentpos - 1;
+ setFinalBuffer(undecodedChunk.slice(firstpos, ampersandpos - firstpos));
firstpos = currentpos;
contRead = true;
} else if (read == HttpCodecUtil.CR) {
@@ -477,9 +475,9 @@ public class HttpPostRequestDecoder {
currentpos++;
if (read == HttpCodecUtil.LF) {
currentStatus = MultiPartStatus.PREEPILOGUE;
- ampersandpos = currentpos-2;
+ ampersandpos = currentpos - 2;
setFinalBuffer(
- undecodedChunk.slice(firstpos, ampersandpos-firstpos));
+ undecodedChunk.slice(firstpos, ampersandpos - firstpos));
firstpos = currentpos;
contRead = false;
} else {
@@ -492,9 +490,9 @@ public class HttpPostRequestDecoder {
}
} else if (read == HttpCodecUtil.LF) {
currentStatus = MultiPartStatus.PREEPILOGUE;
- ampersandpos = currentpos-1;
+ ampersandpos = currentpos - 1;
setFinalBuffer(
- undecodedChunk.slice(firstpos, ampersandpos-firstpos));
+ undecodedChunk.slice(firstpos, ampersandpos - firstpos));
firstpos = currentpos;
contRead = false;
}
@@ -509,7 +507,7 @@ public class HttpPostRequestDecoder {
ampersandpos = currentpos;
if (ampersandpos > firstpos) {
setFinalBuffer(
- undecodedChunk.slice(firstpos, ampersandpos-firstpos));
+ undecodedChunk.slice(firstpos, ampersandpos - firstpos));
} else if (! currentAttribute.isCompleted()) {
setFinalBuffer(ChannelBuffers.EMPTY_BUFFER);
}
@@ -521,7 +519,7 @@ public class HttpPostRequestDecoder {
// reset index except if to continue in case of FIELD status
if (currentStatus == MultiPartStatus.FIELD) {
currentAttribute.addContent(
- undecodedChunk.slice(firstpos, currentpos-firstpos),
+ undecodedChunk.slice(firstpos, currentpos - firstpos),
false);
firstpos = currentpos;
}
@@ -1231,7 +1229,7 @@ public class HttpPostRequestDecoder {
// so go back of delimiter size
try {
currentAttribute.addContent(
- undecodedChunk.slice(readerIndex, lastPosition-readerIndex),
+ undecodedChunk.slice(readerIndex, lastPosition - readerIndex),
true);
} catch (IOException e) {
throw new ErrorDataDecoderException(e);
@@ -1240,7 +1238,7 @@ public class HttpPostRequestDecoder {
} else {
try {
currentAttribute.addContent(
- undecodedChunk.slice(readerIndex, lastPosition-readerIndex),
+ undecodedChunk.slice(readerIndex, lastPosition - readerIndex),
false);
} catch (IOException e) {
throw new ErrorDataDecoderException(e);
diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/HttpPostRequestEncoder.java b/codec-http/src/main/java/io/netty/handler/codec/http/HttpPostRequestEncoder.java
index 6a038423aa..0a13479608 100644
--- a/codec-http/src/main/java/io/netty/handler/codec/http/HttpPostRequestEncoder.java
+++ b/codec-http/src/main/java/io/netty/handler/codec/http/HttpPostRequestEncoder.java
@@ -51,16 +51,16 @@ public class HttpPostRequestEncoder implements ChunkedInput {
/**
* Chunked false by default
*/
- private boolean isChunked = false;
+ private boolean isChunked;
/**
* InterfaceHttpData for Body (without encoding)
*/
- private List bodyListDatas = null;
+ private List bodyListDatas;
/**
* The final Multipart List of InterfaceHttpData including encoding
*/
- private List multipartHttpDatas = null;
+ private List multipartHttpDatas;
/**
* Does this request is a Multipart request
@@ -70,17 +70,17 @@ public class HttpPostRequestEncoder implements ChunkedInput {
/**
* If multipart, this is the boundary for the flobal multipart
*/
- private String multipartDataBoundary = null;
+ private String multipartDataBoundary;
/**
* If multipart, there could be internal multiparts (mixed) to the global multipart.
* Only one level is allowed.
*/
- private String multipartMixedBoundary = null;
+ private String multipartMixedBoundary;
/**
* To check if the header has been finalized
*/
- private boolean headerFinalized = false;
+ private boolean headerFinalized;
/**
*
@@ -90,7 +90,7 @@ public class HttpPostRequestEncoder implements ChunkedInput {
* @throws ErrorDataEncoderException if the request is not a POST
*/
public HttpPostRequestEncoder(HttpRequest request, boolean multipart)
- throws ErrorDataEncoderException, NullPointerException {
+ throws ErrorDataEncoderException {
this(new DefaultHttpDataFactory(DefaultHttpDataFactory.MINSIZE),
request, multipart, HttpCodecUtil.DEFAULT_CHARSET);
}
@@ -104,7 +104,7 @@ public class HttpPostRequestEncoder implements ChunkedInput {
* @throws ErrorDataEncoderException if the request is not a POST
*/
public HttpPostRequestEncoder(HttpDataFactory factory, HttpRequest request, boolean multipart)
- throws ErrorDataEncoderException, NullPointerException {
+ throws ErrorDataEncoderException {
this(factory, request, multipart, HttpCodecUtil.DEFAULT_CHARSET);
}
@@ -118,8 +118,7 @@ public class HttpPostRequestEncoder implements ChunkedInput {
* @throws ErrorDataEncoderException if the request is not a POST
*/
public HttpPostRequestEncoder(HttpDataFactory factory, HttpRequest request,
- boolean multipart, Charset charset) throws ErrorDataEncoderException,
- NullPointerException {
+ boolean multipart, Charset charset) throws ErrorDataEncoderException {
if (factory == null) {
throw new NullPointerException("factory");
}
@@ -157,24 +156,24 @@ public class HttpPostRequestEncoder implements ChunkedInput {
/**
* Does the last non empty chunk already encoded so that next chunk will be empty (last chunk)
*/
- private boolean isLastChunk = false;
+ private boolean isLastChunk;
/**
* Last chunk already sent
*/
- private boolean isLastChunkSent = false;
+ private boolean isLastChunkSent;
/**
* The current FileUpload that is currently in encode process
*/
- private FileUpload currentFileUpload = null;
+ private FileUpload currentFileUpload;
/**
* While adding a FileUpload, is the multipart currently in Mixed Mode
*/
- private boolean duringMixedMode = false;
+ private boolean duringMixedMode;
/**
* Global Body size
*/
- private long globalBodySize = 0;
+ private long globalBodySize;
/**
* True if this request is a Multipart request
@@ -224,7 +223,7 @@ public class HttpPostRequestEncoder implements ChunkedInput {
* @throws ErrorDataEncoderException if the encoding is in error or if the finalize were already done
*/
public void setBodyHttpDatas(List datas)
- throws NullPointerException, ErrorDataEncoderException {
+ throws ErrorDataEncoderException {
if (datas == null) {
throw new NullPointerException("datas");
}
@@ -246,7 +245,7 @@ public class HttpPostRequestEncoder implements ChunkedInput {
* @throws ErrorDataEncoderException if the encoding is in error or if the finalize were already done
*/
public void addBodyAttribute(String name, String value)
- throws NullPointerException, ErrorDataEncoderException {
+ throws ErrorDataEncoderException {
if (name == null) {
throw new NullPointerException("name");
}
@@ -268,7 +267,7 @@ public class HttpPostRequestEncoder implements ChunkedInput {
* @throws ErrorDataEncoderException if the encoding is in error or if the finalize were already done
*/
public void addBodyFileUpload(String name, File file, String contentType, boolean isText)
- throws NullPointerException, ErrorDataEncoderException {
+ throws ErrorDataEncoderException {
if (name == null) {
throw new NullPointerException("name");
}
@@ -307,7 +306,7 @@ public class HttpPostRequestEncoder implements ChunkedInput {
* @throws ErrorDataEncoderException if the encoding is in error or if the finalize were already done
*/
public void addBodyFileUploads(String name, File[] file, String[] contentType, boolean[] isText)
- throws NullPointerException, ErrorDataEncoderException {
+ throws ErrorDataEncoderException {
if (file.length != contentType.length && file.length != isText.length) {
throw new NullPointerException("Different array length");
}
@@ -323,7 +322,7 @@ public class HttpPostRequestEncoder implements ChunkedInput {
* @throws ErrorDataEncoderException if the encoding is in error or if the finalize were already done
*/
public void addBodyHttpData(InterfaceHttpData data)
- throws NullPointerException, ErrorDataEncoderException {
+ throws ErrorDataEncoderException {
if (headerFinalized) {
throw new ErrorDataEncoderException("Cannot add value once finalized");
}
@@ -340,12 +339,12 @@ public class HttpPostRequestEncoder implements ChunkedInput {
String value = encodeAttribute(attribute.getValue(), charset);
Attribute newattribute = factory.createAttribute(request, key, value);
multipartHttpDatas.add(newattribute);
- globalBodySize += newattribute.getName().length()+1+
- newattribute.length()+1;
+ globalBodySize += newattribute.getName().length() + 1 +
+ newattribute.length() + 1;
} catch (IOException e) {
throw new ErrorDataEncoderException(e);
}
- } else if (data instanceof FileUpload){
+ } else if (data instanceof FileUpload) {
// since not Multipart, only name=filename => Attribute
FileUpload fileUpload = (FileUpload) data;
// name=filename& with encoded name and filename
@@ -353,8 +352,8 @@ public class HttpPostRequestEncoder implements ChunkedInput {
String value = encodeAttribute(fileUpload.getFilename(), charset);
Attribute newattribute = factory.createAttribute(request, key, value);
multipartHttpDatas.add(newattribute);
- globalBodySize += newattribute.getName().length()+1+
- newattribute.length()+1;
+ globalBodySize += newattribute.getName().length() + 1 +
+ newattribute.length() + 1;
}
return;
}
@@ -393,7 +392,7 @@ public class HttpPostRequestEncoder implements ChunkedInput {
if (data instanceof Attribute) {
if (duringMixedMode) {
InternalAttribute internal = new InternalAttribute();
- internal.addValue("\r\n--"+multipartMixedBoundary+"--");
+ internal.addValue("\r\n--" + multipartMixedBoundary + "--");
multipartHttpDatas.add(internal);
multipartMixedBoundary = null;
currentFileUpload = null;
@@ -404,24 +403,24 @@ public class HttpPostRequestEncoder implements ChunkedInput {
// previously a data field so CRLF
internal.addValue("\r\n");
}
- internal.addValue("--"+multipartDataBoundary+"\r\n");
+ internal.addValue("--" + multipartDataBoundary + "\r\n");
// content-disposition: form-data; name="field1"
Attribute attribute = (Attribute) data;
- internal.addValue(HttpPostBodyUtil.CONTENT_DISPOSITION+": "+
- HttpPostBodyUtil.FORM_DATA+"; "+
- HttpPostBodyUtil.NAME+"=\""+
- encodeAttribute(attribute.getName(), charset)+"\"\r\n");
+ internal.addValue(HttpPostBodyUtil.CONTENT_DISPOSITION + ": " +
+ HttpPostBodyUtil.FORM_DATA + "; " +
+ HttpPostBodyUtil.NAME + "=\"" +
+ encodeAttribute(attribute.getName(), charset) + "\"\r\n");
Charset localcharset = attribute.getCharset();
if (localcharset != null) {
// Content-Type: charset=charset
- internal.addValue(HttpHeaders.Names.CONTENT_TYPE+": "+
- HttpHeaders.Values.CHARSET+"="+localcharset+"\r\n");
+ internal.addValue(HttpHeaders.Names.CONTENT_TYPE + ": " +
+ HttpHeaders.Values.CHARSET + "=" + localcharset + "\r\n");
}
// CRLF between body header and data
internal.addValue("\r\n");
multipartHttpDatas.add(internal);
multipartHttpDatas.add(data);
- globalBodySize += attribute.length()+internal.size();
+ globalBodySize += attribute.length() + internal.size();
} else if (data instanceof FileUpload) {
FileUpload fileUpload = (FileUpload) data;
InternalAttribute internal = new InternalAttribute();
@@ -441,7 +440,7 @@ public class HttpPostRequestEncoder implements ChunkedInput {
// add endmixedmultipart delimiter, multipart body header and
// Data to multipart list
- internal.addValue("--"+multipartMixedBoundary+"--");
+ internal.addValue("--" + multipartMixedBoundary + "--");
multipartHttpDatas.add(internal);
multipartMixedBoundary = null;
// start a new one (could be replaced if mixed start again from here
@@ -475,19 +474,19 @@ public class HttpPostRequestEncoder implements ChunkedInput {
// Content-Type: text/plain
initMixedMultipart();
InternalAttribute pastAttribute =
- (InternalAttribute) multipartHttpDatas.get(multipartHttpDatas.size()-2);
+ (InternalAttribute) multipartHttpDatas.get(multipartHttpDatas.size() - 2);
// remove past size
globalBodySize -= pastAttribute.size();
- String replacement = HttpPostBodyUtil.CONTENT_DISPOSITION+": "+
- HttpPostBodyUtil.FORM_DATA+"; "+HttpPostBodyUtil.NAME+"=\""+
- encodeAttribute(fileUpload.getName(), charset)+"\"\r\n";
- replacement += HttpHeaders.Names.CONTENT_TYPE+": "+
- HttpPostBodyUtil.MULTIPART_MIXED+"; "+HttpHeaders.Values.BOUNDARY+
- "="+multipartMixedBoundary+"\r\n\r\n";
- replacement += "--"+multipartMixedBoundary+"\r\n";
- replacement += HttpPostBodyUtil.CONTENT_DISPOSITION+": "+
- HttpPostBodyUtil.FILE+"; "+HttpPostBodyUtil.FILENAME+"=\""+
- encodeAttribute(fileUpload.getFilename(), charset)+
+ String replacement = HttpPostBodyUtil.CONTENT_DISPOSITION + ": " +
+ HttpPostBodyUtil.FORM_DATA + "; " + HttpPostBodyUtil.NAME + "=\"" +
+ encodeAttribute(fileUpload.getName(), charset) + "\"\r\n";
+ replacement += HttpHeaders.Names.CONTENT_TYPE + ": " +
+ HttpPostBodyUtil.MULTIPART_MIXED + "; " + HttpHeaders.Values.BOUNDARY +
+ "=" + multipartMixedBoundary + "\r\n\r\n";
+ replacement += "--" + multipartMixedBoundary + "\r\n";
+ replacement += HttpPostBodyUtil.CONTENT_DISPOSITION + ": " +
+ HttpPostBodyUtil.FILE + "; " + HttpPostBodyUtil.FILENAME + "=\"" +
+ encodeAttribute(fileUpload.getFilename(), charset) +
"\"\r\n";
pastAttribute.setValue(replacement, 1);
// update past size
@@ -510,51 +509,51 @@ public class HttpPostRequestEncoder implements ChunkedInput {
if (localMixed) {
// add mixedmultipart delimiter, mixedmultipart body header and
// Data to multipart list
- internal.addValue("--"+multipartMixedBoundary+"\r\n");
+ internal.addValue("--" + multipartMixedBoundary + "\r\n");
// Content-Disposition: file; filename="file1.txt"
- internal.addValue(HttpPostBodyUtil.CONTENT_DISPOSITION+": "+
- HttpPostBodyUtil.FILE+"; "+HttpPostBodyUtil.FILENAME+"=\""+
- encodeAttribute(fileUpload.getFilename(), charset)+
+ internal.addValue(HttpPostBodyUtil.CONTENT_DISPOSITION + ": " +
+ HttpPostBodyUtil.FILE + "; " + HttpPostBodyUtil.FILENAME + "=\"" +
+ encodeAttribute(fileUpload.getFilename(), charset) +
"\"\r\n");
} else {
- internal.addValue("--"+multipartDataBoundary+"\r\n");
+ internal.addValue("--" + multipartDataBoundary + "\r\n");
// Content-Disposition: form-data; name="files"; filename="file1.txt"
- internal.addValue(HttpPostBodyUtil.CONTENT_DISPOSITION+": "+
- HttpPostBodyUtil.FORM_DATA+"; "+HttpPostBodyUtil.NAME+"=\""+
- encodeAttribute(fileUpload.getName(), charset)+"\"; "+
- HttpPostBodyUtil.FILENAME+"=\""+
- encodeAttribute(fileUpload.getFilename(), charset)+
+ internal.addValue(HttpPostBodyUtil.CONTENT_DISPOSITION + ": " +
+ HttpPostBodyUtil.FORM_DATA + "; " + HttpPostBodyUtil.NAME + "=\"" +
+ encodeAttribute(fileUpload.getName(), charset) + "\"; " +
+ HttpPostBodyUtil.FILENAME + "=\"" +
+ encodeAttribute(fileUpload.getFilename(), charset) +
"\"\r\n");
}
// Content-Type: image/gif
// Content-Type: text/plain; charset=ISO-8859-1
// Content-Transfer-Encoding: binary
- internal.addValue(HttpHeaders.Names.CONTENT_TYPE+": "+
+ internal.addValue(HttpHeaders.Names.CONTENT_TYPE + ": " +
fileUpload.getContentType());
String contentTransferEncoding = fileUpload.getContentTransferEncoding();
if (contentTransferEncoding != null &&
contentTransferEncoding.equals(
HttpPostBodyUtil.TransferEncodingMechanism.BINARY.value)) {
- internal.addValue("\r\n"+HttpHeaders.Names.CONTENT_TRANSFER_ENCODING+
- ": "+HttpPostBodyUtil.TransferEncodingMechanism.BINARY.value+
+ internal.addValue("\r\n" + HttpHeaders.Names.CONTENT_TRANSFER_ENCODING +
+ ": " + HttpPostBodyUtil.TransferEncodingMechanism.BINARY.value +
"\r\n\r\n");
} else if (fileUpload.getCharset() != null) {
- internal.addValue("; "+HttpHeaders.Values.CHARSET+"="+
- fileUpload.getCharset()+"\r\n\r\n");
+ internal.addValue("; " + HttpHeaders.Values.CHARSET + "=" +
+ fileUpload.getCharset() + "\r\n\r\n");
} else {
internal.addValue("\r\n\r\n");
}
multipartHttpDatas.add(internal);
multipartHttpDatas.add(data);
- globalBodySize += fileUpload.length()+internal.size();
+ globalBodySize += fileUpload.length() + internal.size();
}
}
/**
* Iterator to be used when encoding will be called chunk after chunk
*/
- private ListIterator iterator = null;
+ private ListIterator iterator;
/**
* Finalize the request by preparing the Header in the request and
@@ -573,9 +572,9 @@ public class HttpPostRequestEncoder implements ChunkedInput {
if (isMultipart) {
InternalAttribute internal = new InternalAttribute();
if (duringMixedMode) {
- internal.addValue("\r\n--"+multipartMixedBoundary+"--");
+ internal.addValue("\r\n--" + multipartMixedBoundary + "--");
}
- internal.addValue("\r\n--"+multipartDataBoundary+"--\r\n");
+ internal.addValue("\r\n--" + multipartDataBoundary + "--\r\n");
multipartHttpDatas.add(internal);
multipartMixedBoundary = null;
currentFileUpload = null;
@@ -597,7 +596,7 @@ public class HttpPostRequestEncoder implements ChunkedInput {
HttpHeaders.Values.MULTIPART_FORM_DATA)) {
// ignore
} else if (contentType.toLowerCase().startsWith(
- HttpHeaders.Values.APPLICATION_X_WWW_FORM_URLENCODED)){
+ HttpHeaders.Values.APPLICATION_X_WWW_FORM_URLENCODED)) {
// ignore
} else {
request.addHeader(HttpHeaders.Names.CONTENT_TYPE, contentType);
@@ -675,11 +674,11 @@ public class HttpPostRequestEncoder implements ChunkedInput {
/**
* The ChannelBuffer currently used by the encoder
*/
- private ChannelBuffer currentBuffer = null;
+ private ChannelBuffer currentBuffer;
/**
* The current InterfaceHttpData to encode (used if more chunks are available)
*/
- private InterfaceHttpData currentData = null;
+ private InterfaceHttpData currentData;
/**
* If not multipart, does the currentBuffer stands for the Key or for the Value
*/
@@ -787,12 +786,12 @@ public class HttpPostRequestEncoder implements ChunkedInput {
currentBuffer = ChannelBuffers.wrappedBuffer(
buffer, ChannelBuffers.wrappedBuffer("=".getBytes()));
//continue
- size -= buffer.readableBytes()+1;
+ size -= buffer.readableBytes() + 1;
} else {
currentBuffer = ChannelBuffers.wrappedBuffer(currentBuffer,
buffer, ChannelBuffers.wrappedBuffer("=".getBytes()));
//continue
- size -= buffer.readableBytes()+1;
+ size -= buffer.readableBytes() + 1;
}
if (currentBuffer.readableBytes() >= HttpPostBodyUtil.chunkSize) {
buffer = fillChannelBuffer();
diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/HttpRequestDecoder.java b/codec-http/src/main/java/io/netty/handler/codec/http/HttpRequestDecoder.java
index ff6897b450..9d2d0665d1 100644
--- a/codec-http/src/main/java/io/netty/handler/codec/http/HttpRequestDecoder.java
+++ b/codec-http/src/main/java/io/netty/handler/codec/http/HttpRequestDecoder.java
@@ -71,7 +71,7 @@ public class HttpRequestDecoder extends HttpMessageDecoder {
}
@Override
- protected HttpMessage createMessage(String[] initialLine) throws Exception{
+ protected HttpMessage createMessage(String[] initialLine) throws Exception {
return new DefaultHttpRequest(
HttpVersion.valueOf(initialLine[2]), HttpMethod.valueOf(initialLine[0]), initialLine[1]);
}
diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/MemoryAttribute.java b/codec-http/src/main/java/io/netty/handler/codec/http/MemoryAttribute.java
index 93881613e7..0a9bfb8c53 100644
--- a/codec-http/src/main/java/io/netty/handler/codec/http/MemoryAttribute.java
+++ b/codec-http/src/main/java/io/netty/handler/codec/http/MemoryAttribute.java
@@ -36,8 +36,7 @@ public class MemoryAttribute extends AbstractMemoryHttpData implements Attribute
* @throws IllegalArgumentException
* @throws IOException
*/
- public MemoryAttribute(String name, String value)
- throws NullPointerException, IllegalArgumentException, IOException {
+ public MemoryAttribute(String name, String value) throws IOException {
super(name, HttpCodecUtil.DEFAULT_CHARSET, 0); // Attribute have no default size
setValue(value);
}
diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/MemoryFileUpload.java b/codec-http/src/main/java/io/netty/handler/codec/http/MemoryFileUpload.java
index f3f2509d81..25c3d236f8 100644
--- a/codec-http/src/main/java/io/netty/handler/codec/http/MemoryFileUpload.java
+++ b/codec-http/src/main/java/io/netty/handler/codec/http/MemoryFileUpload.java
@@ -24,15 +24,14 @@ import java.nio.charset.Charset;
*/
public class MemoryFileUpload extends AbstractMemoryHttpData implements FileUpload {
- private String filename = null;
+ private String filename;
- private String contentType = null;
+ private String contentType;
- private String contentTransferEncoding = null;
+ private String contentTransferEncoding;
public MemoryFileUpload(String name, String filename, String contentType,
- String contentTransferEncoding, Charset charset, long size)
- throws NullPointerException, IllegalArgumentException {
+ String contentTransferEncoding, Charset charset, long size) {
super(name, charset, size);
setFilename(filename);
setContentType(contentType);
@@ -116,11 +115,11 @@ public class MemoryFileUpload extends AbstractMemoryHttpData implements FileUplo
@Override
public String toString() {
return HttpPostBodyUtil.CONTENT_DISPOSITION+": "+
- HttpPostBodyUtil.FORM_DATA+"; "+HttpPostBodyUtil.NAME+"=\"" + getName() +
- "\"; "+HttpPostBodyUtil.FILENAME+"=\"" + filename + "\"\r\n" +
- HttpHeaders.Names.CONTENT_TYPE+": " + contentType +
- (charset != null? "; "+HttpHeaders.Values.CHARSET+"=" + charset + "\r\n" : "\r\n") +
- HttpHeaders.Names.CONTENT_LENGTH+": " + length() + "\r\n" +
+ HttpPostBodyUtil.FORM_DATA + "; " + HttpPostBodyUtil.NAME+"=\"" + getName() +
+ "\"; " + HttpPostBodyUtil.FILENAME + "=\"" + filename + "\"\r\n" +
+ HttpHeaders.Names.CONTENT_TYPE + ": " + contentType +
+ (charset != null? "; " + HttpHeaders.Values.CHARSET + "=" + charset + "\r\n" : "\r\n") +
+ HttpHeaders.Names.CONTENT_LENGTH + ": " + length() + "\r\n" +
"Completed: " + isCompleted() +
"\r\nIsInMemory: " + isInMemory();
}
diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/MixedAttribute.java b/codec-http/src/main/java/io/netty/handler/codec/http/MixedAttribute.java
index 045a39c395..5aa301037c 100644
--- a/codec-http/src/main/java/io/netty/handler/codec/http/MixedAttribute.java
+++ b/codec-http/src/main/java/io/netty/handler/codec/http/MixedAttribute.java
@@ -26,20 +26,16 @@ import io.netty.buffer.ChannelBuffer;
* Mixed implementation using both in Memory and in File with a limit of size
*/
public class MixedAttribute implements Attribute {
- private Attribute attribute = null;
+ private Attribute attribute;
- private long limitSize = 0;
+ private long limitSize;
- public MixedAttribute(String name,
- long limitSize) throws NullPointerException,
- IllegalArgumentException {
+ public MixedAttribute(String name, long limitSize) {
this.limitSize = limitSize;
attribute = new MemoryAttribute(name);
}
- public MixedAttribute(String name, String value,
- long limitSize) throws NullPointerException,
- IllegalArgumentException {
+ public MixedAttribute(String name, String value, long limitSize) {
this.limitSize = limitSize;
if (value.length() > this.limitSize) {
try {
@@ -62,8 +58,7 @@ public class MixedAttribute implements Attribute {
}
@Override
- public void addContent(ChannelBuffer buffer, boolean last)
- throws IOException {
+ public void addContent(ChannelBuffer buffer, boolean last) throws IOException {
if (attribute instanceof MemoryAttribute) {
if (attribute.length() + buffer.readableBytes() > limitSize) {
DiskAttribute diskAttribute = new DiskAttribute(attribute
diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/MixedFileUpload.java b/codec-http/src/main/java/io/netty/handler/codec/http/MixedFileUpload.java
index b98c9375f9..6f0146cb37 100644
--- a/codec-http/src/main/java/io/netty/handler/codec/http/MixedFileUpload.java
+++ b/codec-http/src/main/java/io/netty/handler/codec/http/MixedFileUpload.java
@@ -26,16 +26,15 @@ import io.netty.buffer.ChannelBuffer;
* Mixed implementation using both in Memory and in File with a limit of size
*/
public class MixedFileUpload implements FileUpload {
- private FileUpload fileUpload = null;
+ private FileUpload fileUpload;
- private long limitSize = 0;
+ private long limitSize;
- private long definedSize = 0;
+ private long definedSize;
public MixedFileUpload(String name, String filename, String contentType,
String contentTransferEncoding, Charset charset, long size,
- long limitSize) throws NullPointerException,
- IllegalArgumentException {
+ long limitSize) {
this.limitSize = limitSize;
if (size > this.limitSize) {
fileUpload = new DiskFileUpload(name, filename, contentType,
@@ -57,7 +56,7 @@ public class MixedFileUpload implements FileUpload {
.getContentType(), fileUpload
.getContentTransferEncoding(), fileUpload.getCharset(),
definedSize);
- if (((MemoryFileUpload) fileUpload).getChannelBuffer() != null){
+ if (((MemoryFileUpload) fileUpload).getChannelBuffer() != null) {
diskFileUpload.addContent(((MemoryFileUpload) fileUpload)
.getChannelBuffer(), last);
}
diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/QueryStringDecoder.java b/codec-http/src/main/java/io/netty/handler/codec/http/QueryStringDecoder.java
index f1e2972d9d..d78198f273 100644
--- a/codec-http/src/main/java/io/netty/handler/codec/http/QueryStringDecoder.java
+++ b/codec-http/src/main/java/io/netty/handler/codec/http/QueryStringDecoder.java
@@ -135,7 +135,7 @@ public class QueryStringDecoder {
* Creates a new decoder that decodes the specified URI encoded in the
* specified charset.
*/
- public QueryStringDecoder(URI uri, Charset charset){
+ public QueryStringDecoder(URI uri, Charset charset) {
this(uri, charset, DEFAULT_MAX_PARAMS);
}
@@ -174,8 +174,7 @@ public class QueryStringDecoder {
int pathEndPos = uri.indexOf('?');
if (pathEndPos < 0) {
path = uri;
- }
- else {
+ } else {
return path = uri.substring(0, pathEndPos);
}
}
diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/QueryStringEncoder.java b/codec-http/src/main/java/io/netty/handler/codec/http/QueryStringEncoder.java
index f45fcd8a36..cf1211c806 100644
--- a/codec-http/src/main/java/io/netty/handler/codec/http/QueryStringEncoder.java
+++ b/codec-http/src/main/java/io/netty/handler/codec/http/QueryStringEncoder.java
@@ -106,7 +106,7 @@ public class QueryStringEncoder {
sb.append(encodeComponent(param.name, charset));
sb.append("=");
sb.append(encodeComponent(param.value, charset));
- if(i != params.size() - 1) {
+ if (i != params.size() - 1) {
sb.append("&");
}
}
diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/ContinuationWebSocketFrame.java b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/ContinuationWebSocketFrame.java
index ca77115803..bb2df42aa5 100644
--- a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/ContinuationWebSocketFrame.java
+++ b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/ContinuationWebSocketFrame.java
@@ -25,7 +25,7 @@ import io.netty.util.CharsetUtil;
*/
public class ContinuationWebSocketFrame extends WebSocketFrame {
- private String aggregatedText = null;
+ private String aggregatedText;
/**
* Creates a new empty continuation frame.
diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/UTF8Output.java b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/UTF8Output.java
index 58a2872a39..4477699fbc 100644
--- a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/UTF8Output.java
+++ b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/UTF8Output.java
@@ -42,7 +42,7 @@ final class UTF8Output {
12, 12, 12, 12, 12, 12, 12, 12 };
private int state = UTF8_ACCEPT;
- private int codep = 0;
+ private int codep;
private final StringBuilder stringBuilder;
@@ -60,7 +60,7 @@ final class UTF8Output {
public void write(int b) {
byte type = TYPES[b & 0xFF];
- codep = (state != UTF8_ACCEPT) ? (b & 0x3f) | (codep << 6) : (0xff >> type) & (b);
+ codep = (state != UTF8_ACCEPT) ? (b & 0x3f) | (codep << 6) : (0xff >> type) & b;
state = STATES[state + type];
diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocket08FrameDecoder.java b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocket08FrameDecoder.java
index 42bc5f6220..518567c8bc 100644
--- a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocket08FrameDecoder.java
+++ b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocket08FrameDecoder.java
@@ -64,20 +64,20 @@ public class WebSocket08FrameDecoder extends ReplayingDecoder> 4;
- frameOpcode = (b & 0x0F);
+ frameOpcode = b & 0x0F;
if (logger.isDebugEnabled()) {
logger.debug("Decoding WebSocket Frame opCode=" + frameOpcode);
@@ -127,7 +127,7 @@ public class WebSocket08FrameDecoder extends ReplayingDecoder>> 8) & 0xFF);
- header.writeByte((length) & 0xFF);
+ header.writeByte(length & 0xFF);
} else {
header = ChannelBuffers.buffer(10 + maskLength);
header.writeByte(b0);
- header.writeByte(this.maskPayload ? (0xFF) : 127);
+ header.writeByte(this.maskPayload ? 0xFF : 127);
header.writeLong(length);
}
@@ -170,4 +170,4 @@ public class WebSocket08FrameEncoder extends OneToOneEncoder {
return msg;
}
-}
\ No newline at end of file
+}
diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketClientHandshaker.java b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketClientHandshaker.java
index 4493968db2..23a4d7263c 100644
--- a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketClientHandshaker.java
+++ b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketClientHandshaker.java
@@ -36,20 +36,14 @@ public abstract class WebSocketClientHandshaker {
private WebSocketVersion version = WebSocketVersion.UNKNOWN;
- private boolean openingHandshakeCompleted = false;
+ private boolean openingHandshakeCompleted;
- private String subProtocolRequest = null;
+ private String subProtocolRequest;
- private String subProtocolResponse = null;
+ private String subProtocolResponse;
- protected Map customHeaders = null;
+ protected Map customHeaders;
- /**
- *
- * @param webSocketURL
- * @param version
- * @param subProtocol
- */
public WebSocketClientHandshaker(URI webSocketURL, WebSocketVersion version, String subProtocol,
Map customHeaders) {
this.webSocketURL = webSocketURL;
diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketClientHandshaker00.java b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketClientHandshaker00.java
index 2fbfbaed54..cfe0b69b05 100644
--- a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketClientHandshaker00.java
+++ b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketClientHandshaker00.java
@@ -45,7 +45,7 @@ import io.netty.handler.codec.http.HttpVersion;
*/
public class WebSocketClientHandshaker00 extends WebSocketClientHandshaker {
- private byte[] expectedChallengeResponseBytes = null;
+ private byte[] expectedChallengeResponseBytes;
/**
* Constructor specifying the destination web socket location and version to initiate
diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketClientHandshaker08.java b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketClientHandshaker08.java
index 703a2ca789..5ee0c635fd 100644
--- a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketClientHandshaker08.java
+++ b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketClientHandshaker08.java
@@ -46,11 +46,11 @@ public class WebSocketClientHandshaker08 extends WebSocketClientHandshaker {
public static final String MAGIC_GUID = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11";
- private String expectedChallengeResponseString = null;
+ private String expectedChallengeResponseString;
private static final String protocol = null;
- private boolean allowExtensions = false;
+ private boolean allowExtensions;
/**
* Constructor specifying the destination web socket location and version to initiate
diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketClientHandshaker13.java b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketClientHandshaker13.java
index 491636b037..82a79514e8 100644
--- a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketClientHandshaker13.java
+++ b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketClientHandshaker13.java
@@ -46,11 +46,11 @@ public class WebSocketClientHandshaker13 extends WebSocketClientHandshaker {
public static final String MAGIC_GUID = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11";
- private String expectedChallengeResponseString = null;
+ private String expectedChallengeResponseString;
private static final String protocol = null;
- private boolean allowExtensions = false;
+ private boolean allowExtensions;
/**
* Constructor specifying the destination web socket location and version to initiate
diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketFrame.java b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketFrame.java
index 2f237915bd..9bad30d5c7 100644
--- a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketFrame.java
+++ b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketFrame.java
@@ -31,7 +31,7 @@ public abstract class WebSocketFrame {
/**
* RSV1, RSV2, RSV3 used for extensions
*/
- private int rsv = 0;
+ private int rsv;
/**
* Contents of this frame
diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketServerHandshaker.java b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketServerHandshaker.java
index f88b72020b..fd7d29e884 100644
--- a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketServerHandshaker.java
+++ b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketServerHandshaker.java
@@ -34,7 +34,7 @@ public abstract class WebSocketServerHandshaker {
private String subProtocols;
- private String[] subProtocolsArray = null;
+ private String[] subProtocolsArray;
private WebSocketVersion version = WebSocketVersion.UNKNOWN;
diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketServerHandshaker08.java b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketServerHandshaker08.java
index e26c4812c4..755ea7c992 100644
--- a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketServerHandshaker08.java
+++ b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketServerHandshaker08.java
@@ -49,7 +49,7 @@ public class WebSocketServerHandshaker08 extends WebSocketServerHandshaker {
public static final String WEBSOCKET_08_ACCEPT_GUID = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11";
- private boolean allowExtensions = false;
+ private boolean allowExtensions;
/**
* Constructor specifying the destination web socket location
diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketServerHandshaker13.java b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketServerHandshaker13.java
index ea470a3691..b87fc20b58 100644
--- a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketServerHandshaker13.java
+++ b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketServerHandshaker13.java
@@ -50,7 +50,7 @@ public class WebSocketServerHandshaker13 extends WebSocketServerHandshaker {
public static final String WEBSOCKET_13_ACCEPT_GUID = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11";
- private boolean allowExtensions = false;
+ private boolean allowExtensions;
/**
* Constructor specifying the destination web socket location
diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketServerHandshakerFactory.java b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketServerHandshakerFactory.java
index 7dc15f72dd..9badcd0d45 100644
--- a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketServerHandshakerFactory.java
+++ b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketServerHandshakerFactory.java
@@ -32,7 +32,7 @@ public class WebSocketServerHandshakerFactory {
private final String subProtocols;
- private boolean allowExtensions = false;
+ private boolean allowExtensions;
/**
* Constructor specifying the destination web socket location
diff --git a/codec/src/main/java/io/netty/handler/codec/base64/Base64.java b/codec/src/main/java/io/netty/handler/codec/base64/Base64.java
index 64339345ee..f6d01c99da 100644
--- a/codec/src/main/java/io/netty/handler/codec/base64/Base64.java
+++ b/codec/src/main/java/io/netty/handler/codec/base64/Base64.java
@@ -32,7 +32,7 @@ import io.netty.buffer.HeapChannelBufferFactory;
* @apiviz.landmark
* @apiviz.uses io.netty.handler.codec.base64.Base64Dialect
*/
-public class Base64 {
+public final class Base64 {
/** Maximum line length (76) of Base64 output. */
private static final int MAX_LINE_LENGTH = 76;
@@ -207,7 +207,7 @@ public class Base64 {
// We have to shift left 24 in order to flush out the 1's that appear
// when Java treats a value as negative that is cast from a byte to an int.
int inBuff =
- (numSigBytes > 0? src.getByte(srcOffset ) << 24 >>> 8 : 0) |
+ (numSigBytes > 0? src.getByte(srcOffset) << 24 >>> 8 : 0) |
(numSigBytes > 1? src.getByte(srcOffset + 1) << 24 >>> 16 : 0) |
(numSigBytes > 2? src.getByte(srcOffset + 2) << 24 >>> 24 : 0);
@@ -301,9 +301,9 @@ public class Base64 {
sbiDecode = DECODABET[sbiCrop];
if (sbiDecode >= WHITE_SPACE_ENC) { // White space, Equals sign or better
- if (sbiDecode >= EQUALS_SIGN_ENC) {
+ if (sbiDecode >= EQUALS_SIGN_ENC) { // Equals sign or better
b4[b4Posn ++] = sbiCrop;
- if (b4Posn > 3) {
+ if (b4Posn > 3) { // Quartet built
outBuffPosn += decode4to3(
b4, 0, dest, outBuffPosn, dialect);
b4Posn = 0;
@@ -312,10 +312,9 @@ public class Base64 {
if (sbiCrop == EQUALS_SIGN) {
break;
}
- } // end if: quartet built
- } // end if: equals sign or better
- } // end if: white space, equals sign or better
- else {
+ }
+ }
+ } else {
throw new IllegalArgumentException(
"bad Base64 input character at " + i + ": " +
src.getUnsignedByte(i) + " (decimal)");
@@ -331,18 +330,16 @@ public class Base64 {
byte[] DECODABET = decodabet(dialect);
- // Example: Dk==
if (src[srcOffset + 2] == EQUALS_SIGN) {
+ // Example: Dk==
int outBuff =
(DECODABET[src[srcOffset ]] & 0xFF) << 18 |
(DECODABET[src[srcOffset + 1]] & 0xFF) << 12;
dest.setByte(destOffset, (byte) (outBuff >>> 16));
return 1;
- }
-
- // Example: DkL=
- else if (src[srcOffset + 3] == EQUALS_SIGN) {
+ } else if (src[srcOffset + 3] == EQUALS_SIGN) {
+ // Example: DkL=
int outBuff =
(DECODABET[src[srcOffset ]] & 0xFF) << 18 |
(DECODABET[src[srcOffset + 1]] & 0xFF) << 12 |
@@ -351,10 +348,8 @@ public class Base64 {
dest.setByte(destOffset , (byte) (outBuff >>> 16));
dest.setByte(destOffset + 1, (byte) (outBuff >>> 8));
return 2;
- }
-
- // Example: DkLE
- else {
+ } else {
+ // Example: DkLE
int outBuff;
try {
outBuff =
diff --git a/codec/src/main/java/io/netty/handler/codec/bytes/ByteArrayDecoder.java b/codec/src/main/java/io/netty/handler/codec/bytes/ByteArrayDecoder.java
index bfd305297f..c8ef66f2c4 100644
--- a/codec/src/main/java/io/netty/handler/codec/bytes/ByteArrayDecoder.java
+++ b/codec/src/main/java/io/netty/handler/codec/bytes/ByteArrayDecoder.java
@@ -56,7 +56,7 @@ public class ByteArrayDecoder extends OneToOneDecoder {
if (!(msg instanceof ChannelBuffer)) {
return msg;
}
- ChannelBuffer buf = (ChannelBuffer )msg;
+ ChannelBuffer buf = (ChannelBuffer) msg;
byte[] array;
if (buf.hasArray()) {
if (buf.arrayOffset() == 0 && buf.readableBytes() == buf.capacity()) {
diff --git a/codec/src/main/java/io/netty/handler/codec/compression/ZlibEncoder.java b/codec/src/main/java/io/netty/handler/codec/compression/ZlibEncoder.java
index 960269536a..7a1834e480 100644
--- a/codec/src/main/java/io/netty/handler/codec/compression/ZlibEncoder.java
+++ b/codec/src/main/java/io/netty/handler/codec/compression/ZlibEncoder.java
@@ -157,7 +157,7 @@ public class ZlibEncoder extends OneToOneEncoder implements LifeCycleAwareChanne
ZlibUtil.fail(z, "initialization failure", resultCode);
} else {
resultCode = z.deflateSetDictionary(dictionary, dictionary.length);
- if (resultCode != JZlib.Z_OK){
+ if (resultCode != JZlib.Z_OK) {
ZlibUtil.fail(z, "failed to set the dictionary", resultCode);
}
}
diff --git a/codec/src/main/java/io/netty/handler/codec/embedder/EmbeddedChannelFactory.java b/codec/src/main/java/io/netty/handler/codec/embedder/EmbeddedChannelFactory.java
index c2bd56bbf9..c7a8e197fb 100644
--- a/codec/src/main/java/io/netty/handler/codec/embedder/EmbeddedChannelFactory.java
+++ b/codec/src/main/java/io/netty/handler/codec/embedder/EmbeddedChannelFactory.java
@@ -21,7 +21,7 @@ import io.netty.channel.ChannelPipeline;
/**
*/
-class EmbeddedChannelFactory implements ChannelFactory {
+final class EmbeddedChannelFactory implements ChannelFactory {
static final ChannelFactory INSTANCE = new EmbeddedChannelFactory();
diff --git a/codec/src/main/java/io/netty/handler/codec/frame/Delimiters.java b/codec/src/main/java/io/netty/handler/codec/frame/Delimiters.java
index e00a059940..8ffc2a5255 100644
--- a/codec/src/main/java/io/netty/handler/codec/frame/Delimiters.java
+++ b/codec/src/main/java/io/netty/handler/codec/frame/Delimiters.java
@@ -21,7 +21,7 @@ import io.netty.buffer.ChannelBuffers;
/**
* A set of commonly used delimiters for {@link DelimiterBasedFrameDecoder}.
*/
-public class Delimiters {
+public final class Delimiters {
/**
* Returns a {@code NUL (0x00)} delimiter, which could be used for
diff --git a/codec/src/main/java/io/netty/handler/codec/frame/LengthFieldBasedFrameDecoder.java b/codec/src/main/java/io/netty/handler/codec/frame/LengthFieldBasedFrameDecoder.java
index 33d95675d9..472184bdf1 100644
--- a/codec/src/main/java/io/netty/handler/codec/frame/LengthFieldBasedFrameDecoder.java
+++ b/codec/src/main/java/io/netty/handler/codec/frame/LengthFieldBasedFrameDecoder.java
@@ -145,8 +145,8 @@ import io.netty.handler.codec.serialization.ObjectDecoder;
* header from the frame. If you don't want to strip the prepended header, you
* could specify 0 for initialBytesToSkip.
*
- * lengthFieldOffset = 1 (= the length of HDR1)
- * lengthFieldLength = 2
+ * lengthFieldOffset = 1 (= the length of HDR1)
+ * lengthFieldLength = 2
* lengthAdjustment = 1 (= the length of HDR2)
* initialBytesToStrip = 3 (= the length of HDR1 + LEN)
*
@@ -403,14 +403,12 @@ public class LengthFieldBasedFrameDecoder extends FrameDecoder {
this.tooLongFrameLength = 0;
discardingTooLongFrame = false;
if ((!failFast) ||
- (failFast && firstDetectionOfTooLongFrame))
- {
+ (failFast && firstDetectionOfTooLongFrame)) {
fail(ctx, tooLongFrameLength);
}
} else {
// Keep discarding and notify handlers if necessary.
- if (failFast && firstDetectionOfTooLongFrame)
- {
+ if (failFast && firstDetectionOfTooLongFrame) {
fail(ctx, this.tooLongFrameLength);
}
}
diff --git a/codec/src/main/java/io/netty/handler/codec/protobuf/ProtobufDecoder.java b/codec/src/main/java/io/netty/handler/codec/protobuf/ProtobufDecoder.java
index 2aadf3552b..e15c13fa6c 100644
--- a/codec/src/main/java/io/netty/handler/codec/protobuf/ProtobufDecoder.java
+++ b/codec/src/main/java/io/netty/handler/codec/protobuf/ProtobufDecoder.java
@@ -94,7 +94,7 @@ public class ProtobufDecoder extends OneToOneDecoder {
ChannelBuffer buf = (ChannelBuffer) msg;
if (buf.hasArray()) {
final int offset = buf.readerIndex();
- if(extensionRegistry == null) {
+ if (extensionRegistry == null) {
return prototype.newBuilderForType().mergeFrom(
buf.array(), buf.arrayOffset() + offset, buf.readableBytes()).build();
} else {
diff --git a/codec/src/main/java/io/netty/handler/codec/serialization/ClassResolvers.java b/codec/src/main/java/io/netty/handler/codec/serialization/ClassResolvers.java
index c6c756e94f..edf1ab608c 100644
--- a/codec/src/main/java/io/netty/handler/codec/serialization/ClassResolvers.java
+++ b/codec/src/main/java/io/netty/handler/codec/serialization/ClassResolvers.java
@@ -19,7 +19,7 @@ import java.lang.ref.Reference;
import java.util.HashMap;
import java.util.concurrent.ConcurrentHashMap;
-public class ClassResolvers {
+public final class ClassResolvers {
/**
* cache disabled
@@ -86,4 +86,8 @@ public class ClassResolvers {
return ClassResolvers.class.getClassLoader();
}
+
+ private ClassResolvers() {
+ // Unused
+ }
}
diff --git a/codec/src/main/java/io/netty/handler/codec/serialization/ObjectDecoderInputStream.java b/codec/src/main/java/io/netty/handler/codec/serialization/ObjectDecoderInputStream.java
index 0d9daece52..3772b87eb6 100644
--- a/codec/src/main/java/io/netty/handler/codec/serialization/ObjectDecoderInputStream.java
+++ b/codec/src/main/java/io/netty/handler/codec/serialization/ObjectDecoderInputStream.java
@@ -191,6 +191,9 @@ public class ObjectDecoderInputStream extends InputStream implements
return in.readInt();
}
+ /**
+ * @deprecated Use {@link java.io.BufferedReader#readLine()} instead.
+ */
@Override
@Deprecated
public final String readLine() throws IOException {
diff --git a/common/src/main/java/io/netty/util/CharsetUtil.java b/common/src/main/java/io/netty/util/CharsetUtil.java
index df0c4bcfb6..49c44641cf 100644
--- a/common/src/main/java/io/netty/util/CharsetUtil.java
+++ b/common/src/main/java/io/netty/util/CharsetUtil.java
@@ -26,7 +26,7 @@ import java.util.Map;
* A utility class that provides various common operations and constants
* related with {@link Charset} and its relevant classes.
*/
-public class CharsetUtil {
+public final class CharsetUtil {
/**
* 16-bit UTF (UCS Transformation Format) whose byte order is identified by
@@ -61,7 +61,7 @@ public class CharsetUtil {
public static final Charset US_ASCII = Charset.forName("US-ASCII");
private static final ThreadLocal