migrate java8: use requireNonNull (#8840)
Motivation: We can just use Objects.requireNonNull(...) as a replacement for ObjectUtil.checkNotNull(....) Modifications: - Use Objects.requireNonNull(...) Result: Less code to maintain.
This commit is contained in:
parent
2e433889b2
commit
e8efcd82a8
@ -39,6 +39,7 @@ import java.nio.charset.Charset;
|
||||
|
||||
import static io.netty.util.internal.MathUtil.isOutOfBounds;
|
||||
import static io.netty.util.internal.ObjectUtil.checkPositiveOrZero;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
/**
|
||||
* A skeletal implementation of a buffer.
|
||||
@ -282,9 +283,7 @@ public abstract class AbstractByteBuf extends ByteBuf {
|
||||
if (endianness == order()) {
|
||||
return this;
|
||||
}
|
||||
if (endianness == null) {
|
||||
throw new NullPointerException("endianness");
|
||||
}
|
||||
requireNonNull(endianness, "endianness");
|
||||
return newSwappedByteBuf();
|
||||
}
|
||||
|
||||
@ -592,9 +591,7 @@ public abstract class AbstractByteBuf extends ByteBuf {
|
||||
@Override
|
||||
public ByteBuf setBytes(int index, ByteBuf src, int length) {
|
||||
checkIndex(index, length);
|
||||
if (src == null) {
|
||||
throw new NullPointerException("src");
|
||||
}
|
||||
requireNonNull(src, "src");
|
||||
if (checkBounds) {
|
||||
checkReadableBounds(src, length);
|
||||
}
|
||||
|
@ -15,6 +15,8 @@
|
||||
*/
|
||||
package io.netty.buffer;
|
||||
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
import io.netty.util.ReferenceCounted;
|
||||
import io.netty.util.internal.StringUtil;
|
||||
|
||||
@ -104,9 +106,7 @@ public class ByteBufInputStream extends InputStream implements DataInput {
|
||||
* {@code writerIndex}
|
||||
*/
|
||||
public ByteBufInputStream(ByteBuf buffer, int length, boolean releaseOnClose) {
|
||||
if (buffer == null) {
|
||||
throw new NullPointerException("buffer");
|
||||
}
|
||||
requireNonNull(buffer, "buffer");
|
||||
if (length < 0) {
|
||||
if (releaseOnClose) {
|
||||
buffer.release();
|
||||
|
@ -15,6 +15,8 @@
|
||||
*/
|
||||
package io.netty.buffer;
|
||||
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
import io.netty.util.CharsetUtil;
|
||||
|
||||
import java.io.DataOutput;
|
||||
@ -45,9 +47,7 @@ public class ByteBufOutputStream extends OutputStream implements DataOutput {
|
||||
* Creates a new stream which writes data to the specified {@code buffer}.
|
||||
*/
|
||||
public ByteBufOutputStream(ByteBuf buffer) {
|
||||
if (buffer == null) {
|
||||
throw new NullPointerException("buffer");
|
||||
}
|
||||
requireNonNull(buffer, "buffer");
|
||||
this.buffer = buffer;
|
||||
startIndex = buffer.writerIndex();
|
||||
}
|
||||
|
@ -42,10 +42,10 @@ import java.util.Arrays;
|
||||
import java.util.Locale;
|
||||
|
||||
import static io.netty.util.internal.MathUtil.isOutOfBounds;
|
||||
import static io.netty.util.internal.ObjectUtil.checkNotNull;
|
||||
import static io.netty.util.internal.ObjectUtil.checkPositiveOrZero;
|
||||
import static io.netty.util.internal.StringUtil.NEWLINE;
|
||||
import static io.netty.util.internal.StringUtil.isSurrogate;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
/**
|
||||
* A collection of utility methods that is related with handling {@link ByteBuf},
|
||||
@ -884,7 +884,7 @@ public final class ByteBufUtil {
|
||||
+ length + ") <= srcLen(" + src.length() + ')');
|
||||
}
|
||||
|
||||
checkNotNull(dst, "dst").setBytes(dstIdx, src.array(), srcIdx + src.arrayOffset(), length);
|
||||
requireNonNull(dst, "dst").setBytes(dstIdx, src.array(), srcIdx + src.arrayOffset(), length);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -901,7 +901,7 @@ public final class ByteBufUtil {
|
||||
+ length + ") <= srcLen(" + src.length() + ')');
|
||||
}
|
||||
|
||||
checkNotNull(dst, "dst").writeBytes(src.array(), srcIdx + src.arrayOffset(), length);
|
||||
requireNonNull(dst, "dst").writeBytes(src.array(), srcIdx + src.arrayOffset(), length);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1217,8 +1217,8 @@ public final class ByteBufUtil {
|
||||
* @throws IndexOutOfBoundsException if {@code index} + {@code length} is greater than {@code buf.readableBytes}
|
||||
*/
|
||||
public static boolean isText(ByteBuf buf, int index, int length, Charset charset) {
|
||||
checkNotNull(buf, "buf");
|
||||
checkNotNull(charset, "charset");
|
||||
requireNonNull(buf, "buf");
|
||||
requireNonNull(charset, "charset");
|
||||
final int maxIndex = buf.readerIndex() + buf.readableBytes();
|
||||
if (index < 0 || length < 0 || index > maxIndex - length) {
|
||||
throw new IndexOutOfBoundsException("index: " + index + " length: " + length);
|
||||
|
@ -15,6 +15,8 @@
|
||||
*/
|
||||
package io.netty.buffer;
|
||||
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
import io.netty.util.ByteProcessor;
|
||||
import io.netty.util.IllegalReferenceCountException;
|
||||
import io.netty.util.ReferenceCountUtil;
|
||||
@ -38,7 +40,6 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
import static io.netty.util.internal.ObjectUtil.checkNotNull;
|
||||
|
||||
/**
|
||||
* A virtual buffer which shows multiple buffers as a single merged buffer. It is recommended to use
|
||||
@ -61,9 +62,7 @@ public class CompositeByteBuf extends AbstractReferenceCountedByteBuf implements
|
||||
|
||||
private CompositeByteBuf(ByteBufAllocator alloc, boolean direct, int maxNumComponents, int initSize) {
|
||||
super(AbstractByteBufAllocator.DEFAULT_MAX_CAPACITY);
|
||||
if (alloc == null) {
|
||||
throw new NullPointerException("alloc");
|
||||
}
|
||||
requireNonNull(alloc, "alloc");
|
||||
if (maxNumComponents < 1) {
|
||||
throw new IllegalArgumentException(
|
||||
"maxNumComponents: " + maxNumComponents + " (expected: >= 1)");
|
||||
@ -232,7 +231,7 @@ public class CompositeByteBuf extends AbstractReferenceCountedByteBuf implements
|
||||
* ownership of all {@link ByteBuf} objects is transferred to this {@link CompositeByteBuf}.
|
||||
*/
|
||||
public CompositeByteBuf addComponents(boolean increaseWriterIndex, ByteBuf... buffers) {
|
||||
checkNotNull(buffers, "buffers");
|
||||
requireNonNull(buffers, "buffers");
|
||||
addComponents0(increaseWriterIndex, componentCount, buffers, 0);
|
||||
consolidateIfNeeded();
|
||||
return this;
|
||||
@ -261,7 +260,7 @@ public class CompositeByteBuf extends AbstractReferenceCountedByteBuf implements
|
||||
* {@link CompositeByteBuf}.
|
||||
*/
|
||||
public CompositeByteBuf addComponent(boolean increaseWriterIndex, int cIndex, ByteBuf buffer) {
|
||||
checkNotNull(buffer, "buffer");
|
||||
requireNonNull(buffer, "buffer");
|
||||
addComponent0(increaseWriterIndex, cIndex, buffer);
|
||||
consolidateIfNeeded();
|
||||
return this;
|
||||
@ -333,7 +332,7 @@ public class CompositeByteBuf extends AbstractReferenceCountedByteBuf implements
|
||||
* ownership of all {@link ByteBuf} objects is transferred to this {@link CompositeByteBuf}.
|
||||
*/
|
||||
public CompositeByteBuf addComponents(int cIndex, ByteBuf... buffers) {
|
||||
checkNotNull(buffers, "buffers");
|
||||
requireNonNull(buffers, "buffers");
|
||||
addComponents0(false, cIndex, buffers, 0);
|
||||
consolidateIfNeeded();
|
||||
return this;
|
||||
@ -422,7 +421,7 @@ public class CompositeByteBuf extends AbstractReferenceCountedByteBuf implements
|
||||
// If buffers also implements ByteBuf (e.g. CompositeByteBuf), it has to go to addComponent(ByteBuf).
|
||||
return addComponent(increaseIndex, cIndex, (ByteBuf) buffers);
|
||||
}
|
||||
checkNotNull(buffers, "buffers");
|
||||
requireNonNull(buffers, "buffers");
|
||||
Iterator<ByteBuf> it = buffers.iterator();
|
||||
try {
|
||||
checkComponentIndex(cIndex);
|
||||
|
@ -15,6 +15,8 @@
|
||||
*/
|
||||
package io.netty.buffer;
|
||||
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
import io.netty.util.IllegalReferenceCountException;
|
||||
import io.netty.util.internal.StringUtil;
|
||||
|
||||
@ -27,9 +29,7 @@ public class DefaultByteBufHolder implements ByteBufHolder {
|
||||
private final ByteBuf data;
|
||||
|
||||
public DefaultByteBufHolder(ByteBuf data) {
|
||||
if (data == null) {
|
||||
throw new NullPointerException("data");
|
||||
}
|
||||
requireNonNull(data, "data");
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
|
@ -17,6 +17,7 @@
|
||||
package io.netty.buffer;
|
||||
|
||||
import static io.netty.util.internal.ObjectUtil.checkPositiveOrZero;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
import io.netty.util.ByteProcessor;
|
||||
import io.netty.util.internal.EmptyArrays;
|
||||
@ -64,9 +65,7 @@ public final class EmptyByteBuf extends ByteBuf {
|
||||
}
|
||||
|
||||
private EmptyByteBuf(ByteBufAllocator alloc, ByteOrder order) {
|
||||
if (alloc == null) {
|
||||
throw new NullPointerException("alloc");
|
||||
}
|
||||
requireNonNull(alloc, "alloc");
|
||||
|
||||
this.alloc = alloc;
|
||||
this.order = order;
|
||||
@ -120,9 +119,7 @@ public final class EmptyByteBuf extends ByteBuf {
|
||||
|
||||
@Override
|
||||
public ByteBuf order(ByteOrder endianness) {
|
||||
if (endianness == null) {
|
||||
throw new NullPointerException("endianness");
|
||||
}
|
||||
requireNonNull(endianness, "endianness");
|
||||
if (endianness == order()) {
|
||||
return this;
|
||||
}
|
||||
|
@ -15,6 +15,8 @@
|
||||
*/
|
||||
package io.netty.buffer;
|
||||
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
import io.netty.util.internal.StringUtil;
|
||||
|
||||
import java.io.IOException;
|
||||
@ -27,7 +29,6 @@ import java.nio.channels.FileChannel;
|
||||
import java.nio.channels.GatheringByteChannel;
|
||||
import java.nio.channels.ScatteringByteChannel;
|
||||
|
||||
|
||||
/**
|
||||
* Read-only ByteBuf which wraps a read-only ByteBuffer.
|
||||
*/
|
||||
@ -209,9 +210,7 @@ class ReadOnlyByteBufferBuf extends AbstractReferenceCountedByteBuf {
|
||||
@Override
|
||||
public ByteBuf getBytes(int index, ByteBuffer dst) {
|
||||
checkIndex(index);
|
||||
if (dst == null) {
|
||||
throw new NullPointerException("dst");
|
||||
}
|
||||
requireNonNull(dst, "dst");
|
||||
|
||||
int bytesToCopy = Math.min(capacity() - index, dst.remaining());
|
||||
ByteBuffer tmpBuf = internalNioBuffer();
|
||||
|
@ -16,10 +16,12 @@
|
||||
package io.netty.buffer;
|
||||
|
||||
|
||||
import io.netty.util.internal.PlatformDependent;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import io.netty.util.internal.PlatformDependent;
|
||||
|
||||
|
||||
/**
|
||||
* Read-only ByteBuf which wraps a read-only direct ByteBuffer and use unsafe for best performance.
|
||||
@ -62,9 +64,7 @@ final class ReadOnlyUnsafeDirectByteBuf extends ReadOnlyByteBufferBuf {
|
||||
@Override
|
||||
public ByteBuf getBytes(int index, ByteBuf dst, int dstIndex, int length) {
|
||||
checkIndex(index, length);
|
||||
if (dst == null) {
|
||||
throw new NullPointerException("dst");
|
||||
}
|
||||
requireNonNull(dst, "dst");
|
||||
if (dstIndex < 0 || dstIndex > dst.capacity() - length) {
|
||||
throw new IndexOutOfBoundsException("dstIndex: " + dstIndex);
|
||||
}
|
||||
@ -82,9 +82,7 @@ final class ReadOnlyUnsafeDirectByteBuf extends ReadOnlyByteBufferBuf {
|
||||
@Override
|
||||
public ByteBuf getBytes(int index, byte[] dst, int dstIndex, int length) {
|
||||
checkIndex(index, length);
|
||||
if (dst == null) {
|
||||
throw new NullPointerException("dst");
|
||||
}
|
||||
requireNonNull(dst, "dst");
|
||||
if (dstIndex < 0 || dstIndex > dst.length - length) {
|
||||
throw new IndexOutOfBoundsException(String.format(
|
||||
"dstIndex: %d, length: %d (expected: range(0, %d))", dstIndex, length, dst.length));
|
||||
@ -99,9 +97,7 @@ final class ReadOnlyUnsafeDirectByteBuf extends ReadOnlyByteBufferBuf {
|
||||
@Override
|
||||
public ByteBuf getBytes(int index, ByteBuffer dst) {
|
||||
checkIndex(index);
|
||||
if (dst == null) {
|
||||
throw new NullPointerException("dst");
|
||||
}
|
||||
requireNonNull(dst, "dst");
|
||||
|
||||
int bytesToCopy = Math.min(capacity() - index, dst.remaining());
|
||||
ByteBuffer tmpBuf = internalNioBuffer();
|
||||
|
@ -16,9 +16,10 @@
|
||||
|
||||
package io.netty.buffer;
|
||||
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
import io.netty.util.ResourceLeakDetector;
|
||||
import io.netty.util.ResourceLeakTracker;
|
||||
import io.netty.util.internal.ObjectUtil;
|
||||
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
@ -34,8 +35,8 @@ class SimpleLeakAwareByteBuf extends WrappedByteBuf {
|
||||
|
||||
SimpleLeakAwareByteBuf(ByteBuf wrapped, ByteBuf trackedByteBuf, ResourceLeakTracker<ByteBuf> leak) {
|
||||
super(wrapped);
|
||||
this.trackedByteBuf = ObjectUtil.checkNotNull(trackedByteBuf, "trackedByteBuf");
|
||||
this.leak = ObjectUtil.checkNotNull(leak, "leak");
|
||||
this.trackedByteBuf = requireNonNull(trackedByteBuf, "trackedByteBuf");
|
||||
this.leak = requireNonNull(leak, "leak");
|
||||
}
|
||||
|
||||
SimpleLeakAwareByteBuf(ByteBuf wrapped, ResourceLeakTracker<ByteBuf> leak) {
|
||||
|
@ -15,9 +15,9 @@
|
||||
*/
|
||||
package io.netty.buffer;
|
||||
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
import io.netty.util.ResourceLeakTracker;
|
||||
import io.netty.util.internal.ObjectUtil;
|
||||
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
@ -27,7 +27,7 @@ class SimpleLeakAwareCompositeByteBuf extends WrappedCompositeByteBuf {
|
||||
|
||||
SimpleLeakAwareCompositeByteBuf(CompositeByteBuf wrapped, ResourceLeakTracker<ByteBuf> leak) {
|
||||
super(wrapped);
|
||||
this.leak = ObjectUtil.checkNotNull(leak, "leak");
|
||||
this.leak = requireNonNull(leak, "leak");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -15,6 +15,8 @@
|
||||
*/
|
||||
package io.netty.buffer;
|
||||
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
import io.netty.util.ByteProcessor;
|
||||
|
||||
import java.io.IOException;
|
||||
@ -40,9 +42,7 @@ public class SwappedByteBuf extends ByteBuf {
|
||||
private final ByteOrder order;
|
||||
|
||||
public SwappedByteBuf(ByteBuf buf) {
|
||||
if (buf == null) {
|
||||
throw new NullPointerException("buf");
|
||||
}
|
||||
requireNonNull(buf, "buf");
|
||||
this.buf = buf;
|
||||
if (buf.order() == ByteOrder.BIG_ENDIAN) {
|
||||
order = ByteOrder.LITTLE_ENDIAN;
|
||||
@ -58,9 +58,7 @@ public class SwappedByteBuf extends ByteBuf {
|
||||
|
||||
@Override
|
||||
public ByteBuf order(ByteOrder endianness) {
|
||||
if (endianness == null) {
|
||||
throw new NullPointerException("endianness");
|
||||
}
|
||||
requireNonNull(endianness, "endianness");
|
||||
if (endianness == order) {
|
||||
return this;
|
||||
}
|
||||
|
@ -15,6 +15,8 @@
|
||||
*/
|
||||
package io.netty.buffer;
|
||||
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
import io.netty.buffer.CompositeByteBuf.ByteWrapper;
|
||||
import io.netty.util.internal.PlatformDependent;
|
||||
|
||||
@ -575,9 +577,7 @@ public final class Unpooled {
|
||||
* {@code 0} and the length of the encoded string respectively.
|
||||
*/
|
||||
public static ByteBuf copiedBuffer(CharSequence string, Charset charset) {
|
||||
if (string == null) {
|
||||
throw new NullPointerException("string");
|
||||
}
|
||||
requireNonNull(string, "string");
|
||||
|
||||
if (string instanceof CharBuffer) {
|
||||
return copiedBuffer((CharBuffer) string, charset);
|
||||
@ -594,9 +594,7 @@ public final class Unpooled {
|
||||
*/
|
||||
public static ByteBuf copiedBuffer(
|
||||
CharSequence string, int offset, int length, Charset charset) {
|
||||
if (string == null) {
|
||||
throw new NullPointerException("string");
|
||||
}
|
||||
requireNonNull(string, "string");
|
||||
if (length == 0) {
|
||||
return EMPTY_BUFFER;
|
||||
}
|
||||
@ -626,9 +624,7 @@ public final class Unpooled {
|
||||
* {@code 0} and the length of the encoded string respectively.
|
||||
*/
|
||||
public static ByteBuf copiedBuffer(char[] array, Charset charset) {
|
||||
if (array == null) {
|
||||
throw new NullPointerException("array");
|
||||
}
|
||||
requireNonNull(array, "array");
|
||||
return copiedBuffer(array, 0, array.length, charset);
|
||||
}
|
||||
|
||||
@ -639,9 +635,7 @@ public final class Unpooled {
|
||||
* {@code 0} and the length of the encoded string respectively.
|
||||
*/
|
||||
public static ByteBuf copiedBuffer(char[] array, int offset, int length, Charset charset) {
|
||||
if (array == null) {
|
||||
throw new NullPointerException("array");
|
||||
}
|
||||
requireNonNull(array, "array");
|
||||
if (length == 0) {
|
||||
return EMPTY_BUFFER;
|
||||
}
|
||||
|
@ -16,6 +16,7 @@
|
||||
package io.netty.buffer;
|
||||
|
||||
import static io.netty.util.internal.ObjectUtil.checkPositiveOrZero;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
import io.netty.util.internal.PlatformDependent;
|
||||
|
||||
@ -51,9 +52,7 @@ public class UnpooledDirectByteBuf extends AbstractReferenceCountedByteBuf {
|
||||
*/
|
||||
public UnpooledDirectByteBuf(ByteBufAllocator alloc, int initialCapacity, int maxCapacity) {
|
||||
super(maxCapacity);
|
||||
if (alloc == null) {
|
||||
throw new NullPointerException("alloc");
|
||||
}
|
||||
requireNonNull(alloc, "alloc");
|
||||
checkPositiveOrZero(initialCapacity, "initialCapacity");
|
||||
checkPositiveOrZero(maxCapacity, "maxCapacity");
|
||||
if (initialCapacity > maxCapacity) {
|
||||
@ -72,12 +71,8 @@ public class UnpooledDirectByteBuf extends AbstractReferenceCountedByteBuf {
|
||||
*/
|
||||
protected UnpooledDirectByteBuf(ByteBufAllocator alloc, ByteBuffer initialBuffer, int maxCapacity) {
|
||||
super(maxCapacity);
|
||||
if (alloc == null) {
|
||||
throw new NullPointerException("alloc");
|
||||
}
|
||||
if (initialBuffer == null) {
|
||||
throw new NullPointerException("initialBuffer");
|
||||
}
|
||||
requireNonNull(alloc, "alloc");
|
||||
requireNonNull(initialBuffer, "initialBuffer");
|
||||
if (!initialBuffer.isDirect()) {
|
||||
throw new IllegalArgumentException("initialBuffer is not a direct buffer.");
|
||||
}
|
||||
|
@ -15,6 +15,8 @@
|
||||
*/
|
||||
package io.netty.buffer;
|
||||
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
import io.netty.util.internal.EmptyArrays;
|
||||
import io.netty.util.internal.PlatformDependent;
|
||||
|
||||
@ -28,8 +30,6 @@ import java.nio.channels.FileChannel;
|
||||
import java.nio.channels.GatheringByteChannel;
|
||||
import java.nio.channels.ScatteringByteChannel;
|
||||
|
||||
import static io.netty.util.internal.ObjectUtil.checkNotNull;
|
||||
|
||||
/**
|
||||
* Big endian Java heap buffer implementation. It is recommended to use
|
||||
* {@link UnpooledByteBufAllocator#heapBuffer(int, int)}, {@link Unpooled#buffer(int)} and
|
||||
@ -50,7 +50,7 @@ public class UnpooledHeapByteBuf extends AbstractReferenceCountedByteBuf {
|
||||
public UnpooledHeapByteBuf(ByteBufAllocator alloc, int initialCapacity, int maxCapacity) {
|
||||
super(maxCapacity);
|
||||
|
||||
checkNotNull(alloc, "alloc");
|
||||
requireNonNull(alloc, "alloc");
|
||||
|
||||
if (initialCapacity > maxCapacity) {
|
||||
throw new IllegalArgumentException(String.format(
|
||||
@ -71,8 +71,8 @@ public class UnpooledHeapByteBuf extends AbstractReferenceCountedByteBuf {
|
||||
protected UnpooledHeapByteBuf(ByteBufAllocator alloc, byte[] initialArray, int maxCapacity) {
|
||||
super(maxCapacity);
|
||||
|
||||
checkNotNull(alloc, "alloc");
|
||||
checkNotNull(initialArray, "initialArray");
|
||||
requireNonNull(alloc, "alloc");
|
||||
requireNonNull(initialArray, "initialArray");
|
||||
|
||||
if (initialArray.length > maxCapacity) {
|
||||
throw new IllegalArgumentException(String.format(
|
||||
|
@ -16,6 +16,7 @@
|
||||
package io.netty.buffer;
|
||||
|
||||
import static io.netty.util.internal.ObjectUtil.checkPositiveOrZero;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
import io.netty.util.internal.PlatformDependent;
|
||||
|
||||
@ -52,9 +53,7 @@ public class UnpooledUnsafeDirectByteBuf extends AbstractReferenceCountedByteBuf
|
||||
*/
|
||||
public UnpooledUnsafeDirectByteBuf(ByteBufAllocator alloc, int initialCapacity, int maxCapacity) {
|
||||
super(maxCapacity);
|
||||
if (alloc == null) {
|
||||
throw new NullPointerException("alloc");
|
||||
}
|
||||
requireNonNull(alloc, "alloc");
|
||||
checkPositiveOrZero(initialCapacity, "initialCapacity");
|
||||
checkPositiveOrZero(maxCapacity, "maxCapacity");
|
||||
if (initialCapacity > maxCapacity) {
|
||||
@ -86,12 +85,8 @@ public class UnpooledUnsafeDirectByteBuf extends AbstractReferenceCountedByteBuf
|
||||
|
||||
UnpooledUnsafeDirectByteBuf(ByteBufAllocator alloc, ByteBuffer initialBuffer, int maxCapacity, boolean doFree) {
|
||||
super(maxCapacity);
|
||||
if (alloc == null) {
|
||||
throw new NullPointerException("alloc");
|
||||
}
|
||||
if (initialBuffer == null) {
|
||||
throw new NullPointerException("initialBuffer");
|
||||
}
|
||||
requireNonNull(alloc, "alloc");
|
||||
requireNonNull(initialBuffer, "initialBuffer");
|
||||
if (!initialBuffer.isDirect()) {
|
||||
throw new IllegalArgumentException("initialBuffer is not a direct buffer.");
|
||||
}
|
||||
|
@ -15,6 +15,8 @@
|
||||
*/
|
||||
package io.netty.buffer;
|
||||
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
/**
|
||||
@ -31,9 +33,7 @@ final class UnreleasableByteBuf extends WrappedByteBuf {
|
||||
|
||||
@Override
|
||||
public ByteBuf order(ByteOrder endianness) {
|
||||
if (endianness == null) {
|
||||
throw new NullPointerException("endianness");
|
||||
}
|
||||
requireNonNull(endianness, "endianness");
|
||||
if (endianness == order()) {
|
||||
return this;
|
||||
}
|
||||
|
@ -25,8 +25,8 @@ import java.nio.ByteOrder;
|
||||
import java.nio.ReadOnlyBufferException;
|
||||
|
||||
import static io.netty.util.internal.MathUtil.isOutOfBounds;
|
||||
import static io.netty.util.internal.ObjectUtil.checkNotNull;
|
||||
import static io.netty.util.internal.PlatformDependent.BIG_ENDIAN_NATIVE_ORDER;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
/**
|
||||
* All operations get and set as {@link ByteOrder#BIG_ENDIAN}.
|
||||
@ -463,7 +463,7 @@ final class UnsafeByteBufUtil {
|
||||
|
||||
static void getBytes(AbstractByteBuf buf, long addr, int index, ByteBuf dst, int dstIndex, int length) {
|
||||
buf.checkIndex(index, length);
|
||||
checkNotNull(dst, "dst");
|
||||
requireNonNull(dst, "dst");
|
||||
if (isOutOfBounds(dstIndex, length, dst.capacity())) {
|
||||
throw new IndexOutOfBoundsException("dstIndex: " + dstIndex);
|
||||
}
|
||||
@ -479,7 +479,7 @@ final class UnsafeByteBufUtil {
|
||||
|
||||
static void getBytes(AbstractByteBuf buf, long addr, int index, byte[] dst, int dstIndex, int length) {
|
||||
buf.checkIndex(index, length);
|
||||
checkNotNull(dst, "dst");
|
||||
requireNonNull(dst, "dst");
|
||||
if (isOutOfBounds(dstIndex, length, dst.length)) {
|
||||
throw new IndexOutOfBoundsException("dstIndex: " + dstIndex);
|
||||
}
|
||||
@ -514,7 +514,7 @@ final class UnsafeByteBufUtil {
|
||||
|
||||
static void setBytes(AbstractByteBuf buf, long addr, int index, ByteBuf src, int srcIndex, int length) {
|
||||
buf.checkIndex(index, length);
|
||||
checkNotNull(src, "src");
|
||||
requireNonNull(src, "src");
|
||||
if (isOutOfBounds(srcIndex, length, src.capacity())) {
|
||||
throw new IndexOutOfBoundsException("srcIndex: " + srcIndex);
|
||||
}
|
||||
|
@ -16,6 +16,8 @@
|
||||
|
||||
package io.netty.buffer;
|
||||
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
import io.netty.util.ByteProcessor;
|
||||
import io.netty.util.internal.StringUtil;
|
||||
|
||||
@ -41,9 +43,7 @@ class WrappedByteBuf extends ByteBuf {
|
||||
protected final ByteBuf buf;
|
||||
|
||||
protected WrappedByteBuf(ByteBuf buf) {
|
||||
if (buf == null) {
|
||||
throw new NullPointerException("buf");
|
||||
}
|
||||
requireNonNull(buf, "buf");
|
||||
this.buf = buf;
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,7 @@ import io.netty.util.internal.UnstableApi;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static io.netty.util.internal.ObjectUtil.checkNotNull;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
/**
|
||||
* A skeletal implementation of {@link DnsMessage}.
|
||||
@ -87,7 +87,7 @@ public abstract class AbstractDnsMessage extends AbstractReferenceCounted implem
|
||||
|
||||
@Override
|
||||
public DnsMessage setOpCode(DnsOpCode opCode) {
|
||||
this.opCode = checkNotNull(opCode, "opCode");
|
||||
this.opCode = requireNonNull(opCode, "opCode");
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -452,11 +452,11 @@ public abstract class AbstractDnsMessage extends AbstractReferenceCounted implem
|
||||
}
|
||||
|
||||
private static int sectionOrdinal(DnsSection section) {
|
||||
return checkNotNull(section, "section").ordinal();
|
||||
return requireNonNull(section, "section").ordinal();
|
||||
}
|
||||
|
||||
private static DnsRecord checkQuestion(int section, DnsRecord record) {
|
||||
if (section == SECTION_QUESTION && !(checkNotNull(record, "record") instanceof DnsQuestion)) {
|
||||
if (section == SECTION_QUESTION && !(requireNonNull(record, "record") instanceof DnsQuestion)) {
|
||||
throw new IllegalArgumentException(
|
||||
"record: " + record + " (expected: " + StringUtil.simpleClassName(DnsQuestion.class) + ')');
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ import io.netty.util.internal.UnstableApi;
|
||||
|
||||
import java.net.IDN;
|
||||
|
||||
import static io.netty.util.internal.ObjectUtil.checkNotNull;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
/**
|
||||
* A skeletal implementation of {@link DnsRecord}.
|
||||
@ -69,8 +69,8 @@ public abstract class AbstractDnsRecord implements DnsRecord {
|
||||
// See:
|
||||
// - https://github.com/netty/netty/issues/4937
|
||||
// - https://github.com/netty/netty/issues/4935
|
||||
this.name = appendTrailingDot(IDN.toASCII(checkNotNull(name, "name")));
|
||||
this.type = checkNotNull(type, "type");
|
||||
this.name = appendTrailingDot(IDN.toASCII(requireNonNull(name, "name")));
|
||||
this.type = requireNonNull(type, "type");
|
||||
this.dnsClass = (short) dnsClass;
|
||||
this.timeToLive = timeToLive;
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ import io.netty.util.internal.UnstableApi;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static io.netty.util.internal.ObjectUtil.checkNotNull;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
/**
|
||||
* Decodes a {@link DatagramPacket} into a {@link DatagramDnsQuery}.
|
||||
@ -47,7 +47,7 @@ public class DatagramDnsQueryDecoder extends MessageToMessageDecoder<DatagramPac
|
||||
* Creates a new decoder with the specified {@code recordDecoder}.
|
||||
*/
|
||||
public DatagramDnsQueryDecoder(DnsRecordDecoder recordDecoder) {
|
||||
this.recordDecoder = checkNotNull(recordDecoder, "recordDecoder");
|
||||
this.recordDecoder = requireNonNull(recordDecoder, "recordDecoder");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -26,7 +26,7 @@ import io.netty.util.internal.UnstableApi;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.List;
|
||||
|
||||
import static io.netty.util.internal.ObjectUtil.checkNotNull;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
/**
|
||||
* Encodes a {@link DatagramDnsQuery} (or an {@link AddressedEnvelope} of {@link DnsQuery}} into a
|
||||
@ -49,7 +49,7 @@ public class DatagramDnsQueryEncoder extends MessageToMessageEncoder<AddressedEn
|
||||
* Creates a new encoder with the specified {@code recordEncoder}.
|
||||
*/
|
||||
public DatagramDnsQueryEncoder(DnsRecordEncoder recordEncoder) {
|
||||
this.recordEncoder = checkNotNull(recordEncoder, "recordEncoder");
|
||||
this.recordEncoder = requireNonNull(recordEncoder, "recordEncoder");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -25,7 +25,7 @@ import io.netty.util.internal.UnstableApi;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static io.netty.util.internal.ObjectUtil.checkNotNull;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
/**
|
||||
* Decodes a {@link DatagramPacket} into a {@link DatagramDnsResponse}.
|
||||
@ -47,7 +47,7 @@ public class DatagramDnsResponseDecoder extends MessageToMessageDecoder<Datagram
|
||||
* Creates a new decoder with the specified {@code recordDecoder}.
|
||||
*/
|
||||
public DatagramDnsResponseDecoder(DnsRecordDecoder recordDecoder) {
|
||||
this.recordDecoder = checkNotNull(recordDecoder, "recordDecoder");
|
||||
this.recordDecoder = requireNonNull(recordDecoder, "recordDecoder");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -26,7 +26,7 @@ import io.netty.util.internal.UnstableApi;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.List;
|
||||
|
||||
import static io.netty.util.internal.ObjectUtil.checkNotNull;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
/**
|
||||
* Encodes a {@link DatagramDnsResponse} (or an {@link AddressedEnvelope} of {@link DnsResponse}} into a
|
||||
@ -50,7 +50,7 @@ public class DatagramDnsResponseEncoder
|
||||
* Creates a new encoder with the specified {@code recordEncoder}.
|
||||
*/
|
||||
public DatagramDnsResponseEncoder(DnsRecordEncoder recordEncoder) {
|
||||
this.recordEncoder = checkNotNull(recordEncoder, "recordEncoder");
|
||||
this.recordEncoder = requireNonNull(recordEncoder, "recordEncoder");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -15,7 +15,7 @@
|
||||
*/
|
||||
package io.netty.handler.codec.dns;
|
||||
|
||||
import static io.netty.util.internal.ObjectUtil.checkNotNull;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
import io.netty.util.internal.StringUtil;
|
||||
import io.netty.util.internal.UnstableApi;
|
||||
@ -44,7 +44,7 @@ public class DefaultDnsPtrRecord extends AbstractDnsRecord implements DnsPtrReco
|
||||
public DefaultDnsPtrRecord(
|
||||
String name, int dnsClass, long timeToLive, String hostname) {
|
||||
super(name, DnsRecordType.PTR, dnsClass, timeToLive);
|
||||
this.hostname = checkNotNull(hostname, "hostname");
|
||||
this.hostname = requireNonNull(hostname, "hostname");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -19,7 +19,7 @@ import io.netty.buffer.ByteBuf;
|
||||
import io.netty.util.internal.StringUtil;
|
||||
import io.netty.util.internal.UnstableApi;
|
||||
|
||||
import static io.netty.util.internal.ObjectUtil.checkNotNull;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
/**
|
||||
* The default {@code DnsRawRecord} implementation.
|
||||
@ -59,7 +59,7 @@ public class DefaultDnsRawRecord extends AbstractDnsRecord implements DnsRawReco
|
||||
public DefaultDnsRawRecord(
|
||||
String name, DnsRecordType type, int dnsClass, long timeToLive, ByteBuf content) {
|
||||
super(name, type, dnsClass, timeToLive);
|
||||
this.content = checkNotNull(content, "content");
|
||||
this.content = requireNonNull(content, "content");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -17,7 +17,7 @@ package io.netty.handler.codec.dns;
|
||||
|
||||
import io.netty.util.internal.UnstableApi;
|
||||
|
||||
import static io.netty.util.internal.ObjectUtil.checkNotNull;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
/**
|
||||
* The default {@link DnsResponse} implementation.
|
||||
@ -102,7 +102,7 @@ public class DefaultDnsResponse extends AbstractDnsMessage implements DnsRespons
|
||||
|
||||
@Override
|
||||
public DnsResponse setCode(DnsResponseCode code) {
|
||||
this.code = checkNotNull(code, "code");
|
||||
this.code = requireNonNull(code, "code");
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,7 @@ package io.netty.handler.codec.dns;
|
||||
|
||||
import io.netty.util.internal.UnstableApi;
|
||||
|
||||
import static io.netty.util.internal.ObjectUtil.checkNotNull;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
/**
|
||||
* The DNS {@code OpCode} as defined in <a href="https://tools.ietf.org/html/rfc2929">RFC2929</a>.
|
||||
@ -80,7 +80,7 @@ public class DnsOpCode implements Comparable<DnsOpCode> {
|
||||
|
||||
public DnsOpCode(int byteValue, String name) {
|
||||
this.byteValue = (byte) byteValue;
|
||||
this.name = checkNotNull(name, "name");
|
||||
this.name = requireNonNull(name, "name");
|
||||
}
|
||||
|
||||
public byte byteValue() {
|
||||
|
@ -17,7 +17,7 @@ package io.netty.handler.codec.dns;
|
||||
|
||||
import io.netty.util.internal.UnstableApi;
|
||||
|
||||
import static io.netty.util.internal.ObjectUtil.checkNotNull;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
/**
|
||||
* The DNS {@code RCODE}, as defined in <a href="https://tools.ietf.org/html/rfc2929">RFC2929</a>.
|
||||
@ -173,7 +173,7 @@ public class DnsResponseCode implements Comparable<DnsResponseCode> {
|
||||
}
|
||||
|
||||
this.code = code;
|
||||
this.name = checkNotNull(name, "name");
|
||||
this.name = requireNonNull(name, "name");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -15,6 +15,8 @@
|
||||
*/
|
||||
package io.netty.handler.codec.haproxy;
|
||||
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.handler.codec.haproxy.HAProxyProxiedProtocol.AddressFamily;
|
||||
import io.netty.util.ByteProcessor;
|
||||
@ -89,10 +91,7 @@ public final class HAProxyMessage {
|
||||
HAProxyProtocolVersion protocolVersion, HAProxyCommand command, HAProxyProxiedProtocol proxiedProtocol,
|
||||
String sourceAddress, String destinationAddress, int sourcePort, int destinationPort,
|
||||
List<HAProxyTLV> tlvs) {
|
||||
|
||||
if (proxiedProtocol == null) {
|
||||
throw new NullPointerException("proxiedProtocol");
|
||||
}
|
||||
requireNonNull(proxiedProtocol, "proxiedProtocol");
|
||||
AddressFamily addrFamily = proxiedProtocol.addressFamily();
|
||||
|
||||
checkAddress(sourceAddress, addrFamily);
|
||||
@ -118,9 +117,7 @@ public final class HAProxyMessage {
|
||||
* @throws HAProxyProtocolException if any portion of the header is invalid
|
||||
*/
|
||||
static HAProxyMessage decodeHeader(ByteBuf header) {
|
||||
if (header == null) {
|
||||
throw new NullPointerException("header");
|
||||
}
|
||||
requireNonNull(header, "header");
|
||||
|
||||
if (header.readableBytes() < 16) {
|
||||
throw new HAProxyProtocolException(
|
||||
@ -416,9 +413,7 @@ public final class HAProxyMessage {
|
||||
* @throws HAProxyProtocolException if the address is invalid
|
||||
*/
|
||||
private static void checkAddress(String address, AddressFamily addrFamily) {
|
||||
if (addrFamily == null) {
|
||||
throw new NullPointerException("addrFamily");
|
||||
}
|
||||
requireNonNull(addrFamily, "addrFamily");
|
||||
|
||||
switch (addrFamily) {
|
||||
case AF_UNSPEC:
|
||||
@ -430,9 +425,7 @@ public final class HAProxyMessage {
|
||||
return;
|
||||
}
|
||||
|
||||
if (address == null) {
|
||||
throw new NullPointerException("address");
|
||||
}
|
||||
requireNonNull(address, "address");
|
||||
|
||||
switch (addrFamily) {
|
||||
case AF_IPv4:
|
||||
|
@ -19,7 +19,7 @@ package io.netty.handler.codec.haproxy;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.DefaultByteBufHolder;
|
||||
|
||||
import static io.netty.util.internal.ObjectUtil.*;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
/**
|
||||
* A Type-Length Value (TLV vector) that can be added to the PROXY protocol
|
||||
@ -85,7 +85,7 @@ public class HAProxyTLV extends DefaultByteBufHolder {
|
||||
*/
|
||||
HAProxyTLV(final Type type, final byte typeByteValue, final ByteBuf content) {
|
||||
super(content);
|
||||
checkNotNull(type, "type");
|
||||
requireNonNull(type, "type");
|
||||
|
||||
this.type = type;
|
||||
this.typeByteValue = typeByteValue;
|
||||
|
@ -18,7 +18,7 @@ package io.netty.handler.codec.http;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.util.IllegalReferenceCountException;
|
||||
import static io.netty.util.internal.ObjectUtil.checkNotNull;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
/**
|
||||
* Default implementation of {@link FullHttpRequest}.
|
||||
@ -47,15 +47,15 @@ public class DefaultFullHttpRequest extends DefaultHttpRequest implements FullHt
|
||||
public DefaultFullHttpRequest(HttpVersion httpVersion, HttpMethod method, String uri,
|
||||
ByteBuf content, boolean validateHeaders) {
|
||||
super(httpVersion, method, uri, validateHeaders);
|
||||
this.content = checkNotNull(content, "content");
|
||||
this.content = requireNonNull(content, "content");
|
||||
trailingHeader = new DefaultHttpHeaders(validateHeaders);
|
||||
}
|
||||
|
||||
public DefaultFullHttpRequest(HttpVersion httpVersion, HttpMethod method, String uri,
|
||||
ByteBuf content, HttpHeaders headers, HttpHeaders trailingHeader) {
|
||||
super(httpVersion, method, uri, headers);
|
||||
this.content = checkNotNull(content, "content");
|
||||
this.trailingHeader = checkNotNull(trailingHeader, "trailingHeader");
|
||||
this.content = requireNonNull(content, "content");
|
||||
this.trailingHeader = requireNonNull(trailingHeader, "trailingHeader");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -19,7 +19,7 @@ import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.util.IllegalReferenceCountException;
|
||||
|
||||
import static io.netty.util.internal.ObjectUtil.checkNotNull;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
/**
|
||||
* Default implementation of a {@link FullHttpResponse}.
|
||||
@ -59,7 +59,7 @@ public class DefaultFullHttpResponse extends DefaultHttpResponse implements Full
|
||||
public DefaultFullHttpResponse(HttpVersion version, HttpResponseStatus status,
|
||||
ByteBuf content, boolean validateHeaders, boolean singleFieldHeaders) {
|
||||
super(version, status, validateHeaders, singleFieldHeaders);
|
||||
this.content = checkNotNull(content, "content");
|
||||
this.content = requireNonNull(content, "content");
|
||||
this.trailingHeaders = singleFieldHeaders ? new CombinedHttpHeaders(validateHeaders)
|
||||
: new DefaultHttpHeaders(validateHeaders);
|
||||
}
|
||||
@ -67,8 +67,8 @@ public class DefaultFullHttpResponse extends DefaultHttpResponse implements Full
|
||||
public DefaultFullHttpResponse(HttpVersion version, HttpResponseStatus status,
|
||||
ByteBuf content, HttpHeaders headers, HttpHeaders trailingHeaders) {
|
||||
super(version, status, headers);
|
||||
this.content = checkNotNull(content, "content");
|
||||
this.trailingHeaders = checkNotNull(trailingHeaders, "trailingHeaders");
|
||||
this.content = requireNonNull(content, "content");
|
||||
this.trailingHeaders = requireNonNull(trailingHeaders, "trailingHeaders");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -15,6 +15,8 @@
|
||||
*/
|
||||
package io.netty.handler.codec.http;
|
||||
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.util.internal.StringUtil;
|
||||
|
||||
@ -29,9 +31,7 @@ public class DefaultHttpContent extends DefaultHttpObject implements HttpContent
|
||||
* Creates a new instance with the specified chunk content.
|
||||
*/
|
||||
public DefaultHttpContent(ByteBuf content) {
|
||||
if (content == null) {
|
||||
throw new NullPointerException("content");
|
||||
}
|
||||
requireNonNull(content, "content");
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,7 @@
|
||||
*/
|
||||
package io.netty.handler.codec.http;
|
||||
|
||||
import static io.netty.util.internal.ObjectUtil.checkNotNull;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
/**
|
||||
* The default {@link HttpMessage} implementation.
|
||||
@ -45,8 +45,8 @@ public abstract class DefaultHttpMessage extends DefaultHttpObject implements Ht
|
||||
* Creates a new instance.
|
||||
*/
|
||||
protected DefaultHttpMessage(final HttpVersion version, HttpHeaders headers) {
|
||||
this.version = checkNotNull(version, "version");
|
||||
this.headers = checkNotNull(headers, "headers");
|
||||
this.version = requireNonNull(version, "version");
|
||||
this.headers = requireNonNull(headers, "headers");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -89,9 +89,7 @@ public abstract class DefaultHttpMessage extends DefaultHttpObject implements Ht
|
||||
|
||||
@Override
|
||||
public HttpMessage setProtocolVersion(HttpVersion version) {
|
||||
if (version == null) {
|
||||
throw new NullPointerException("version");
|
||||
}
|
||||
requireNonNull(version, "version");
|
||||
this.version = version;
|
||||
return this;
|
||||
}
|
||||
|
@ -15,6 +15,8 @@
|
||||
*/
|
||||
package io.netty.handler.codec.http;
|
||||
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
import io.netty.handler.codec.DecoderResult;
|
||||
|
||||
public class DefaultHttpObject implements HttpObject {
|
||||
@ -39,9 +41,7 @@ public class DefaultHttpObject implements HttpObject {
|
||||
|
||||
@Override
|
||||
public void setDecoderResult(DecoderResult decoderResult) {
|
||||
if (decoderResult == null) {
|
||||
throw new NullPointerException("decoderResult");
|
||||
}
|
||||
requireNonNull(decoderResult, "decoderResult");
|
||||
this.decoderResult = decoderResult;
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,7 @@
|
||||
*/
|
||||
package io.netty.handler.codec.http;
|
||||
|
||||
import static io.netty.util.internal.ObjectUtil.checkNotNull;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
/**
|
||||
* The default {@link HttpRequest} implementation.
|
||||
@ -46,8 +46,8 @@ public class DefaultHttpRequest extends DefaultHttpMessage implements HttpReques
|
||||
*/
|
||||
public DefaultHttpRequest(HttpVersion httpVersion, HttpMethod method, String uri, boolean validateHeaders) {
|
||||
super(httpVersion, validateHeaders, false);
|
||||
this.method = checkNotNull(method, "method");
|
||||
this.uri = checkNotNull(uri, "uri");
|
||||
this.method = requireNonNull(method, "method");
|
||||
this.uri = requireNonNull(uri, "uri");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -60,8 +60,8 @@ public class DefaultHttpRequest extends DefaultHttpMessage implements HttpReques
|
||||
*/
|
||||
public DefaultHttpRequest(HttpVersion httpVersion, HttpMethod method, String uri, HttpHeaders headers) {
|
||||
super(httpVersion, headers);
|
||||
this.method = checkNotNull(method, "method");
|
||||
this.uri = checkNotNull(uri, "uri");
|
||||
this.method = requireNonNull(method, "method");
|
||||
this.uri = requireNonNull(uri, "uri");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -88,18 +88,14 @@ public class DefaultHttpRequest extends DefaultHttpMessage implements HttpReques
|
||||
|
||||
@Override
|
||||
public HttpRequest setMethod(HttpMethod method) {
|
||||
if (method == null) {
|
||||
throw new NullPointerException("method");
|
||||
}
|
||||
requireNonNull(method, "method");
|
||||
this.method = method;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpRequest setUri(String uri) {
|
||||
if (uri == null) {
|
||||
throw new NullPointerException("uri");
|
||||
}
|
||||
requireNonNull(uri, "uri");
|
||||
this.uri = uri;
|
||||
return this;
|
||||
}
|
||||
|
@ -15,7 +15,7 @@
|
||||
*/
|
||||
package io.netty.handler.codec.http;
|
||||
|
||||
import static io.netty.util.internal.ObjectUtil.checkNotNull;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
/**
|
||||
* The default {@link HttpResponse} implementation.
|
||||
@ -60,7 +60,7 @@ public class DefaultHttpResponse extends DefaultHttpMessage implements HttpRespo
|
||||
public DefaultHttpResponse(HttpVersion version, HttpResponseStatus status, boolean validateHeaders,
|
||||
boolean singleFieldHeaders) {
|
||||
super(version, validateHeaders, singleFieldHeaders);
|
||||
this.status = checkNotNull(status, "status");
|
||||
this.status = requireNonNull(status, "status");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -72,7 +72,7 @@ public class DefaultHttpResponse extends DefaultHttpMessage implements HttpRespo
|
||||
*/
|
||||
public DefaultHttpResponse(HttpVersion version, HttpResponseStatus status, HttpHeaders headers) {
|
||||
super(version, headers);
|
||||
this.status = checkNotNull(status, "status");
|
||||
this.status = requireNonNull(status, "status");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -88,9 +88,7 @@ public class DefaultHttpResponse extends DefaultHttpMessage implements HttpRespo
|
||||
|
||||
@Override
|
||||
public HttpResponse setStatus(HttpResponseStatus status) {
|
||||
if (status == null) {
|
||||
throw new NullPointerException("status");
|
||||
}
|
||||
requireNonNull(status, "status");
|
||||
this.status = status;
|
||||
return this;
|
||||
}
|
||||
|
@ -27,6 +27,7 @@ import java.util.Set;
|
||||
|
||||
import static io.netty.handler.codec.http.HttpResponseStatus.SWITCHING_PROTOCOLS;
|
||||
import static io.netty.util.ReferenceCountUtil.release;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
/**
|
||||
* Client-side handler for handling an HTTP upgrade handshake to another protocol. When the first
|
||||
@ -115,12 +116,8 @@ public class HttpClientUpgradeHandler extends HttpObjectAggregator implements Ch
|
||||
public HttpClientUpgradeHandler(SourceCodec sourceCodec, UpgradeCodec upgradeCodec,
|
||||
int maxContentLength) {
|
||||
super(maxContentLength);
|
||||
if (sourceCodec == null) {
|
||||
throw new NullPointerException("sourceCodec");
|
||||
}
|
||||
if (upgradeCodec == null) {
|
||||
throw new NullPointerException("upgradeCodec");
|
||||
}
|
||||
requireNonNull(sourceCodec, "sourceCodec");
|
||||
requireNonNull(upgradeCodec, "upgradeCodec");
|
||||
this.sourceCodec = sourceCodec;
|
||||
this.upgradeCodec = upgradeCodec;
|
||||
}
|
||||
|
@ -15,6 +15,8 @@
|
||||
*/
|
||||
package io.netty.handler.codec.http;
|
||||
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.ByteBufHolder;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
@ -350,12 +352,8 @@ public abstract class HttpContentEncoder extends MessageToMessageCodec<HttpReque
|
||||
private final EmbeddedChannel contentEncoder;
|
||||
|
||||
public Result(String targetContentEncoding, EmbeddedChannel contentEncoder) {
|
||||
if (targetContentEncoding == null) {
|
||||
throw new NullPointerException("targetContentEncoding");
|
||||
}
|
||||
if (contentEncoder == null) {
|
||||
throw new NullPointerException("contentEncoder");
|
||||
}
|
||||
requireNonNull(targetContentEncoding, "targetContentEncoding");
|
||||
requireNonNull(contentEncoder, "contentEncoder");
|
||||
|
||||
this.targetContentEncoding = targetContentEncoding;
|
||||
this.contentEncoder = contentEncoder;
|
||||
|
@ -35,7 +35,7 @@ import java.util.Set;
|
||||
import static io.netty.util.AsciiString.contentEquals;
|
||||
import static io.netty.util.AsciiString.contentEqualsIgnoreCase;
|
||||
import static io.netty.util.AsciiString.trim;
|
||||
import static io.netty.util.internal.ObjectUtil.checkNotNull;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
/**
|
||||
* Provides the constants for the standard HTTP header names and values and
|
||||
@ -950,9 +950,7 @@ public abstract class HttpHeaders implements Iterable<Map.Entry<String, String>>
|
||||
* @return {@code this}
|
||||
*/
|
||||
public HttpHeaders add(HttpHeaders headers) {
|
||||
if (headers == null) {
|
||||
throw new NullPointerException("headers");
|
||||
}
|
||||
requireNonNull(headers, "headers");
|
||||
for (Map.Entry<String, String> e: headers) {
|
||||
add(e.getKey(), e.getValue());
|
||||
}
|
||||
@ -1031,7 +1029,7 @@ public abstract class HttpHeaders implements Iterable<Map.Entry<String, String>>
|
||||
* @return {@code this}
|
||||
*/
|
||||
public HttpHeaders set(HttpHeaders headers) {
|
||||
checkNotNull(headers, "headers");
|
||||
requireNonNull(headers, "headers");
|
||||
|
||||
clear();
|
||||
|
||||
@ -1052,7 +1050,7 @@ public abstract class HttpHeaders implements Iterable<Map.Entry<String, String>>
|
||||
* @return {@code this}
|
||||
*/
|
||||
public HttpHeaders setAll(HttpHeaders headers) {
|
||||
checkNotNull(headers, "headers");
|
||||
requireNonNull(headers, "headers");
|
||||
|
||||
if (headers.isEmpty()) {
|
||||
return this;
|
||||
|
@ -18,7 +18,7 @@ package io.netty.handler.codec.http;
|
||||
import io.netty.util.AsciiString;
|
||||
|
||||
import static io.netty.util.internal.MathUtil.findNextPositivePowerOfTwo;
|
||||
import static io.netty.util.internal.ObjectUtil.checkNotNull;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
/**
|
||||
* The request method of HTTP or its derived protocols, such as
|
||||
@ -120,7 +120,7 @@ public class HttpMethod implements Comparable<HttpMethod> {
|
||||
* <a href="http://en.wikipedia.org/wiki/Internet_Content_Adaptation_Protocol">ICAP</a>
|
||||
*/
|
||||
public HttpMethod(String name) {
|
||||
name = checkNotNull(name, "name").trim();
|
||||
name = requireNonNull(name, "name").trim();
|
||||
if (name.isEmpty()) {
|
||||
throw new IllegalArgumentException("empty name");
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ import io.netty.util.CharsetUtil;
|
||||
import static io.netty.handler.codec.http.HttpConstants.SP;
|
||||
import static io.netty.util.ByteProcessor.FIND_ASCII_SPACE;
|
||||
import static java.lang.Integer.parseInt;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
/**
|
||||
* The response code and its description of HTTP or its derived protocols, such as
|
||||
@ -543,9 +544,7 @@ public class HttpResponseStatus implements Comparable<HttpResponseStatus> {
|
||||
"code: " + code + " (expected: 0+)");
|
||||
}
|
||||
|
||||
if (reasonPhrase == null) {
|
||||
throw new NullPointerException("reasonPhrase");
|
||||
}
|
||||
requireNonNull(reasonPhrase, "reasonPhrase");
|
||||
|
||||
for (int i = 0; i < reasonPhrase.length(); i ++) {
|
||||
char c = reasonPhrase.charAt(i);
|
||||
|
@ -30,7 +30,7 @@ import java.util.List;
|
||||
|
||||
import static io.netty.handler.codec.http.HttpResponseStatus.SWITCHING_PROTOCOLS;
|
||||
import static io.netty.handler.codec.http.HttpVersion.HTTP_1_1;
|
||||
import static io.netty.util.internal.ObjectUtil.checkNotNull;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
/**
|
||||
* A server-side handler that receives HTTP requests and optionally performs a protocol switch if
|
||||
@ -201,8 +201,8 @@ public class HttpServerUpgradeHandler extends HttpObjectAggregator {
|
||||
SourceCodec sourceCodec, UpgradeCodecFactory upgradeCodecFactory, int maxContentLength) {
|
||||
super(maxContentLength);
|
||||
|
||||
this.sourceCodec = checkNotNull(sourceCodec, "sourceCodec");
|
||||
this.upgradeCodecFactory = checkNotNull(upgradeCodecFactory, "upgradeCodecFactory");
|
||||
this.sourceCodec = requireNonNull(sourceCodec, "sourceCodec");
|
||||
this.upgradeCodecFactory = requireNonNull(upgradeCodecFactory, "upgradeCodecFactory");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -15,6 +15,8 @@
|
||||
*/
|
||||
package io.netty.handler.codec.http;
|
||||
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.URI;
|
||||
import java.nio.charset.Charset;
|
||||
@ -455,9 +457,7 @@ public final class HttpUtil {
|
||||
* @throws NullPointerException in case if {@code contentTypeValue == null}
|
||||
*/
|
||||
public static CharSequence getCharsetAsSequence(CharSequence contentTypeValue) {
|
||||
if (contentTypeValue == null) {
|
||||
throw new NullPointerException("contentTypeValue");
|
||||
}
|
||||
requireNonNull(contentTypeValue, "contentTypeValue");
|
||||
|
||||
int indexOfCharset = AsciiString.indexOfIgnoreCaseAscii(contentTypeValue, CHARSET_EQUALS, 0);
|
||||
if (indexOfCharset == AsciiString.INDEX_NOT_FOUND) {
|
||||
@ -511,9 +511,7 @@ public final class HttpUtil {
|
||||
* @throws NullPointerException in case if {@code contentTypeValue == null}
|
||||
*/
|
||||
public static CharSequence getMimeType(CharSequence contentTypeValue) {
|
||||
if (contentTypeValue == null) {
|
||||
throw new NullPointerException("contentTypeValue");
|
||||
}
|
||||
requireNonNull(contentTypeValue, "contentTypeValue");
|
||||
|
||||
int indexOfSemicolon = AsciiString.indexOfIgnoreCaseAscii(contentTypeValue, SEMICOLON, 0);
|
||||
if (indexOfSemicolon != AsciiString.INDEX_NOT_FOUND) {
|
||||
|
@ -15,6 +15,8 @@
|
||||
*/
|
||||
package io.netty.handler.codec.http;
|
||||
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.util.CharsetUtil;
|
||||
|
||||
@ -53,9 +55,7 @@ public class HttpVersion implements Comparable<HttpVersion> {
|
||||
* returned.
|
||||
*/
|
||||
public static HttpVersion valueOf(String text) {
|
||||
if (text == null) {
|
||||
throw new NullPointerException("text");
|
||||
}
|
||||
requireNonNull(text, "text");
|
||||
|
||||
text = text.trim();
|
||||
|
||||
@ -107,9 +107,7 @@ public class HttpVersion implements Comparable<HttpVersion> {
|
||||
* the {@code "Connection"} header is set to {@code "close"} explicitly.
|
||||
*/
|
||||
public HttpVersion(String text, boolean keepAliveDefault) {
|
||||
if (text == null) {
|
||||
throw new NullPointerException("text");
|
||||
}
|
||||
requireNonNull(text, "text");
|
||||
|
||||
text = text.trim().toUpperCase();
|
||||
if (text.isEmpty()) {
|
||||
@ -149,9 +147,7 @@ public class HttpVersion implements Comparable<HttpVersion> {
|
||||
private HttpVersion(
|
||||
String protocolName, int majorVersion, int minorVersion,
|
||||
boolean keepAliveDefault, boolean bytes) {
|
||||
if (protocolName == null) {
|
||||
throw new NullPointerException("protocolName");
|
||||
}
|
||||
requireNonNull(protocolName, "protocolName");
|
||||
|
||||
protocolName = protocolName.trim().toUpperCase();
|
||||
if (protocolName.isEmpty()) {
|
||||
|
@ -31,8 +31,9 @@ import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static io.netty.util.internal.ObjectUtil.*;
|
||||
import static io.netty.util.internal.ObjectUtil.checkPositive;
|
||||
import static io.netty.util.internal.StringUtil.*;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
/**
|
||||
* Splits an HTTP query string into a path string and key-value parameter pairs.
|
||||
@ -109,8 +110,8 @@ public class QueryStringDecoder {
|
||||
* specified charset.
|
||||
*/
|
||||
public QueryStringDecoder(String uri, Charset charset, boolean hasPath, int maxParams) {
|
||||
this.uri = checkNotNull(uri, "uri");
|
||||
this.charset = checkNotNull(charset, "charset");
|
||||
this.uri = requireNonNull(uri, "uri");
|
||||
this.charset = requireNonNull(charset, "charset");
|
||||
this.maxParams = checkPositive(maxParams, "maxParams");
|
||||
|
||||
// `-1` means that path end index will be initialized lazily
|
||||
@ -145,7 +146,7 @@ public class QueryStringDecoder {
|
||||
String rawQuery = uri.getRawQuery();
|
||||
// Also take care of cut of things like "http://localhost"
|
||||
this.uri = rawQuery == null? rawPath : rawPath + '?' + rawQuery;
|
||||
this.charset = checkNotNull(charset, "charset");
|
||||
this.charset = requireNonNull(charset, "charset");
|
||||
this.maxParams = checkPositive(maxParams, "maxParams");
|
||||
pathEndIdx = rawPath.length();
|
||||
}
|
||||
|
@ -15,7 +15,7 @@
|
||||
*/
|
||||
package io.netty.handler.codec.http;
|
||||
|
||||
import io.netty.util.internal.ObjectUtil;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URI;
|
||||
@ -62,7 +62,7 @@ public class QueryStringEncoder {
|
||||
* Adds a parameter with the specified name and value to this encoder.
|
||||
*/
|
||||
public void addParam(String name, String value) {
|
||||
ObjectUtil.checkNotNull(name, "name");
|
||||
requireNonNull(name, "name");
|
||||
if (hasParams) {
|
||||
uriBuilder.append('&');
|
||||
} else {
|
||||
|
@ -19,7 +19,7 @@ import io.netty.handler.codec.DateFormatter;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import static io.netty.util.internal.ObjectUtil.checkNotNull;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
/**
|
||||
* A <a href="http://tools.ietf.org/html/rfc6265">RFC6265</a> compliant cookie decoder to be used client side.
|
||||
@ -52,7 +52,7 @@ public final class ClientCookieDecoder extends CookieDecoder {
|
||||
* @return the decoded {@link Cookie}
|
||||
*/
|
||||
public Cookie decode(String header) {
|
||||
final int headerLen = checkNotNull(header, "header").length();
|
||||
final int headerLen = requireNonNull(header, "header").length();
|
||||
|
||||
if (headerLen == 0) {
|
||||
return null;
|
||||
|
@ -20,7 +20,8 @@ import static io.netty.handler.codec.http.cookie.CookieUtil.addQuoted;
|
||||
import static io.netty.handler.codec.http.cookie.CookieUtil.stringBuilder;
|
||||
import static io.netty.handler.codec.http.cookie.CookieUtil.stripTrailingSeparator;
|
||||
import static io.netty.handler.codec.http.cookie.CookieUtil.stripTrailingSeparatorOrNull;
|
||||
import static io.netty.util.internal.ObjectUtil.checkNotNull;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
import io.netty.handler.codec.http.HttpRequest;
|
||||
import io.netty.util.internal.InternalThreadLocalMap;
|
||||
|
||||
@ -83,7 +84,7 @@ public final class ClientCookieEncoder extends CookieEncoder {
|
||||
*/
|
||||
public String encode(Cookie cookie) {
|
||||
StringBuilder buf = stringBuilder();
|
||||
encode(buf, checkNotNull(cookie, "cookie"));
|
||||
encode(buf, requireNonNull(cookie, "cookie"));
|
||||
return stripTrailingSeparator(buf);
|
||||
}
|
||||
|
||||
@ -118,7 +119,7 @@ public final class ClientCookieEncoder extends CookieEncoder {
|
||||
* @return a Rfc6265 style Cookie header value, null if no cookies are passed.
|
||||
*/
|
||||
public String encode(Cookie... cookies) {
|
||||
if (checkNotNull(cookies, "cookies").length == 0) {
|
||||
if (requireNonNull(cookies, "cookies").length == 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -149,7 +150,7 @@ public final class ClientCookieEncoder extends CookieEncoder {
|
||||
* @return a Rfc6265 style Cookie header value, null if no cookies are passed.
|
||||
*/
|
||||
public String encode(Collection<? extends Cookie> cookies) {
|
||||
if (checkNotNull(cookies, "cookies").isEmpty()) {
|
||||
if (requireNonNull(cookies, "cookies").isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -179,7 +180,7 @@ public final class ClientCookieEncoder extends CookieEncoder {
|
||||
* @return a Rfc6265 style Cookie header value, null if no cookies are passed.
|
||||
*/
|
||||
public String encode(Iterable<? extends Cookie> cookies) {
|
||||
Iterator<? extends Cookie> cookiesIt = checkNotNull(cookies, "cookies").iterator();
|
||||
Iterator<? extends Cookie> cookiesIt = requireNonNull(cookies, "cookies").iterator();
|
||||
if (!cookiesIt.hasNext()) {
|
||||
return null;
|
||||
}
|
||||
|
@ -16,7 +16,7 @@
|
||||
package io.netty.handler.codec.http.cookie;
|
||||
|
||||
import static io.netty.handler.codec.http.cookie.CookieUtil.*;
|
||||
import static io.netty.util.internal.ObjectUtil.checkNotNull;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
/**
|
||||
* The default {@link Cookie} implementation.
|
||||
@ -36,7 +36,7 @@ public class DefaultCookie implements Cookie {
|
||||
* Creates a new cookie with the specified name and value.
|
||||
*/
|
||||
public DefaultCookie(String name, String value) {
|
||||
name = checkNotNull(name, "name").trim();
|
||||
name = requireNonNull(name, "name").trim();
|
||||
if (name.isEmpty()) {
|
||||
throw new IllegalArgumentException("empty name");
|
||||
}
|
||||
@ -56,7 +56,7 @@ public class DefaultCookie implements Cookie {
|
||||
|
||||
@Override
|
||||
public void setValue(String value) {
|
||||
this.value = checkNotNull(value, "value");
|
||||
this.value = requireNonNull(value, "value");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -15,7 +15,7 @@
|
||||
*/
|
||||
package io.netty.handler.codec.http.cookie;
|
||||
|
||||
import static io.netty.util.internal.ObjectUtil.checkNotNull;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
@ -62,7 +62,7 @@ public final class ServerCookieDecoder extends CookieDecoder {
|
||||
* @return the decoded {@link Cookie}
|
||||
*/
|
||||
public Set<Cookie> decode(String header) {
|
||||
final int headerLen = checkNotNull(header, "header").length();
|
||||
final int headerLen = requireNonNull(header, "header").length();
|
||||
|
||||
if (headerLen == 0) {
|
||||
return Collections.emptySet();
|
||||
|
@ -19,7 +19,7 @@ import static io.netty.handler.codec.http.cookie.CookieUtil.add;
|
||||
import static io.netty.handler.codec.http.cookie.CookieUtil.addQuoted;
|
||||
import static io.netty.handler.codec.http.cookie.CookieUtil.stringBuilder;
|
||||
import static io.netty.handler.codec.http.cookie.CookieUtil.stripTrailingSeparator;
|
||||
import static io.netty.util.internal.ObjectUtil.checkNotNull;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
import io.netty.handler.codec.DateFormatter;
|
||||
import io.netty.handler.codec.http.HttpConstants;
|
||||
@ -88,7 +88,7 @@ public final class ServerCookieEncoder extends CookieEncoder {
|
||||
* @return a single Set-Cookie header value
|
||||
*/
|
||||
public String encode(Cookie cookie) {
|
||||
final String name = checkNotNull(cookie, "cookie").name();
|
||||
final String name = requireNonNull(cookie, "cookie").name();
|
||||
final String value = cookie.value() != null ? cookie.value() : "";
|
||||
|
||||
validateCookie(name, value);
|
||||
@ -155,7 +155,7 @@ public final class ServerCookieEncoder extends CookieEncoder {
|
||||
* @return the corresponding bunch of Set-Cookie headers
|
||||
*/
|
||||
public List<String> encode(Cookie... cookies) {
|
||||
if (checkNotNull(cookies, "cookies").length == 0) {
|
||||
if (requireNonNull(cookies, "cookies").length == 0) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@ -179,7 +179,7 @@ public final class ServerCookieEncoder extends CookieEncoder {
|
||||
* @return the corresponding bunch of Set-Cookie headers
|
||||
*/
|
||||
public List<String> encode(Collection<? extends Cookie> cookies) {
|
||||
if (checkNotNull(cookies, "cookies").isEmpty()) {
|
||||
if (requireNonNull(cookies, "cookies").isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@ -203,7 +203,7 @@ public final class ServerCookieEncoder extends CookieEncoder {
|
||||
* @return the corresponding bunch of Set-Cookie headers
|
||||
*/
|
||||
public List<String> encode(Iterable<? extends Cookie> cookies) {
|
||||
Iterator<? extends Cookie> cookiesIt = checkNotNull(cookies, "cookies").iterator();
|
||||
Iterator<? extends Cookie> cookiesIt = requireNonNull(cookies, "cookies").iterator();
|
||||
if (!cookiesIt.hasNext()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ import static io.netty.handler.codec.http.HttpResponseStatus.FORBIDDEN;
|
||||
import static io.netty.handler.codec.http.HttpResponseStatus.OK;
|
||||
import static io.netty.util.ReferenceCountUtil.release;
|
||||
import static io.netty.util.internal.ObjectUtil.checkNonEmpty;
|
||||
import static io.netty.util.internal.ObjectUtil.checkNotNull;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
/**
|
||||
* Handles <a href="http://www.w3.org/TR/cors/">Cross Origin Resource Sharing</a> (CORS) requests.
|
||||
@ -61,7 +61,7 @@ public class CorsHandler extends ChannelDuplexHandler {
|
||||
* Creates a new instance with a single {@link CorsConfig}.
|
||||
*/
|
||||
public CorsHandler(final CorsConfig config) {
|
||||
this(Collections.singletonList(checkNotNull(config, "config")), config.isShortCircuit());
|
||||
this(Collections.singletonList(requireNonNull(config, "config")), config.isShortCircuit());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -32,6 +32,7 @@ import java.nio.charset.Charset;
|
||||
import java.nio.file.Files;
|
||||
|
||||
import static io.netty.buffer.Unpooled.*;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
/**
|
||||
* Abstract Disk HttpData implementation
|
||||
@ -101,9 +102,7 @@ public abstract class AbstractDiskHttpData extends AbstractHttpData {
|
||||
|
||||
@Override
|
||||
public void setContent(ByteBuf buffer) throws IOException {
|
||||
if (buffer == null) {
|
||||
throw new NullPointerException("buffer");
|
||||
}
|
||||
requireNonNull(buffer, "buffer");
|
||||
try {
|
||||
size = buffer.readableBytes();
|
||||
checkSize(size);
|
||||
@ -188,9 +187,7 @@ public abstract class AbstractDiskHttpData extends AbstractHttpData {
|
||||
fileChannel = null;
|
||||
setCompleted();
|
||||
} else {
|
||||
if (buffer == null) {
|
||||
throw new NullPointerException("buffer");
|
||||
}
|
||||
requireNonNull(buffer, "buffer");
|
||||
}
|
||||
}
|
||||
|
||||
@ -208,9 +205,7 @@ public abstract class AbstractDiskHttpData extends AbstractHttpData {
|
||||
|
||||
@Override
|
||||
public void setContent(InputStream inputStream) throws IOException {
|
||||
if (inputStream == null) {
|
||||
throw new NullPointerException("inputStream");
|
||||
}
|
||||
requireNonNull(inputStream, "inputStream");
|
||||
if (file != null) {
|
||||
delete();
|
||||
}
|
||||
@ -335,9 +330,7 @@ public abstract class AbstractDiskHttpData extends AbstractHttpData {
|
||||
|
||||
@Override
|
||||
public boolean renameTo(File dest) throws IOException {
|
||||
if (dest == null) {
|
||||
throw new NullPointerException("dest");
|
||||
}
|
||||
requireNonNull(dest, "dest");
|
||||
if (file == null) {
|
||||
throw new IOException("No file defined so cannot be renamed");
|
||||
}
|
||||
|
@ -15,6 +15,8 @@
|
||||
*/
|
||||
package io.netty.handler.codec.http.multipart;
|
||||
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.ChannelException;
|
||||
import io.netty.handler.codec.http.HttpConstants;
|
||||
@ -40,9 +42,7 @@ public abstract class AbstractHttpData extends AbstractReferenceCounted implemen
|
||||
private long maxSize = DefaultHttpDataFactory.MAXSIZE;
|
||||
|
||||
protected AbstractHttpData(String name, Charset charset, long size) {
|
||||
if (name == null) {
|
||||
throw new NullPointerException("name");
|
||||
}
|
||||
requireNonNull(name, "name");
|
||||
|
||||
name = REPLACE_PATTERN.matcher(name).replaceAll(" ");
|
||||
name = STRIP_PATTERN.matcher(name).replaceAll("");
|
||||
@ -96,9 +96,7 @@ public abstract class AbstractHttpData extends AbstractReferenceCounted implemen
|
||||
|
||||
@Override
|
||||
public void setCharset(Charset charset) {
|
||||
if (charset == null) {
|
||||
throw new NullPointerException("charset");
|
||||
}
|
||||
requireNonNull(charset, "charset");
|
||||
this.charset = charset;
|
||||
}
|
||||
|
||||
|
@ -32,6 +32,7 @@ import static io.netty.buffer.Unpooled.EMPTY_BUFFER;
|
||||
import static io.netty.buffer.Unpooled.buffer;
|
||||
import static io.netty.buffer.Unpooled.compositeBuffer;
|
||||
import static io.netty.buffer.Unpooled.wrappedBuffer;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
/**
|
||||
* Abstract Memory HttpData implementation
|
||||
@ -47,9 +48,7 @@ public abstract class AbstractMemoryHttpData extends AbstractHttpData {
|
||||
|
||||
@Override
|
||||
public void setContent(ByteBuf buffer) throws IOException {
|
||||
if (buffer == null) {
|
||||
throw new NullPointerException("buffer");
|
||||
}
|
||||
requireNonNull(buffer, "buffer");
|
||||
long localsize = buffer.readableBytes();
|
||||
checkSize(localsize);
|
||||
if (definedSize > 0 && definedSize < localsize) {
|
||||
@ -66,9 +65,7 @@ public abstract class AbstractMemoryHttpData extends AbstractHttpData {
|
||||
|
||||
@Override
|
||||
public void setContent(InputStream inputStream) throws IOException {
|
||||
if (inputStream == null) {
|
||||
throw new NullPointerException("inputStream");
|
||||
}
|
||||
requireNonNull(inputStream, "inputStream");
|
||||
ByteBuf buffer = buffer();
|
||||
byte[] bytes = new byte[4096 * 4];
|
||||
int read = inputStream.read(bytes);
|
||||
@ -115,17 +112,13 @@ public abstract class AbstractMemoryHttpData extends AbstractHttpData {
|
||||
if (last) {
|
||||
setCompleted();
|
||||
} else {
|
||||
if (buffer == null) {
|
||||
throw new NullPointerException("buffer");
|
||||
}
|
||||
requireNonNull(buffer, "buffer");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setContent(File file) throws IOException {
|
||||
if (file == null) {
|
||||
throw new NullPointerException("file");
|
||||
}
|
||||
requireNonNull(file, "file");
|
||||
long newsize = file.length();
|
||||
if (newsize > Integer.MAX_VALUE) {
|
||||
throw new IllegalArgumentException(
|
||||
@ -222,9 +215,7 @@ public abstract class AbstractMemoryHttpData extends AbstractHttpData {
|
||||
|
||||
@Override
|
||||
public boolean renameTo(File dest) throws IOException {
|
||||
if (dest == null) {
|
||||
throw new NullPointerException("dest");
|
||||
}
|
||||
requireNonNull(dest, "dest");
|
||||
if (byteBuf == null) {
|
||||
// empty file
|
||||
if (!dest.createNewFile()) {
|
||||
|
@ -23,6 +23,7 @@ import java.io.IOException;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
import static io.netty.buffer.Unpooled.wrappedBuffer;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
/**
|
||||
* Disk implementation of Attributes
|
||||
@ -77,9 +78,7 @@ public class DiskAttribute extends AbstractDiskHttpData implements Attribute {
|
||||
|
||||
@Override
|
||||
public void setValue(String value) throws IOException {
|
||||
if (value == null) {
|
||||
throw new NullPointerException("value");
|
||||
}
|
||||
requireNonNull(value, "value");
|
||||
byte [] bytes = value.getBytes(getCharset());
|
||||
checkSize(bytes.length);
|
||||
ByteBuf buffer = wrappedBuffer(bytes);
|
||||
|
@ -15,6 +15,8 @@
|
||||
*/
|
||||
package io.netty.handler.codec.http.multipart;
|
||||
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.ChannelException;
|
||||
import io.netty.handler.codec.http.HttpHeaderNames;
|
||||
@ -62,9 +64,7 @@ public class DiskFileUpload extends AbstractDiskHttpData implements FileUpload {
|
||||
|
||||
@Override
|
||||
public void setFilename(String filename) {
|
||||
if (filename == null) {
|
||||
throw new NullPointerException("filename");
|
||||
}
|
||||
requireNonNull(filename, "filename");
|
||||
this.filename = filename;
|
||||
}
|
||||
|
||||
@ -93,9 +93,7 @@ public class DiskFileUpload extends AbstractDiskHttpData implements FileUpload {
|
||||
|
||||
@Override
|
||||
public void setContentType(String contentType) {
|
||||
if (contentType == null) {
|
||||
throw new NullPointerException("contentType");
|
||||
}
|
||||
requireNonNull(contentType, "contentType");
|
||||
this.contentType = contentType;
|
||||
}
|
||||
|
||||
|
@ -45,8 +45,8 @@ import static io.netty.buffer.Unpooled.buffer;
|
||||
import static io.netty.handler.codec.http.multipart.HttpPostBodyUtil.BINARY_STRING;
|
||||
import static io.netty.handler.codec.http.multipart.HttpPostBodyUtil.BIT_7_STRING;
|
||||
import static io.netty.handler.codec.http.multipart.HttpPostBodyUtil.BIT_8_STRING;
|
||||
import static io.netty.util.internal.ObjectUtil.checkNotNull;
|
||||
import static io.netty.util.internal.ObjectUtil.checkPositiveOrZero;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
/**
|
||||
* This decoder will decode Body and can handle POST BODY.
|
||||
@ -177,9 +177,9 @@ public class HttpPostMultipartRequestDecoder implements InterfaceHttpPostRequest
|
||||
* errors
|
||||
*/
|
||||
public HttpPostMultipartRequestDecoder(HttpDataFactory factory, HttpRequest request, Charset charset) {
|
||||
this.request = checkNotNull(request, "request");
|
||||
this.charset = checkNotNull(charset, "charset");
|
||||
this.factory = checkNotNull(factory, "factory");
|
||||
this.request = requireNonNull(request, "request");
|
||||
this.charset = requireNonNull(charset, "charset");
|
||||
this.factory = requireNonNull(factory, "factory");
|
||||
// Fill default values
|
||||
|
||||
setMultipart(this.request.headers().get(HttpHeaderNames.CONTENT_TYPE));
|
||||
|
@ -15,6 +15,8 @@
|
||||
*/
|
||||
package io.netty.handler.codec.http.multipart;
|
||||
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
import io.netty.handler.codec.DecoderException;
|
||||
import io.netty.handler.codec.http.HttpConstants;
|
||||
import io.netty.handler.codec.http.HttpContent;
|
||||
@ -83,15 +85,9 @@ public class HttpPostRequestDecoder implements InterfaceHttpPostRequestDecoder {
|
||||
* errors
|
||||
*/
|
||||
public HttpPostRequestDecoder(HttpDataFactory factory, HttpRequest request, Charset charset) {
|
||||
if (factory == null) {
|
||||
throw new NullPointerException("factory");
|
||||
}
|
||||
if (request == null) {
|
||||
throw new NullPointerException("request");
|
||||
}
|
||||
if (charset == null) {
|
||||
throw new NullPointerException("charset");
|
||||
}
|
||||
requireNonNull(factory, "factory");
|
||||
requireNonNull(request, "request");
|
||||
requireNonNull(charset, "charset");
|
||||
// Fill default values
|
||||
if (isMultipart(request)) {
|
||||
decoder = new HttpPostMultipartRequestDecoder(factory, request, charset);
|
||||
|
@ -49,8 +49,8 @@ import java.util.concurrent.ThreadLocalRandom;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static io.netty.buffer.Unpooled.wrappedBuffer;
|
||||
import static io.netty.util.internal.ObjectUtil.checkNotNull;
|
||||
import static java.util.AbstractMap.SimpleImmutableEntry;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
/**
|
||||
* This encoder will help to encode Request for a FORM as POST.
|
||||
@ -209,9 +209,9 @@ public class HttpPostRequestEncoder implements ChunkedInput<HttpContent> {
|
||||
HttpDataFactory factory, HttpRequest request, boolean multipart, Charset charset,
|
||||
EncoderMode encoderMode)
|
||||
throws ErrorDataEncoderException {
|
||||
this.request = checkNotNull(request, "request");
|
||||
this.charset = checkNotNull(charset, "charset");
|
||||
this.factory = checkNotNull(factory, "factory");
|
||||
this.request = requireNonNull(request, "request");
|
||||
this.charset = requireNonNull(charset, "charset");
|
||||
this.factory = requireNonNull(factory, "factory");
|
||||
if (HttpMethod.TRACE.equals(request.method())) {
|
||||
throw new ErrorDataEncoderException("Cannot create a Encoder if request is a TRACE");
|
||||
}
|
||||
@ -310,9 +310,7 @@ public class HttpPostRequestEncoder implements ChunkedInput<HttpContent> {
|
||||
* if the encoding is in error or if the finalize were already done
|
||||
*/
|
||||
public void setBodyHttpDatas(List<InterfaceHttpData> datas) throws ErrorDataEncoderException {
|
||||
if (datas == null) {
|
||||
throw new NullPointerException("datas");
|
||||
}
|
||||
requireNonNull(datas, "datas");
|
||||
globalBodySize = 0;
|
||||
bodyListDatas.clear();
|
||||
currentFileUpload = null;
|
||||
@ -337,7 +335,7 @@ public class HttpPostRequestEncoder implements ChunkedInput<HttpContent> {
|
||||
*/
|
||||
public void addBodyAttribute(String name, String value) throws ErrorDataEncoderException {
|
||||
String svalue = value != null? value : StringUtil.EMPTY_STRING;
|
||||
Attribute data = factory.createAttribute(request, checkNotNull(name, "name"), svalue);
|
||||
Attribute data = factory.createAttribute(request, requireNonNull(name, "name"), svalue);
|
||||
addBodyHttpData(data);
|
||||
}
|
||||
|
||||
@ -383,8 +381,8 @@ public class HttpPostRequestEncoder implements ChunkedInput<HttpContent> {
|
||||
*/
|
||||
public void addBodyFileUpload(String name, String filename, File file, String contentType, boolean isText)
|
||||
throws ErrorDataEncoderException {
|
||||
checkNotNull(name, "name");
|
||||
checkNotNull(file, "file");
|
||||
requireNonNull(name, "name");
|
||||
requireNonNull(file, "file");
|
||||
if (filename == null) {
|
||||
filename = StringUtil.EMPTY_STRING;
|
||||
}
|
||||
@ -448,7 +446,7 @@ public class HttpPostRequestEncoder implements ChunkedInput<HttpContent> {
|
||||
if (headerFinalized) {
|
||||
throw new ErrorDataEncoderException("Cannot add value once finalized");
|
||||
}
|
||||
bodyListDatas.add(checkNotNull(data, "data"));
|
||||
bodyListDatas.add(requireNonNull(data, "data"));
|
||||
if (!isMultipart) {
|
||||
if (data instanceof Attribute) {
|
||||
Attribute attribute = (Attribute) data;
|
||||
|
@ -35,7 +35,8 @@ import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import static io.netty.buffer.Unpooled.*;
|
||||
import static io.netty.util.internal.ObjectUtil.*;
|
||||
import static io.netty.util.internal.ObjectUtil.checkPositiveOrZero;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
/**
|
||||
* This decoder will decode Body and can handle POST BODY.
|
||||
@ -145,9 +146,9 @@ public class HttpPostStandardRequestDecoder implements InterfaceHttpPostRequestD
|
||||
* errors
|
||||
*/
|
||||
public HttpPostStandardRequestDecoder(HttpDataFactory factory, HttpRequest request, Charset charset) {
|
||||
this.request = checkNotNull(request, "request");
|
||||
this.charset = checkNotNull(charset, "charset");
|
||||
this.factory = checkNotNull(factory, "factory");
|
||||
this.request = requireNonNull(request, "request");
|
||||
this.charset = requireNonNull(charset, "charset");
|
||||
this.factory = requireNonNull(factory, "factory");
|
||||
if (request instanceof HttpContent) {
|
||||
// Offer automatically if the given request is als type of HttpContent
|
||||
// See #1089
|
||||
|
@ -15,6 +15,8 @@
|
||||
*/
|
||||
package io.netty.handler.codec.http.multipart;
|
||||
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.util.AbstractReferenceCounted;
|
||||
@ -42,27 +44,21 @@ final class InternalAttribute extends AbstractReferenceCounted implements Interf
|
||||
}
|
||||
|
||||
public void addValue(String value) {
|
||||
if (value == null) {
|
||||
throw new NullPointerException("value");
|
||||
}
|
||||
requireNonNull(value, "value");
|
||||
ByteBuf buf = Unpooled.copiedBuffer(value, charset);
|
||||
this.value.add(buf);
|
||||
size += buf.readableBytes();
|
||||
}
|
||||
|
||||
public void addValue(String value, int rank) {
|
||||
if (value == null) {
|
||||
throw new NullPointerException("value");
|
||||
}
|
||||
requireNonNull(value, "value");
|
||||
ByteBuf buf = Unpooled.copiedBuffer(value, charset);
|
||||
this.value.add(rank, buf);
|
||||
size += buf.readableBytes();
|
||||
}
|
||||
|
||||
public void setValue(String value, int rank) {
|
||||
if (value == null) {
|
||||
throw new NullPointerException("value");
|
||||
}
|
||||
requireNonNull(value, "value");
|
||||
ByteBuf buf = Unpooled.copiedBuffer(value, charset);
|
||||
ByteBuf old = this.value.set(rank, buf);
|
||||
if (old != null) {
|
||||
|
@ -23,6 +23,7 @@ import java.io.IOException;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
import static io.netty.buffer.Unpooled.*;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
/**
|
||||
* Memory implementation of Attributes
|
||||
@ -66,9 +67,7 @@ public class MemoryAttribute extends AbstractMemoryHttpData implements Attribute
|
||||
|
||||
@Override
|
||||
public void setValue(String value) throws IOException {
|
||||
if (value == null) {
|
||||
throw new NullPointerException("value");
|
||||
}
|
||||
requireNonNull(value, "value");
|
||||
byte [] bytes = value.getBytes(getCharset());
|
||||
checkSize(bytes.length);
|
||||
ByteBuf buffer = wrappedBuffer(bytes);
|
||||
|
@ -15,6 +15,8 @@
|
||||
*/
|
||||
package io.netty.handler.codec.http.multipart;
|
||||
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.ChannelException;
|
||||
import io.netty.handler.codec.http.HttpHeaderNames;
|
||||
@ -56,9 +58,7 @@ public class MemoryFileUpload extends AbstractMemoryHttpData implements FileUplo
|
||||
|
||||
@Override
|
||||
public void setFilename(String filename) {
|
||||
if (filename == null) {
|
||||
throw new NullPointerException("filename");
|
||||
}
|
||||
requireNonNull(filename, "filename");
|
||||
this.filename = filename;
|
||||
}
|
||||
|
||||
@ -87,9 +87,7 @@ public class MemoryFileUpload extends AbstractMemoryHttpData implements FileUplo
|
||||
|
||||
@Override
|
||||
public void setContentType(String contentType) {
|
||||
if (contentType == null) {
|
||||
throw new NullPointerException("contentType");
|
||||
}
|
||||
requireNonNull(contentType, "contentType");
|
||||
this.contentType = contentType;
|
||||
}
|
||||
|
||||
|
@ -15,11 +15,12 @@
|
||||
*/
|
||||
package io.netty.handler.codec.http.websocketx;
|
||||
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.ByteBufAllocator;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.handler.stream.ChunkedInput;
|
||||
import io.netty.util.internal.ObjectUtil;
|
||||
|
||||
/**
|
||||
* A {@link ChunkedInput} that fetches data chunk by chunk for use with WebSocket chunked transfers.
|
||||
@ -48,7 +49,7 @@ public final class WebSocketChunkedInput implements ChunkedInput<WebSocketFrame>
|
||||
* @throws NullPointerException if {@code input} is null
|
||||
*/
|
||||
public WebSocketChunkedInput(ChunkedInput<ByteBuf> input, int rsv) {
|
||||
this.input = ObjectUtil.checkNotNull(input, "input");
|
||||
this.input = requireNonNull(input, "input");
|
||||
this.rsv = rsv;
|
||||
}
|
||||
|
||||
|
@ -15,6 +15,8 @@
|
||||
*/
|
||||
package io.netty.handler.codec.http.websocketx;
|
||||
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelFuture;
|
||||
import io.netty.channel.ChannelFutureListener;
|
||||
@ -147,9 +149,7 @@ public abstract class WebSocketClientHandshaker {
|
||||
* Channel
|
||||
*/
|
||||
public ChannelFuture handshake(Channel channel) {
|
||||
if (channel == null) {
|
||||
throw new NullPointerException("channel");
|
||||
}
|
||||
requireNonNull(channel, "channel");
|
||||
return handshake(channel, channel.newPromise());
|
||||
}
|
||||
|
||||
@ -398,9 +398,7 @@ public abstract class WebSocketClientHandshaker {
|
||||
* Closing Frame that was received
|
||||
*/
|
||||
public ChannelFuture close(Channel channel, CloseWebSocketFrame frame) {
|
||||
if (channel == null) {
|
||||
throw new NullPointerException("channel");
|
||||
}
|
||||
requireNonNull(channel, "channel");
|
||||
return close(channel, frame, channel.newPromise());
|
||||
}
|
||||
|
||||
@ -415,9 +413,7 @@ public abstract class WebSocketClientHandshaker {
|
||||
* the {@link ChannelPromise} to be notified when the closing handshake is done
|
||||
*/
|
||||
public ChannelFuture close(Channel channel, CloseWebSocketFrame frame, ChannelPromise promise) {
|
||||
if (channel == null) {
|
||||
throw new NullPointerException("channel");
|
||||
}
|
||||
requireNonNull(channel, "channel");
|
||||
return channel.writeAndFlush(frame, promise);
|
||||
}
|
||||
|
||||
|
@ -15,6 +15,8 @@
|
||||
*/
|
||||
package io.netty.handler.codec.http.websocketx;
|
||||
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelFuture;
|
||||
import io.netty.channel.ChannelFutureListener;
|
||||
@ -305,9 +307,7 @@ public abstract class WebSocketServerHandshaker {
|
||||
* Closing Frame that was received
|
||||
*/
|
||||
public ChannelFuture close(Channel channel, CloseWebSocketFrame frame) {
|
||||
if (channel == null) {
|
||||
throw new NullPointerException("channel");
|
||||
}
|
||||
requireNonNull(channel, "channel");
|
||||
return close(channel, frame, channel.newPromise());
|
||||
}
|
||||
|
||||
@ -322,9 +322,7 @@ public abstract class WebSocketServerHandshaker {
|
||||
* the {@link ChannelPromise} to be notified when the closing handshake is done
|
||||
*/
|
||||
public ChannelFuture close(Channel channel, CloseWebSocketFrame frame, ChannelPromise promise) {
|
||||
if (channel == null) {
|
||||
throw new NullPointerException("channel");
|
||||
}
|
||||
requireNonNull(channel, "channel");
|
||||
return channel.writeAndFlush(frame, promise).addListener(ChannelFutureListener.CLOSE);
|
||||
}
|
||||
|
||||
|
@ -15,6 +15,8 @@
|
||||
*/
|
||||
package io.netty.handler.codec.http.websocketx.extensions;
|
||||
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
import io.netty.channel.ChannelDuplexHandler;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelPromise;
|
||||
@ -50,9 +52,7 @@ public class WebSocketClientExtensionHandler extends ChannelDuplexHandler {
|
||||
* with fallback configuration.
|
||||
*/
|
||||
public WebSocketClientExtensionHandler(WebSocketClientExtensionHandshaker... extensionHandshakers) {
|
||||
if (extensionHandshakers == null) {
|
||||
throw new NullPointerException("extensionHandshakers");
|
||||
}
|
||||
requireNonNull(extensionHandshakers, "extensionHandshakers");
|
||||
if (extensionHandshakers.length == 0) {
|
||||
throw new IllegalArgumentException("extensionHandshakers must contains at least one handshaker");
|
||||
}
|
||||
|
@ -15,6 +15,8 @@
|
||||
*/
|
||||
package io.netty.handler.codec.http.websocketx.extensions;
|
||||
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
|
||||
@ -29,12 +31,8 @@ public final class WebSocketExtensionData {
|
||||
private final Map<String, String> parameters;
|
||||
|
||||
public WebSocketExtensionData(String name, Map<String, String> parameters) {
|
||||
if (name == null) {
|
||||
throw new NullPointerException("name");
|
||||
}
|
||||
if (parameters == null) {
|
||||
throw new NullPointerException("parameters");
|
||||
}
|
||||
requireNonNull(name, "name");
|
||||
requireNonNull(parameters, "parameters");
|
||||
this.name = name;
|
||||
this.parameters = Collections.unmodifiableMap(parameters);
|
||||
}
|
||||
|
@ -15,8 +15,9 @@
|
||||
*/
|
||||
package io.netty.handler.codec.http.websocketx.extensions;
|
||||
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
import io.netty.channel.ChannelDuplexHandler;
|
||||
import io.netty.channel.ChannelFuture;
|
||||
import io.netty.channel.ChannelFutureListener;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelPromise;
|
||||
@ -53,9 +54,7 @@ public class WebSocketServerExtensionHandler extends ChannelDuplexHandler {
|
||||
* with fallback configuration.
|
||||
*/
|
||||
public WebSocketServerExtensionHandler(WebSocketServerExtensionHandshaker... extensionHandshakers) {
|
||||
if (extensionHandshakers == null) {
|
||||
throw new NullPointerException("extensionHandshakers");
|
||||
}
|
||||
requireNonNull(extensionHandshakers, "extensionHandshakers");
|
||||
if (extensionHandshakers.length == 0) {
|
||||
throw new IllegalArgumentException("extensionHandshakers must contains at least one handshaker");
|
||||
}
|
||||
|
@ -15,6 +15,8 @@
|
||||
*/
|
||||
package io.netty.handler.codec.rtsp;
|
||||
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
import io.netty.handler.codec.http.HttpMethod;
|
||||
|
||||
import java.util.HashMap;
|
||||
@ -117,9 +119,7 @@ public final class RtspMethods {
|
||||
* will be returned. Otherwise, a new instance will be returned.
|
||||
*/
|
||||
public static HttpMethod valueOf(String name) {
|
||||
if (name == null) {
|
||||
throw new NullPointerException("name");
|
||||
}
|
||||
requireNonNull(name, "name");
|
||||
|
||||
name = name.trim().toUpperCase();
|
||||
if (name.isEmpty()) {
|
||||
|
@ -15,6 +15,8 @@
|
||||
*/
|
||||
package io.netty.handler.codec.rtsp;
|
||||
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
import io.netty.handler.codec.http.HttpVersion;
|
||||
|
||||
/**
|
||||
@ -34,9 +36,7 @@ public final class RtspVersions {
|
||||
* Otherwise, a new {@link HttpVersion} instance will be returned.
|
||||
*/
|
||||
public static HttpVersion valueOf(String text) {
|
||||
if (text == null) {
|
||||
throw new NullPointerException("text");
|
||||
}
|
||||
requireNonNull(text, "text");
|
||||
|
||||
text = text.trim().toUpperCase();
|
||||
if ("RTSP/1.0".equals(text)) {
|
||||
|
@ -22,9 +22,9 @@ import io.netty.util.internal.UnstableApi;
|
||||
import static io.netty.handler.codec.http2.Http2CodecUtil.DEFAULT_HEADER_LIST_SIZE;
|
||||
import static io.netty.handler.codec.http2.Http2CodecUtil.DEFAULT_INITIAL_HUFFMAN_DECODE_CAPACITY;
|
||||
import static io.netty.handler.codec.http2.Http2CodecUtil.DEFAULT_MAX_RESERVED_STREAMS;
|
||||
import static io.netty.util.internal.ObjectUtil.checkNotNull;
|
||||
import static io.netty.util.internal.ObjectUtil.checkPositive;
|
||||
import static io.netty.util.internal.ObjectUtil.checkPositiveOrZero;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
/**
|
||||
* Abstract base class which defines commonly used features required to build {@link Http2ConnectionHandler} instances.
|
||||
@ -116,7 +116,7 @@ public abstract class AbstractHttp2ConnectionHandlerBuilder<T extends Http2Conne
|
||||
* Sets the {@link Http2Settings} to use for the initial connection settings exchange.
|
||||
*/
|
||||
protected B initialSettings(Http2Settings settings) {
|
||||
initialSettings = checkNotNull(settings, "settings");
|
||||
initialSettings = requireNonNull(settings, "settings");
|
||||
return self();
|
||||
}
|
||||
|
||||
@ -134,7 +134,7 @@ public abstract class AbstractHttp2ConnectionHandlerBuilder<T extends Http2Conne
|
||||
* This listener will only be set if the decoder's listener is {@code null}.
|
||||
*/
|
||||
protected B frameListener(Http2FrameListener frameListener) {
|
||||
this.frameListener = checkNotNull(frameListener, "frameListener");
|
||||
this.frameListener = requireNonNull(frameListener, "frameListener");
|
||||
return self();
|
||||
}
|
||||
|
||||
@ -220,7 +220,7 @@ public abstract class AbstractHttp2ConnectionHandlerBuilder<T extends Http2Conne
|
||||
enforceConstraint("connection", "codec", decoder);
|
||||
enforceConstraint("connection", "codec", encoder);
|
||||
|
||||
this.connection = checkNotNull(connection, "connection");
|
||||
this.connection = requireNonNull(connection, "connection");
|
||||
|
||||
return self();
|
||||
}
|
||||
@ -255,8 +255,8 @@ public abstract class AbstractHttp2ConnectionHandlerBuilder<T extends Http2Conne
|
||||
enforceConstraint("codec", "headerSensitivityDetector", headerSensitivityDetector);
|
||||
enforceConstraint("codec", "encoderEnforceMaxConcurrentStreams", encoderEnforceMaxConcurrentStreams);
|
||||
|
||||
checkNotNull(decoder, "decoder");
|
||||
checkNotNull(encoder, "encoder");
|
||||
requireNonNull(decoder, "decoder");
|
||||
requireNonNull(encoder, "encoder");
|
||||
|
||||
if (decoder.connection() != encoder.connection()) {
|
||||
throw new IllegalArgumentException("The specified encoder and decoder have different connections.");
|
||||
@ -300,7 +300,7 @@ public abstract class AbstractHttp2ConnectionHandlerBuilder<T extends Http2Conne
|
||||
*/
|
||||
protected B frameLogger(Http2FrameLogger frameLogger) {
|
||||
enforceNonCodecConstraints("frameLogger");
|
||||
this.frameLogger = checkNotNull(frameLogger, "frameLogger");
|
||||
this.frameLogger = requireNonNull(frameLogger, "frameLogger");
|
||||
return self();
|
||||
}
|
||||
|
||||
@ -334,7 +334,7 @@ public abstract class AbstractHttp2ConnectionHandlerBuilder<T extends Http2Conne
|
||||
*/
|
||||
protected B headerSensitivityDetector(SensitivityDetector headerSensitivityDetector) {
|
||||
enforceNonCodecConstraints("headerSensitivityDetector");
|
||||
this.headerSensitivityDetector = checkNotNull(headerSensitivityDetector, "headerSensitivityDetector");
|
||||
this.headerSensitivityDetector = requireNonNull(headerSensitivityDetector, "headerSensitivityDetector");
|
||||
return self();
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,7 @@ package io.netty.handler.codec.http2;
|
||||
import io.netty.handler.codec.TooLongFrameException;
|
||||
import io.netty.util.internal.UnstableApi;
|
||||
|
||||
import static io.netty.util.internal.ObjectUtil.checkNotNull;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
/**
|
||||
* A skeletal builder implementation of {@link InboundHttp2ToHttpAdapter} and its subtypes.
|
||||
@ -38,7 +38,7 @@ public abstract class AbstractInboundHttp2ToHttpAdapterBuilder<
|
||||
* for the current connection
|
||||
*/
|
||||
protected AbstractInboundHttp2ToHttpAdapterBuilder(Http2Connection connection) {
|
||||
this.connection = checkNotNull(connection, "connection");
|
||||
this.connection = requireNonNull(connection, "connection");
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
|
@ -30,7 +30,7 @@ import java.util.List;
|
||||
import static io.netty.buffer.Unpooled.unreleasableBuffer;
|
||||
import static io.netty.handler.codec.http2.Http2CodecUtil.connectionPrefaceBuf;
|
||||
|
||||
import static io.netty.util.internal.ObjectUtil.checkNotNull;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
/**
|
||||
* Performing cleartext upgrade, by h2c HTTP upgrade or Prior Knowledge.
|
||||
@ -58,9 +58,9 @@ public final class CleartextHttp2ServerUpgradeHandler extends ChannelHandlerAdap
|
||||
public CleartextHttp2ServerUpgradeHandler(HttpServerCodec httpServerCodec,
|
||||
HttpServerUpgradeHandler httpServerUpgradeHandler,
|
||||
ChannelHandler http2ServerHandler) {
|
||||
this.httpServerCodec = checkNotNull(httpServerCodec, "httpServerCodec");
|
||||
this.httpServerUpgradeHandler = checkNotNull(httpServerUpgradeHandler, "httpServerUpgradeHandler");
|
||||
this.http2ServerHandler = checkNotNull(http2ServerHandler, "http2ServerHandler");
|
||||
this.httpServerCodec = requireNonNull(httpServerCodec, "httpServerCodec");
|
||||
this.httpServerUpgradeHandler = requireNonNull(httpServerUpgradeHandler, "httpServerUpgradeHandler");
|
||||
this.http2ServerHandler = requireNonNull(http2ServerHandler, "http2ServerHandler");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -14,7 +14,7 @@
|
||||
*/
|
||||
package io.netty.handler.codec.http2;
|
||||
|
||||
import static io.netty.util.internal.ObjectUtil.checkNotNull;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
@ -30,7 +30,7 @@ public class DecoratingHttp2ConnectionDecoder implements Http2ConnectionDecoder
|
||||
private final Http2ConnectionDecoder delegate;
|
||||
|
||||
public DecoratingHttp2ConnectionDecoder(Http2ConnectionDecoder delegate) {
|
||||
this.delegate = checkNotNull(delegate, "delegate");
|
||||
this.delegate = requireNonNull(delegate, "delegate");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -16,7 +16,7 @@ package io.netty.handler.codec.http2;
|
||||
|
||||
import io.netty.util.internal.UnstableApi;
|
||||
|
||||
import static io.netty.util.internal.ObjectUtil.checkNotNull;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
/**
|
||||
* A decorator around another {@link Http2ConnectionEncoder} instance.
|
||||
@ -27,7 +27,7 @@ public class DecoratingHttp2ConnectionEncoder extends DecoratingHttp2FrameWriter
|
||||
|
||||
public DecoratingHttp2ConnectionEncoder(Http2ConnectionEncoder delegate) {
|
||||
super(delegate);
|
||||
this.delegate = checkNotNull(delegate, "delegate");
|
||||
this.delegate = requireNonNull(delegate, "delegate");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -20,7 +20,7 @@ import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelPromise;
|
||||
import io.netty.util.internal.UnstableApi;
|
||||
|
||||
import static io.netty.util.internal.ObjectUtil.checkNotNull;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
/**
|
||||
* Decorator around another {@link Http2FrameWriter} instance.
|
||||
@ -30,7 +30,7 @@ public class DecoratingHttp2FrameWriter implements Http2FrameWriter {
|
||||
private final Http2FrameWriter delegate;
|
||||
|
||||
public DecoratingHttp2FrameWriter(Http2FrameWriter delegate) {
|
||||
this.delegate = checkNotNull(delegate, "delegate");
|
||||
this.delegate = requireNonNull(delegate, "delegate");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -53,9 +53,9 @@ import static io.netty.handler.codec.http2.Http2Stream.State.IDLE;
|
||||
import static io.netty.handler.codec.http2.Http2Stream.State.OPEN;
|
||||
import static io.netty.handler.codec.http2.Http2Stream.State.RESERVED_LOCAL;
|
||||
import static io.netty.handler.codec.http2.Http2Stream.State.RESERVED_REMOTE;
|
||||
import static io.netty.util.internal.ObjectUtil.checkNotNull;
|
||||
import static io.netty.util.internal.ObjectUtil.checkPositiveOrZero;
|
||||
import static java.lang.Integer.MAX_VALUE;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
/**
|
||||
* Simple implementation of {@link Http2Connection}.
|
||||
@ -118,7 +118,7 @@ public class DefaultHttp2Connection implements Http2Connection {
|
||||
|
||||
@Override
|
||||
public Future<Void> close(final Promise<Void> promise) {
|
||||
checkNotNull(promise, "promise");
|
||||
requireNonNull(promise, "promise");
|
||||
// Since we allow this method to be called multiple times, we must make sure that all the promises are notified
|
||||
// when all streams are removed and the close operation completes.
|
||||
if (closePromise != null) {
|
||||
@ -370,7 +370,7 @@ public class DefaultHttp2Connection implements Http2Connection {
|
||||
* @throws IllegalArgumentException if the key was not created by this connection.
|
||||
*/
|
||||
final DefaultPropertyKey verifyKey(PropertyKey key) {
|
||||
return checkNotNull((DefaultPropertyKey) key, "key").verifyConnection(this);
|
||||
return requireNonNull((DefaultPropertyKey) key, "key").verifyConnection(this);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -853,7 +853,7 @@ public class DefaultHttp2Connection implements Http2Connection {
|
||||
|
||||
@Override
|
||||
public void flowController(F flowController) {
|
||||
this.flowController = checkNotNull(flowController, "flowController");
|
||||
this.flowController = requireNonNull(flowController, "flowController");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -34,9 +34,9 @@ import static io.netty.handler.codec.http2.Http2Exception.streamError;
|
||||
import static io.netty.handler.codec.http2.Http2PromisedRequestVerifier.ALWAYS_VERIFY;
|
||||
import static io.netty.handler.codec.http2.Http2Stream.State.CLOSED;
|
||||
import static io.netty.handler.codec.http2.Http2Stream.State.HALF_CLOSED_REMOTE;
|
||||
import static io.netty.util.internal.ObjectUtil.checkNotNull;
|
||||
import static java.lang.Integer.MAX_VALUE;
|
||||
import static java.lang.Math.min;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
/**
|
||||
* Provides the default implementation for processing inbound frame events and delegates to a
|
||||
@ -68,10 +68,10 @@ public class DefaultHttp2ConnectionDecoder implements Http2ConnectionDecoder {
|
||||
Http2ConnectionEncoder encoder,
|
||||
Http2FrameReader frameReader,
|
||||
Http2PromisedRequestVerifier requestVerifier) {
|
||||
this.connection = checkNotNull(connection, "connection");
|
||||
this.frameReader = checkNotNull(frameReader, "frameReader");
|
||||
this.encoder = checkNotNull(encoder, "encoder");
|
||||
this.requestVerifier = checkNotNull(requestVerifier, "requestVerifier");
|
||||
this.connection = requireNonNull(connection, "connection");
|
||||
this.frameReader = requireNonNull(frameReader, "frameReader");
|
||||
this.encoder = requireNonNull(encoder, "encoder");
|
||||
this.requestVerifier = requireNonNull(requestVerifier, "requestVerifier");
|
||||
if (connection.local().flowController() == null) {
|
||||
connection.local().flowController(new DefaultHttp2LocalFlowController(connection));
|
||||
}
|
||||
@ -80,7 +80,7 @@ public class DefaultHttp2ConnectionDecoder implements Http2ConnectionDecoder {
|
||||
|
||||
@Override
|
||||
public void lifecycleManager(Http2LifecycleManager lifecycleManager) {
|
||||
this.lifecycleManager = checkNotNull(lifecycleManager, "lifecycleManager");
|
||||
this.lifecycleManager = requireNonNull(lifecycleManager, "lifecycleManager");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -95,7 +95,7 @@ public class DefaultHttp2ConnectionDecoder implements Http2ConnectionDecoder {
|
||||
|
||||
@Override
|
||||
public void frameListener(Http2FrameListener listener) {
|
||||
this.listener = checkNotNull(listener, "listener");
|
||||
this.listener = requireNonNull(listener, "listener");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -29,9 +29,9 @@ import static io.netty.handler.codec.http.HttpStatusClass.INFORMATIONAL;
|
||||
import static io.netty.handler.codec.http2.Http2CodecUtil.DEFAULT_PRIORITY_WEIGHT;
|
||||
import static io.netty.handler.codec.http2.Http2Error.PROTOCOL_ERROR;
|
||||
import static io.netty.handler.codec.http2.Http2Exception.connectionError;
|
||||
import static io.netty.util.internal.ObjectUtil.checkNotNull;
|
||||
import static java.lang.Integer.MAX_VALUE;
|
||||
import static java.lang.Math.min;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
/**
|
||||
* Default implementation of {@link Http2ConnectionEncoder}.
|
||||
@ -46,8 +46,8 @@ public class DefaultHttp2ConnectionEncoder implements Http2ConnectionEncoder {
|
||||
private final ArrayDeque<Http2Settings> outstandingLocalSettingsQueue = new ArrayDeque<>(4);
|
||||
|
||||
public DefaultHttp2ConnectionEncoder(Http2Connection connection, Http2FrameWriter frameWriter) {
|
||||
this.connection = checkNotNull(connection, "connection");
|
||||
this.frameWriter = checkNotNull(frameWriter, "frameWriter");
|
||||
this.connection = requireNonNull(connection, "connection");
|
||||
this.frameWriter = requireNonNull(frameWriter, "frameWriter");
|
||||
if (connection.remote().flowController() == null) {
|
||||
connection.remote().flowController(new DefaultHttp2RemoteFlowController(connection));
|
||||
}
|
||||
@ -55,7 +55,7 @@ public class DefaultHttp2ConnectionEncoder implements Http2ConnectionEncoder {
|
||||
|
||||
@Override
|
||||
public void lifecycleManager(Http2LifecycleManager lifecycleManager) {
|
||||
this.lifecycleManager = checkNotNull(lifecycleManager, "lifecycleManager");
|
||||
this.lifecycleManager = requireNonNull(lifecycleManager, "lifecycleManager");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -22,7 +22,7 @@ import io.netty.util.internal.StringUtil;
|
||||
import io.netty.util.internal.UnstableApi;
|
||||
|
||||
import static io.netty.handler.codec.http2.Http2CodecUtil.verifyPadding;
|
||||
import static io.netty.util.internal.ObjectUtil.checkNotNull;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
/**
|
||||
* The default {@link Http2DataFrame} implementation.
|
||||
@ -71,7 +71,7 @@ public final class DefaultHttp2DataFrame extends AbstractHttp2StreamFrame implem
|
||||
* 256 (inclusive).
|
||||
*/
|
||||
public DefaultHttp2DataFrame(ByteBuf content, boolean endStream, int padding) {
|
||||
this.content = checkNotNull(content, "content");
|
||||
this.content = requireNonNull(content, "content");
|
||||
this.endStream = endStream;
|
||||
verifyPadding(padding);
|
||||
this.padding = padding;
|
||||
|
@ -60,9 +60,9 @@ import static io.netty.handler.codec.http2.Http2FrameTypes.PUSH_PROMISE;
|
||||
import static io.netty.handler.codec.http2.Http2FrameTypes.RST_STREAM;
|
||||
import static io.netty.handler.codec.http2.Http2FrameTypes.SETTINGS;
|
||||
import static io.netty.handler.codec.http2.Http2FrameTypes.WINDOW_UPDATE;
|
||||
import static io.netty.util.internal.ObjectUtil.checkNotNull;
|
||||
import static java.lang.Math.max;
|
||||
import static java.lang.Math.min;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
/**
|
||||
* A {@link Http2FrameWriter} that supports all frame types defined by the HTTP/2 specification.
|
||||
@ -306,7 +306,7 @@ public class DefaultHttp2FrameWriter implements Http2FrameWriter, Http2FrameSize
|
||||
public ChannelFuture writeSettings(ChannelHandlerContext ctx, Http2Settings settings,
|
||||
ChannelPromise promise) {
|
||||
try {
|
||||
checkNotNull(settings, "settings");
|
||||
requireNonNull(settings, "settings");
|
||||
int payloadLength = SETTING_ENTRY_LENGTH * settings.size();
|
||||
ByteBuf buf = ctx.alloc().buffer(FRAME_HEADER_LENGTH + settings.size() * SETTING_ENTRY_LENGTH);
|
||||
writeFrameHeaderInternal(buf, payloadLength, SETTINGS, new Http2Flags(), 0);
|
||||
|
@ -16,7 +16,6 @@
|
||||
package io.netty.handler.codec.http2;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.util.internal.ObjectUtil;
|
||||
import io.netty.util.internal.UnstableApi;
|
||||
|
||||
import static io.netty.handler.codec.http2.Http2CodecUtil.DEFAULT_HEADER_LIST_SIZE;
|
||||
@ -24,6 +23,7 @@ import static io.netty.handler.codec.http2.Http2CodecUtil.DEFAULT_INITIAL_HUFFMA
|
||||
import static io.netty.handler.codec.http2.Http2Error.COMPRESSION_ERROR;
|
||||
import static io.netty.handler.codec.http2.Http2Error.INTERNAL_ERROR;
|
||||
import static io.netty.handler.codec.http2.Http2Exception.connectionError;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
@UnstableApi
|
||||
public class DefaultHttp2HeadersDecoder implements Http2HeadersDecoder, Http2HeadersDecoder.Configuration {
|
||||
@ -79,7 +79,7 @@ public class DefaultHttp2HeadersDecoder implements Http2HeadersDecoder, Http2Hea
|
||||
* for testing but violate the RFC if used outside the scope of testing.
|
||||
*/
|
||||
DefaultHttp2HeadersDecoder(boolean validateHeaders, HpackDecoder hpackDecoder) {
|
||||
this.hpackDecoder = ObjectUtil.checkNotNull(hpackDecoder, "hpackDecoder");
|
||||
this.hpackDecoder = requireNonNull(hpackDecoder, "hpackDecoder");
|
||||
this.validateHeaders = validateHeaders;
|
||||
this.maxHeaderListSizeGoAway =
|
||||
Http2CodecUtil.calculateMaxHeaderListSizeGoAway(hpackDecoder.getMaxHeaderListSize());
|
||||
|
@ -21,7 +21,7 @@ import io.netty.util.internal.UnstableApi;
|
||||
|
||||
import static io.netty.handler.codec.http2.Http2Error.COMPRESSION_ERROR;
|
||||
import static io.netty.handler.codec.http2.Http2Exception.connectionError;
|
||||
import static io.netty.util.internal.ObjectUtil.checkNotNull;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
@UnstableApi
|
||||
public class DefaultHttp2HeadersEncoder implements Http2HeadersEncoder, Http2HeadersEncoder.Configuration {
|
||||
@ -51,8 +51,8 @@ public class DefaultHttp2HeadersEncoder implements Http2HeadersEncoder, Http2Hea
|
||||
* for testing but violate the RFC if used outside the scope of testing.
|
||||
*/
|
||||
DefaultHttp2HeadersEncoder(SensitivityDetector sensitivityDetector, HpackEncoder hpackEncoder) {
|
||||
this.sensitivityDetector = checkNotNull(sensitivityDetector, "sensitiveDetector");
|
||||
this.hpackEncoder = checkNotNull(hpackEncoder, "hpackEncoder");
|
||||
this.sensitivityDetector = requireNonNull(sensitivityDetector, "sensitiveDetector");
|
||||
this.hpackEncoder = requireNonNull(hpackEncoder, "hpackEncoder");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -19,7 +19,7 @@ import io.netty.util.internal.StringUtil;
|
||||
import io.netty.util.internal.UnstableApi;
|
||||
|
||||
import static io.netty.handler.codec.http2.Http2CodecUtil.verifyPadding;
|
||||
import static io.netty.util.internal.ObjectUtil.checkNotNull;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
/**
|
||||
* The default {@link Http2HeadersFrame} implementation.
|
||||
@ -57,7 +57,7 @@ public final class DefaultHttp2HeadersFrame extends AbstractHttp2StreamFrame imp
|
||||
* 256 (inclusive).
|
||||
*/
|
||||
public DefaultHttp2HeadersFrame(Http2Headers headers, boolean endStream, int padding) {
|
||||
this.headers = checkNotNull(headers, "headers");
|
||||
this.headers = requireNonNull(headers, "headers");
|
||||
this.endStream = endStream;
|
||||
verifyPadding(padding);
|
||||
this.padding = padding;
|
||||
|
@ -23,9 +23,10 @@ import static io.netty.handler.codec.http2.Http2Error.FLOW_CONTROL_ERROR;
|
||||
import static io.netty.handler.codec.http2.Http2Error.INTERNAL_ERROR;
|
||||
import static io.netty.handler.codec.http2.Http2Exception.connectionError;
|
||||
import static io.netty.handler.codec.http2.Http2Exception.streamError;
|
||||
import static io.netty.util.internal.ObjectUtil.checkNotNull;
|
||||
import static java.lang.Math.max;
|
||||
import static java.lang.Math.min;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.handler.codec.http2.Http2Exception.CompositeStreamException;
|
||||
@ -74,7 +75,7 @@ public class DefaultHttp2LocalFlowController implements Http2LocalFlowController
|
||||
public DefaultHttp2LocalFlowController(Http2Connection connection,
|
||||
float windowUpdateRatio,
|
||||
boolean autoRefillConnectionWindow) {
|
||||
this.connection = checkNotNull(connection, "connection");
|
||||
this.connection = requireNonNull(connection, "connection");
|
||||
windowUpdateRatio(windowUpdateRatio);
|
||||
|
||||
// Add a flow state for the connection.
|
||||
@ -125,13 +126,13 @@ public class DefaultHttp2LocalFlowController implements Http2LocalFlowController
|
||||
|
||||
@Override
|
||||
public DefaultHttp2LocalFlowController frameWriter(Http2FrameWriter frameWriter) {
|
||||
this.frameWriter = checkNotNull(frameWriter, "frameWriter");
|
||||
this.frameWriter = requireNonNull(frameWriter, "frameWriter");
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void channelHandlerContext(ChannelHandlerContext ctx) {
|
||||
this.ctx = checkNotNull(ctx, "ctx");
|
||||
this.ctx = requireNonNull(ctx, "ctx");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -30,9 +30,9 @@ import static io.netty.handler.codec.http2.Http2Error.INTERNAL_ERROR;
|
||||
import static io.netty.handler.codec.http2.Http2Error.STREAM_CLOSED;
|
||||
import static io.netty.handler.codec.http2.Http2Exception.streamError;
|
||||
import static io.netty.handler.codec.http2.Http2Stream.State.HALF_CLOSED_LOCAL;
|
||||
import static io.netty.util.internal.ObjectUtil.checkNotNull;
|
||||
import static java.lang.Math.max;
|
||||
import static java.lang.Math.min;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
/**
|
||||
* Basic implementation of {@link Http2RemoteFlowController}.
|
||||
@ -69,8 +69,8 @@ public class DefaultHttp2RemoteFlowController implements Http2RemoteFlowControll
|
||||
public DefaultHttp2RemoteFlowController(Http2Connection connection,
|
||||
StreamByteDistributor streamByteDistributor,
|
||||
final Listener listener) {
|
||||
this.connection = checkNotNull(connection, "connection");
|
||||
this.streamByteDistributor = checkNotNull(streamByteDistributor, "streamWriteDistributor");
|
||||
this.connection = requireNonNull(connection, "connection");
|
||||
this.streamByteDistributor = requireNonNull(streamByteDistributor, "streamWriteDistributor");
|
||||
|
||||
// Add a flow state for the connection.
|
||||
stateKey = connection.newKey();
|
||||
@ -131,7 +131,7 @@ public class DefaultHttp2RemoteFlowController implements Http2RemoteFlowControll
|
||||
*/
|
||||
@Override
|
||||
public void channelHandlerContext(ChannelHandlerContext ctx) throws Http2Exception {
|
||||
this.ctx = checkNotNull(ctx, "ctx");
|
||||
this.ctx = requireNonNull(ctx, "ctx");
|
||||
|
||||
// Writing the pending bytes will not check writability change and instead a writability change notification
|
||||
// to be provided by an explicit call.
|
||||
@ -210,7 +210,7 @@ public class DefaultHttp2RemoteFlowController implements Http2RemoteFlowControll
|
||||
public void addFlowControlled(Http2Stream stream, FlowControlled frame) {
|
||||
// The context can be null assuming the frame will be queued and send later when the context is set.
|
||||
assert ctx == null || ctx.executor().inEventLoop();
|
||||
checkNotNull(frame, "frame");
|
||||
requireNonNull(frame, "frame");
|
||||
try {
|
||||
monitor.enqueueFrame(state(stream), frame);
|
||||
} catch (Throwable t) {
|
||||
|
@ -18,7 +18,7 @@ package io.netty.handler.codec.http2;
|
||||
import io.netty.util.internal.StringUtil;
|
||||
import io.netty.util.internal.UnstableApi;
|
||||
|
||||
import static io.netty.util.internal.ObjectUtil.checkNotNull;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
/**
|
||||
* The default {@link Http2ResetFrame} implementation.
|
||||
@ -34,7 +34,7 @@ public final class DefaultHttp2ResetFrame extends AbstractHttp2StreamFrame imple
|
||||
* @param error the non-{@code null} reason for reset
|
||||
*/
|
||||
public DefaultHttp2ResetFrame(Http2Error error) {
|
||||
errorCode = checkNotNull(error, "error").code();
|
||||
errorCode = requireNonNull(error, "error").code();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -16,7 +16,8 @@
|
||||
|
||||
package io.netty.handler.codec.http2;
|
||||
|
||||
import io.netty.util.internal.ObjectUtil;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
import io.netty.util.internal.StringUtil;
|
||||
import io.netty.util.internal.UnstableApi;
|
||||
|
||||
@ -29,7 +30,7 @@ public class DefaultHttp2SettingsFrame implements Http2SettingsFrame {
|
||||
private final Http2Settings settings;
|
||||
|
||||
public DefaultHttp2SettingsFrame(Http2Settings settings) {
|
||||
this.settings = ObjectUtil.checkNotNull(settings, "settings");
|
||||
this.settings = requireNonNull(settings, "settings");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -32,7 +32,7 @@ import static io.netty.handler.codec.http.HttpHeaderValues.X_DEFLATE;
|
||||
import static io.netty.handler.codec.http.HttpHeaderValues.X_GZIP;
|
||||
import static io.netty.handler.codec.http2.Http2Error.INTERNAL_ERROR;
|
||||
import static io.netty.handler.codec.http2.Http2Exception.streamError;
|
||||
import static io.netty.util.internal.ObjectUtil.checkNotNull;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
/**
|
||||
* A HTTP2 frame listener that will decompress data frames according to the {@code content-encoding} header for each
|
||||
@ -286,7 +286,7 @@ public class DelegatingDecompressorFrameListener extends Http2FrameListenerDecor
|
||||
private final Http2LocalFlowController flowController;
|
||||
|
||||
ConsumedBytesConverter(Http2LocalFlowController flowController) {
|
||||
this.flowController = checkNotNull(flowController, "flowController");
|
||||
this.flowController = requireNonNull(flowController, "flowController");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -31,7 +31,7 @@
|
||||
*/
|
||||
package io.netty.handler.codec.http2;
|
||||
|
||||
import static io.netty.util.internal.ObjectUtil.checkNotNull;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
class HpackHeaderField {
|
||||
|
||||
@ -49,8 +49,8 @@ class HpackHeaderField {
|
||||
|
||||
// This constructor can only be used if name and value are ISO-8859-1 encoded.
|
||||
HpackHeaderField(CharSequence name, CharSequence value) {
|
||||
this.name = checkNotNull(name, "name");
|
||||
this.value = checkNotNull(value, "value");
|
||||
this.name = requireNonNull(name, "name");
|
||||
this.value = requireNonNull(value, "value");
|
||||
}
|
||||
|
||||
final int size() {
|
||||
|
@ -31,10 +31,11 @@
|
||||
*/
|
||||
package io.netty.handler.codec.http2;
|
||||
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.util.AsciiString;
|
||||
import io.netty.util.ByteProcessor;
|
||||
import io.netty.util.internal.ObjectUtil;
|
||||
import io.netty.util.internal.PlatformDependent;
|
||||
|
||||
final class HpackHuffmanEncoder {
|
||||
@ -66,7 +67,7 @@ final class HpackHuffmanEncoder {
|
||||
* @param data the string literal to be Huffman encoded
|
||||
*/
|
||||
public void encode(ByteBuf out, CharSequence data) {
|
||||
ObjectUtil.checkNotNull(out, "out");
|
||||
requireNonNull(out, "out");
|
||||
if (data instanceof AsciiString) {
|
||||
AsciiString string = (AsciiString) data;
|
||||
try {
|
||||
|
@ -34,7 +34,7 @@ import static io.netty.handler.codec.http2.Http2CodecUtil.HTTP_UPGRADE_SETTINGS_
|
||||
import static io.netty.handler.codec.http2.Http2CodecUtil.SETTING_ENTRY_LENGTH;
|
||||
import static io.netty.util.CharsetUtil.UTF_8;
|
||||
import static io.netty.util.ReferenceCountUtil.release;
|
||||
import static io.netty.util.internal.ObjectUtil.checkNotNull;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
/**
|
||||
* Client-side cleartext upgrade codec from HTTP to HTTP/2.
|
||||
@ -80,8 +80,8 @@ public class Http2ClientUpgradeCodec implements HttpClientUpgradeHandler.Upgrade
|
||||
private Http2ClientUpgradeCodec(String handlerName, Http2ConnectionHandler connectionHandler, ChannelHandler
|
||||
upgradeToHandler) {
|
||||
this.handlerName = handlerName;
|
||||
this.connectionHandler = checkNotNull(connectionHandler, "connectionHandler");
|
||||
this.upgradeToHandler = checkNotNull(upgradeToHandler, "upgradeToHandler");
|
||||
this.connectionHandler = requireNonNull(connectionHandler, "connectionHandler");
|
||||
this.upgradeToHandler = requireNonNull(upgradeToHandler, "upgradeToHandler");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -49,8 +49,8 @@ import static io.netty.handler.codec.http2.Http2Exception.isStreamError;
|
||||
import static io.netty.handler.codec.http2.Http2FrameTypes.SETTINGS;
|
||||
import static io.netty.handler.codec.http2.Http2Stream.State.IDLE;
|
||||
import static io.netty.util.CharsetUtil.UTF_8;
|
||||
import static io.netty.util.internal.ObjectUtil.checkNotNull;
|
||||
import static java.lang.Math.min;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
import static java.util.concurrent.TimeUnit.MILLISECONDS;
|
||||
|
||||
/**
|
||||
@ -82,9 +82,9 @@ public class Http2ConnectionHandler extends ByteToMessageDecoder implements Http
|
||||
|
||||
protected Http2ConnectionHandler(Http2ConnectionDecoder decoder, Http2ConnectionEncoder encoder,
|
||||
Http2Settings initialSettings) {
|
||||
this.initialSettings = checkNotNull(initialSettings, "initialSettings");
|
||||
this.decoder = checkNotNull(decoder, "decoder");
|
||||
this.encoder = checkNotNull(encoder, "encoder");
|
||||
this.initialSettings = requireNonNull(initialSettings, "initialSettings");
|
||||
this.decoder = requireNonNull(decoder, "decoder");
|
||||
this.encoder = requireNonNull(encoder, "encoder");
|
||||
if (encoder.connection() != decoder.connection()) {
|
||||
throw new IllegalArgumentException("Encoder and Decoder do not share the same connection object");
|
||||
}
|
||||
@ -92,7 +92,7 @@ public class Http2ConnectionHandler extends ByteToMessageDecoder implements Http
|
||||
|
||||
Http2ConnectionHandler(boolean server, Http2FrameWriter frameWriter, Http2FrameLogger frameLogger,
|
||||
Http2Settings initialSettings) {
|
||||
this.initialSettings = checkNotNull(initialSettings, "initialSettings");
|
||||
this.initialSettings = requireNonNull(initialSettings, "initialSettings");
|
||||
|
||||
Http2Connection connection = new DefaultHttp2Connection(server);
|
||||
|
||||
|
@ -22,7 +22,7 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import static io.netty.handler.codec.http2.Http2CodecUtil.CONNECTION_STREAM_ID;
|
||||
import static io.netty.util.internal.ObjectUtil.checkNotNull;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
/**
|
||||
* Exception thrown when an HTTP/2 error was encountered.
|
||||
@ -38,8 +38,8 @@ public class Http2Exception extends Exception {
|
||||
}
|
||||
|
||||
public Http2Exception(Http2Error error, ShutdownHint shutdownHint) {
|
||||
this.error = checkNotNull(error, "error");
|
||||
this.shutdownHint = checkNotNull(shutdownHint, "shutdownHint");
|
||||
this.error = requireNonNull(error, "error");
|
||||
this.shutdownHint = requireNonNull(shutdownHint, "shutdownHint");
|
||||
}
|
||||
|
||||
public Http2Exception(Http2Error error, String message) {
|
||||
@ -48,8 +48,8 @@ public class Http2Exception extends Exception {
|
||||
|
||||
public Http2Exception(Http2Error error, String message, ShutdownHint shutdownHint) {
|
||||
super(message);
|
||||
this.error = checkNotNull(error, "error");
|
||||
this.shutdownHint = checkNotNull(shutdownHint, "shutdownHint");
|
||||
this.error = requireNonNull(error, "error");
|
||||
this.shutdownHint = requireNonNull(shutdownHint, "shutdownHint");
|
||||
}
|
||||
|
||||
public Http2Exception(Http2Error error, String message, Throwable cause) {
|
||||
@ -58,8 +58,8 @@ public class Http2Exception extends Exception {
|
||||
|
||||
public Http2Exception(Http2Error error, String message, Throwable cause, ShutdownHint shutdownHint) {
|
||||
super(message, cause);
|
||||
this.error = checkNotNull(error, "error");
|
||||
this.shutdownHint = checkNotNull(shutdownHint, "shutdownHint");
|
||||
this.error = requireNonNull(error, "error");
|
||||
this.shutdownHint = requireNonNull(shutdownHint, "shutdownHint");
|
||||
}
|
||||
|
||||
public Http2Error error() {
|
||||
|
@ -18,7 +18,7 @@ package io.netty.handler.codec.http2;
|
||||
|
||||
import io.netty.util.internal.UnstableApi;
|
||||
|
||||
import static io.netty.util.internal.ObjectUtil.checkNotNull;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
/**
|
||||
* Builder for the {@link Http2FrameCodec}.
|
||||
@ -49,7 +49,7 @@ public class Http2FrameCodecBuilder extends
|
||||
|
||||
// For testing only.
|
||||
Http2FrameCodecBuilder frameWriter(Http2FrameWriter frameWriter) {
|
||||
this.frameWriter = checkNotNull(frameWriter, "frameWriter");
|
||||
this.frameWriter = requireNonNull(frameWriter, "frameWriter");
|
||||
return this;
|
||||
}
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user