Java 8 migration: Use diamond operator (#8749)
Motivation: We can use the diamond operator these days. Modification: Use diamond operator whenever possible. Result: More modern code and less boiler-plate.
This commit is contained in:
parent
5fb515f4af
commit
9d62deeb6f
@ -637,7 +637,7 @@ public class CompositeByteBuf extends AbstractReferenceCountedByteBuf implements
|
||||
return Collections.singletonList(slice);
|
||||
}
|
||||
|
||||
List<ByteBuf> sliceList = new ArrayList<ByteBuf>(componentCount - componentId);
|
||||
List<ByteBuf> sliceList = new ArrayList<>(componentCount - componentId);
|
||||
sliceList.add(slice);
|
||||
|
||||
// Add all the slices until there is nothing more left and then return the List.
|
||||
|
@ -128,7 +128,7 @@ abstract class PoolArena<T> implements PoolArenaMetric {
|
||||
}
|
||||
|
||||
private PoolSubpage<T> newSubpagePoolHead(int pageSize) {
|
||||
PoolSubpage<T> head = new PoolSubpage<T>(pageSize);
|
||||
PoolSubpage<T> head = new PoolSubpage<>(pageSize);
|
||||
head.prev = head;
|
||||
head.next = head;
|
||||
return head;
|
||||
|
@ -173,7 +173,7 @@ final class PoolChunk<T> implements PoolChunkMetric {
|
||||
}
|
||||
|
||||
subpages = newSubpageArray(maxSubpageAllocs);
|
||||
cachedNioBuffers = new ArrayDeque<ByteBuffer>(8);
|
||||
cachedNioBuffers = new ArrayDeque<>(8);
|
||||
}
|
||||
|
||||
/** Creates a special chunk that is not pooled. */
|
||||
@ -355,7 +355,7 @@ final class PoolChunk<T> implements PoolChunkMetric {
|
||||
int subpageIdx = subpageIdx(id);
|
||||
PoolSubpage<T> subpage = subpages[subpageIdx];
|
||||
if (subpage == null) {
|
||||
subpage = new PoolSubpage<T>(head, this, id, runOffset(id), pageSize, normCapacity);
|
||||
subpage = new PoolSubpage<>(head, this, id, runOffset(id), pageSize, normCapacity);
|
||||
subpages[subpageIdx] = subpage;
|
||||
} else {
|
||||
subpage.init(head, normCapacity);
|
||||
|
@ -192,7 +192,7 @@ final class PoolChunkList<T> implements PoolChunkListMetric {
|
||||
if (head == null) {
|
||||
return EMPTY_METRICS;
|
||||
}
|
||||
List<PoolChunkMetric> metrics = new ArrayList<PoolChunkMetric>();
|
||||
List<PoolChunkMetric> metrics = new ArrayList<>();
|
||||
for (PoolChunk<T> cur = head;;) {
|
||||
metrics.add(cur);
|
||||
cur = cur.next;
|
||||
|
@ -126,7 +126,7 @@ final class PoolThreadCache {
|
||||
MemoryRegionCache<T>[] cache = new MemoryRegionCache[numCaches];
|
||||
for (int i = 0; i < cache.length; i++) {
|
||||
// TODO: maybe use cacheSize / cache.length
|
||||
cache[i] = new SubPageMemoryRegionCache<T>(cacheSize, sizeClass);
|
||||
cache[i] = new SubPageMemoryRegionCache<>(cacheSize, sizeClass);
|
||||
}
|
||||
return cache;
|
||||
} else {
|
||||
@ -143,7 +143,7 @@ final class PoolThreadCache {
|
||||
@SuppressWarnings("unchecked")
|
||||
MemoryRegionCache<T>[] cache = new MemoryRegionCache[arraySize];
|
||||
for (int i = 0; i < cache.length; i++) {
|
||||
cache[i] = new NormalMemoryRegionCache<T>(cacheSize);
|
||||
cache[i] = new NormalMemoryRegionCache<>(cacheSize);
|
||||
}
|
||||
return cache;
|
||||
} else {
|
||||
|
@ -239,7 +239,7 @@ public class PooledByteBufAllocator extends AbstractByteBufAllocator implements
|
||||
|
||||
if (nHeapArena > 0) {
|
||||
heapArenas = newArenaArray(nHeapArena);
|
||||
List<PoolArenaMetric> metrics = new ArrayList<PoolArenaMetric>(heapArenas.length);
|
||||
List<PoolArenaMetric> metrics = new ArrayList<>(heapArenas.length);
|
||||
for (int i = 0; i < heapArenas.length; i ++) {
|
||||
PoolArena.HeapArena arena = new PoolArena.HeapArena(this,
|
||||
pageSize, maxOrder, pageShifts, chunkSize,
|
||||
@ -255,7 +255,7 @@ public class PooledByteBufAllocator extends AbstractByteBufAllocator implements
|
||||
|
||||
if (nDirectArena > 0) {
|
||||
directArenas = newArenaArray(nDirectArena);
|
||||
List<PoolArenaMetric> metrics = new ArrayList<PoolArenaMetric>(directArenas.length);
|
||||
List<PoolArenaMetric> metrics = new ArrayList<>(directArenas.length);
|
||||
for (int i = 0; i < directArenas.length; i ++) {
|
||||
PoolArena.DirectArena arena = new PoolArena.DirectArena(
|
||||
this, pageSize, maxOrder, pageShifts, chunkSize, directMemoryCacheAlignment);
|
||||
|
@ -2086,8 +2086,8 @@ public abstract class AbstractByteBufTest {
|
||||
buffer.writeBytes("Hello, World!".getBytes(CharsetUtil.ISO_8859_1));
|
||||
|
||||
final AtomicInteger counter = new AtomicInteger(30000);
|
||||
final AtomicReference<Throwable> errorRef = new AtomicReference<Throwable>();
|
||||
List<Thread> threads = new ArrayList<Thread>();
|
||||
final AtomicReference<Throwable> errorRef = new AtomicReference<>();
|
||||
List<Thread> threads = new ArrayList<>();
|
||||
for (int i = 0; i < 10; i++) {
|
||||
Thread thread = new Thread(new Runnable() {
|
||||
@Override
|
||||
@ -2202,7 +2202,7 @@ public abstract class AbstractByteBufTest {
|
||||
elemA.writeBytes(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5 });
|
||||
elemB.writeBytes(new byte[] { 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 9 });
|
||||
|
||||
Set<ByteBuf> set = new HashSet<ByteBuf>();
|
||||
Set<ByteBuf> set = new HashSet<>();
|
||||
set.add(elemA);
|
||||
set.add(elemB);
|
||||
|
||||
@ -2465,7 +2465,7 @@ public abstract class AbstractByteBufTest {
|
||||
|
||||
final ByteBuf buffer = newBuffer(8);
|
||||
buffer.writeBytes(bytes);
|
||||
final AtomicReference<Throwable> cause = new AtomicReference<Throwable>();
|
||||
final AtomicReference<Throwable> cause = new AtomicReference<>();
|
||||
final CountDownLatch latch = new CountDownLatch(60000);
|
||||
final CyclicBarrier barrier = new CyclicBarrier(11);
|
||||
for (int i = 0; i < 10; i++) {
|
||||
|
@ -67,7 +67,7 @@ public abstract class AbstractCompositeByteBufTest extends AbstractByteBufTest {
|
||||
protected ByteBuf newBuffer(int length, int maxCapacity) {
|
||||
Assume.assumeTrue(maxCapacity == Integer.MAX_VALUE);
|
||||
|
||||
List<ByteBuf> buffers = new ArrayList<ByteBuf>();
|
||||
List<ByteBuf> buffers = new ArrayList<>();
|
||||
for (int i = 0; i < length + 45; i += 45) {
|
||||
buffers.add(EMPTY_BUFFER);
|
||||
buffers.add(wrappedBuffer(new byte[1]));
|
||||
@ -659,7 +659,7 @@ public abstract class AbstractCompositeByteBufTest extends AbstractByteBufTest {
|
||||
CompositeByteBuf buf = compositeBuffer();
|
||||
assertThat(buf.refCnt(), is(1));
|
||||
|
||||
List<ByteBuf> components = new ArrayList<ByteBuf>();
|
||||
List<ByteBuf> components = new ArrayList<>();
|
||||
Collections.addAll(components, c1, c2, c3);
|
||||
buf.addComponents(components);
|
||||
|
||||
|
@ -677,8 +677,8 @@ public class ByteBufUtilTest {
|
||||
|
||||
try {
|
||||
final AtomicInteger counter = new AtomicInteger(60000);
|
||||
final AtomicReference<Throwable> errorRef = new AtomicReference<Throwable>();
|
||||
List<Thread> threads = new ArrayList<Thread>();
|
||||
final AtomicReference<Throwable> errorRef = new AtomicReference<>();
|
||||
List<Thread> threads = new ArrayList<>();
|
||||
for (int i = 0; i < 10; i++) {
|
||||
Thread thread = new Thread(new Runnable() {
|
||||
@Override
|
||||
|
@ -416,7 +416,7 @@ public class PooledByteBufAllocatorTest extends AbstractByteBufAllocatorTest<Poo
|
||||
// We use no caches and only one arena to maximize the chance of hitting the race-condition we
|
||||
// had before.
|
||||
ByteBufAllocator allocator = new PooledByteBufAllocator(true, 1, 1, 8192, 11, 0, 0, 0);
|
||||
List<AllocationThread> threads = new ArrayList<AllocationThread>();
|
||||
List<AllocationThread> threads = new ArrayList<>();
|
||||
try {
|
||||
for (int i = 0; i < 512; i++) {
|
||||
AllocationThread thread = new AllocationThread(allocator);
|
||||
@ -457,9 +457,9 @@ public class PooledByteBufAllocatorTest extends AbstractByteBufAllocatorTest<Poo
|
||||
}
|
||||
}
|
||||
|
||||
private final Queue<ByteBuf> buffers = new ConcurrentLinkedQueue<ByteBuf>();
|
||||
private final Queue<ByteBuf> buffers = new ConcurrentLinkedQueue<>();
|
||||
private final ByteBufAllocator allocator;
|
||||
private final AtomicReference<Object> finish = new AtomicReference<Object>();
|
||||
private final AtomicReference<Object> finish = new AtomicReference<>();
|
||||
|
||||
public AllocationThread(ByteBufAllocator allocator) {
|
||||
this.allocator = allocator;
|
||||
|
@ -28,7 +28,7 @@ import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class SimpleLeakAwareByteBufTest extends BigEndianHeapByteBufTest {
|
||||
private final Class<? extends ByteBuf> clazz = leakClass();
|
||||
private final Queue<NoopResourceLeakTracker<ByteBuf>> trackers = new ArrayDeque<NoopResourceLeakTracker<ByteBuf>>();
|
||||
private final Queue<NoopResourceLeakTracker<ByteBuf>> trackers = new ArrayDeque<>();
|
||||
|
||||
@Override
|
||||
protected final ByteBuf newBuffer(int capacity, int maxCapacity) {
|
||||
@ -36,7 +36,7 @@ public class SimpleLeakAwareByteBufTest extends BigEndianHeapByteBufTest {
|
||||
}
|
||||
|
||||
private ByteBuf wrap(ByteBuf buffer) {
|
||||
NoopResourceLeakTracker<ByteBuf> tracker = new NoopResourceLeakTracker<ByteBuf>();
|
||||
NoopResourceLeakTracker<ByteBuf> tracker = new NoopResourceLeakTracker<>();
|
||||
ByteBuf leakAwareBuf = wrap(buffer, tracker);
|
||||
trackers.add(tracker);
|
||||
return leakAwareBuf;
|
||||
|
@ -29,11 +29,11 @@ import static org.junit.Assert.assertTrue;
|
||||
public class SimpleLeakAwareCompositeByteBufTest extends WrappedCompositeByteBufTest {
|
||||
|
||||
private final Class<? extends ByteBuf> clazz = leakClass();
|
||||
private final Queue<NoopResourceLeakTracker<ByteBuf>> trackers = new ArrayDeque<NoopResourceLeakTracker<ByteBuf>>();
|
||||
private final Queue<NoopResourceLeakTracker<ByteBuf>> trackers = new ArrayDeque<>();
|
||||
|
||||
@Override
|
||||
protected final WrappedCompositeByteBuf wrap(CompositeByteBuf buffer) {
|
||||
NoopResourceLeakTracker<ByteBuf> tracker = new NoopResourceLeakTracker<ByteBuf>();
|
||||
NoopResourceLeakTracker<ByteBuf> tracker = new NoopResourceLeakTracker<>();
|
||||
WrappedCompositeByteBuf leakAwareBuf = wrap(buffer, tracker);
|
||||
trackers.add(tracker);
|
||||
return leakAwareBuf;
|
||||
|
@ -60,7 +60,7 @@ public class UnpooledTest {
|
||||
|
||||
@Test
|
||||
public void testHashCode() {
|
||||
Map<byte[], Integer> map = new LinkedHashMap<byte[], Integer>();
|
||||
Map<byte[], Integer> map = new LinkedHashMap<>();
|
||||
map.put(EMPTY_BYTES, 1);
|
||||
map.put(new byte[] { 1 }, 32);
|
||||
map.put(new byte[] { 2 }, 33);
|
||||
@ -149,7 +149,7 @@ public class UnpooledTest {
|
||||
|
||||
@Test
|
||||
public void testCompare() {
|
||||
List<ByteBuf> expected = new ArrayList<ByteBuf>();
|
||||
List<ByteBuf> expected = new ArrayList<>();
|
||||
expected.add(wrappedBuffer(new byte[]{1}));
|
||||
expected.add(wrappedBuffer(new byte[]{1, 2}));
|
||||
expected.add(wrappedBuffer(new byte[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}));
|
||||
|
@ -469,6 +469,6 @@ public abstract class AbstractDnsMessage extends AbstractReferenceCounted implem
|
||||
}
|
||||
|
||||
private static ArrayList<DnsRecord> newRecordList() {
|
||||
return new ArrayList<DnsRecord>(2);
|
||||
return new ArrayList<>(2);
|
||||
}
|
||||
}
|
||||
|
@ -303,7 +303,7 @@ public class DnsRecordType implements Comparable<DnsRecordType> {
|
||||
*/
|
||||
public static final DnsRecordType DLV = new DnsRecordType(0x8001, "DLV");
|
||||
|
||||
private static final Map<String, DnsRecordType> BY_NAME = new HashMap<String, DnsRecordType>();
|
||||
private static final Map<String, DnsRecordType> BY_NAME = new HashMap<>();
|
||||
private static final IntObjectHashMap<DnsRecordType> BY_TYPE = new IntObjectHashMap<DnsRecordType>();
|
||||
private static final String EXPECTED;
|
||||
|
||||
|
@ -35,7 +35,7 @@ public class DnsQueryTest {
|
||||
public void writeQueryTest() throws Exception {
|
||||
InetSocketAddress addr = SocketUtils.socketAddress("8.8.8.8", 53);
|
||||
EmbeddedChannel embedder = new EmbeddedChannel(new DatagramDnsQueryEncoder());
|
||||
List<DnsQuery> queries = new ArrayList<DnsQuery>(5);
|
||||
List<DnsQuery> queries = new ArrayList<>(5);
|
||||
queries.add(new DatagramDnsQuery(null, addr, 1).setRecord(
|
||||
DnsSection.QUESTION,
|
||||
new DefaultDnsQuestion("1.0.0.127.in-addr.arpa", DnsRecordType.PTR)));
|
||||
|
@ -28,7 +28,7 @@ import static org.junit.Assert.*;
|
||||
public class DnsRecordTypeTest {
|
||||
|
||||
private static List<DnsRecordType> allTypes() throws Exception {
|
||||
List<DnsRecordType> result = new ArrayList<DnsRecordType>();
|
||||
List<DnsRecordType> result = new ArrayList<>();
|
||||
for (Field field : DnsRecordType.class.getFields()) {
|
||||
if ((field.getModifiers() & Modifier.STATIC) != 0 && field.getType() == DnsRecordType.class) {
|
||||
result.add((DnsRecordType) field.get(null));
|
||||
@ -41,7 +41,7 @@ public class DnsRecordTypeTest {
|
||||
@Test
|
||||
public void testSanity() throws Exception {
|
||||
assertEquals("More than one type has the same int value",
|
||||
allTypes().size(), new HashSet<DnsRecordType>(allTypes()).size());
|
||||
allTypes().size(), new HashSet<>(allTypes()).size());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -243,7 +243,7 @@ public final class HAProxyMessage {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
// In most cases there are less than 4 TLVs available
|
||||
List<HAProxyTLV> haProxyTLVs = new ArrayList<HAProxyTLV>(4);
|
||||
List<HAProxyTLV> haProxyTLVs = new ArrayList<>(4);
|
||||
|
||||
do {
|
||||
haProxyTLVs.add(haProxyTLV);
|
||||
@ -274,7 +274,7 @@ public final class HAProxyMessage {
|
||||
|
||||
if (byteBuf.readableBytes() >= 4) {
|
||||
|
||||
final List<HAProxyTLV> encapsulatedTlvs = new ArrayList<HAProxyTLV>(4);
|
||||
final List<HAProxyTLV> encapsulatedTlvs = new ArrayList<>(4);
|
||||
do {
|
||||
final HAProxyTLV haProxyTLV = readNextTLV(byteBuf);
|
||||
if (haProxyTLV == null) {
|
||||
|
@ -82,8 +82,8 @@ public final class CookieDecoder {
|
||||
* @return the decoded {@link Cookie}s
|
||||
*/
|
||||
private Set<Cookie> doDecode(String header) {
|
||||
List<String> names = new ArrayList<String>(8);
|
||||
List<String> values = new ArrayList<String>(8);
|
||||
List<String> names = new ArrayList<>(8);
|
||||
List<String> values = new ArrayList<>(8);
|
||||
extractKeyValuePairs(header, names, values);
|
||||
|
||||
if (names.isEmpty()) {
|
||||
@ -111,7 +111,7 @@ public final class CookieDecoder {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
Set<Cookie> cookies = new TreeSet<Cookie>();
|
||||
Set<Cookie> cookies = new TreeSet<>();
|
||||
for (; i < names.size(); i ++) {
|
||||
String name = names.get(i);
|
||||
String value = values.get(i);
|
||||
@ -133,7 +133,7 @@ public final class CookieDecoder {
|
||||
String domain = null;
|
||||
String path = null;
|
||||
long maxAge = Long.MIN_VALUE;
|
||||
List<Integer> ports = new ArrayList<Integer>(2);
|
||||
List<Integer> ports = new ArrayList<>(2);
|
||||
|
||||
for (int j = i + 1; j < names.size(); j++, i++) {
|
||||
name = names.get(j);
|
||||
|
@ -139,7 +139,7 @@ public class DefaultCookie extends io.netty.handler.codec.http.cookie.DefaultCoo
|
||||
if (portsCopy.length == 0) {
|
||||
unmodifiablePorts = this.ports = Collections.emptySet();
|
||||
} else {
|
||||
Set<Integer> newPorts = new TreeSet<Integer>();
|
||||
Set<Integer> newPorts = new TreeSet<>();
|
||||
for (int p: portsCopy) {
|
||||
if (p <= 0 || p > 65535) {
|
||||
throw new IllegalArgumentException("port out of range: " + p);
|
||||
@ -154,7 +154,7 @@ public class DefaultCookie extends io.netty.handler.codec.http.cookie.DefaultCoo
|
||||
@Override
|
||||
@Deprecated
|
||||
public void setPorts(Iterable<Integer> ports) {
|
||||
Set<Integer> newPorts = new TreeSet<Integer>();
|
||||
Set<Integer> newPorts = new TreeSet<>();
|
||||
for (int p: ports) {
|
||||
if (p <= 0 || p > 65535) {
|
||||
throw new IllegalArgumentException("port out of range: " + p);
|
||||
|
@ -83,9 +83,9 @@ public class DefaultHttpHeaders extends HttpHeaders {
|
||||
}
|
||||
|
||||
protected DefaultHttpHeaders(boolean validate, NameValidator<CharSequence> nameValidator) {
|
||||
this(new DefaultHeadersImpl<CharSequence, CharSequence>(CASE_INSENSITIVE_HASHER,
|
||||
valueConverter(validate),
|
||||
nameValidator));
|
||||
this(new DefaultHeadersImpl<>(CASE_INSENSITIVE_HASHER,
|
||||
valueConverter(validate),
|
||||
nameValidator));
|
||||
}
|
||||
|
||||
protected DefaultHttpHeaders(DefaultHeaders<CharSequence, CharSequence, ?> headers) {
|
||||
@ -257,7 +257,7 @@ public class DefaultHttpHeaders extends HttpHeaders {
|
||||
if (isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
List<Entry<String, String>> entriesConverted = new ArrayList<Entry<String, String>>(
|
||||
List<Entry<String, String>> entriesConverted = new ArrayList<>(
|
||||
headers.size());
|
||||
for (Entry<String, String> entry : this) {
|
||||
entriesConverted.add(entry);
|
||||
|
@ -46,7 +46,7 @@ public final class HttpClientCodec extends CombinedChannelDuplexHandler<HttpResp
|
||||
implements HttpClientUpgradeHandler.SourceCodec {
|
||||
|
||||
/** A queue that is used for correlating a request and a response. */
|
||||
private final Queue<HttpMethod> queue = new ArrayDeque<HttpMethod>();
|
||||
private final Queue<HttpMethod> queue = new ArrayDeque<>();
|
||||
private final boolean parseHttpAfterConnectRequest;
|
||||
|
||||
/** If true, decoding stops (i.e. pass-through) */
|
||||
|
@ -272,7 +272,7 @@ public class HttpClientUpgradeHandler extends HttpObjectAggregator implements Ch
|
||||
request.headers().set(HttpHeaderNames.UPGRADE, upgradeCodec.protocol());
|
||||
|
||||
// Add all protocol-specific headers to the request.
|
||||
Set<CharSequence> connectionParts = new LinkedHashSet<CharSequence>(2);
|
||||
Set<CharSequence> connectionParts = new LinkedHashSet<>(2);
|
||||
connectionParts.addAll(upgradeCodec.setUpgradeHeaders(ctx, request));
|
||||
|
||||
// Set the CONNECTION header from the set of all protocol-specific headers that were added.
|
||||
|
@ -61,7 +61,7 @@ public abstract class HttpContentEncoder extends MessageToMessageCodec<HttpReque
|
||||
private static final CharSequence ZERO_LENGTH_CONNECT = "CONNECT";
|
||||
private static final int CONTINUE_CODE = HttpResponseStatus.CONTINUE.code();
|
||||
|
||||
private final Queue<CharSequence> acceptEncodingQueue = new ArrayDeque<CharSequence>();
|
||||
private final Queue<CharSequence> acceptEncodingQueue = new ArrayDeque<>();
|
||||
private EmbeddedChannel encoder;
|
||||
private State state = State.AWAIT_HEADERS;
|
||||
|
||||
|
@ -88,16 +88,16 @@ public class HttpMethod implements Comparable<HttpMethod> {
|
||||
private static final EnumNameMap<HttpMethod> methodMap;
|
||||
|
||||
static {
|
||||
methodMap = new EnumNameMap<HttpMethod>(
|
||||
new EnumNameMap.Node<HttpMethod>(OPTIONS.toString(), OPTIONS),
|
||||
new EnumNameMap.Node<HttpMethod>(GET.toString(), GET),
|
||||
new EnumNameMap.Node<HttpMethod>(HEAD.toString(), HEAD),
|
||||
new EnumNameMap.Node<HttpMethod>(POST.toString(), POST),
|
||||
new EnumNameMap.Node<HttpMethod>(PUT.toString(), PUT),
|
||||
new EnumNameMap.Node<HttpMethod>(PATCH.toString(), PATCH),
|
||||
new EnumNameMap.Node<HttpMethod>(DELETE.toString(), DELETE),
|
||||
new EnumNameMap.Node<HttpMethod>(TRACE.toString(), TRACE),
|
||||
new EnumNameMap.Node<HttpMethod>(CONNECT.toString(), CONNECT));
|
||||
methodMap = new EnumNameMap<>(
|
||||
new EnumNameMap.Node<>(OPTIONS.toString(), OPTIONS),
|
||||
new EnumNameMap.Node<>(GET.toString(), GET),
|
||||
new EnumNameMap.Node<>(HEAD.toString(), HEAD),
|
||||
new EnumNameMap.Node<>(POST.toString(), POST),
|
||||
new EnumNameMap.Node<>(PUT.toString(), PUT),
|
||||
new EnumNameMap.Node<>(PATCH.toString(), PATCH),
|
||||
new EnumNameMap.Node<>(DELETE.toString(), DELETE),
|
||||
new EnumNameMap.Node<>(TRACE.toString(), TRACE),
|
||||
new EnumNameMap.Node<>(CONNECT.toString(), CONNECT));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -33,7 +33,7 @@ public final class HttpServerCodec extends CombinedChannelDuplexHandler<HttpRequ
|
||||
implements HttpServerUpgradeHandler.SourceCodec {
|
||||
|
||||
/** A queue that is used for correlating a request and a response. */
|
||||
private final Queue<HttpMethod> queue = new ArrayDeque<HttpMethod>();
|
||||
private final Queue<HttpMethod> queue = new ArrayDeque<>();
|
||||
|
||||
/**
|
||||
* Creates a new instance with the default decoder options
|
||||
|
@ -359,7 +359,7 @@ public class HttpServerUpgradeHandler extends HttpObjectAggregator {
|
||||
*/
|
||||
private static List<CharSequence> splitHeader(CharSequence header) {
|
||||
final StringBuilder builder = new StringBuilder(header.length());
|
||||
final List<CharSequence> protocols = new ArrayList<CharSequence>(4);
|
||||
final List<CharSequence> protocols = new ArrayList<>(4);
|
||||
for (int i = 0; i < header.length(); ++i) {
|
||||
char c = header.charAt(i);
|
||||
if (Character.isWhitespace(c)) {
|
||||
|
@ -325,7 +325,7 @@ public final class HttpUtil {
|
||||
if (encodings.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
List<CharSequence> values = new ArrayList<CharSequence>(encodings);
|
||||
List<CharSequence> values = new ArrayList<>(encodings);
|
||||
Iterator<CharSequence> valuesIt = values.iterator();
|
||||
while (valuesIt.hasNext()) {
|
||||
CharSequence value = valuesIt.next();
|
||||
|
@ -212,7 +212,7 @@ public class QueryStringDecoder {
|
||||
if (s.charAt(from) == '?') {
|
||||
from++;
|
||||
}
|
||||
Map<String, List<String>> params = new LinkedHashMap<String, List<String>>();
|
||||
Map<String, List<String>> params = new LinkedHashMap<>();
|
||||
int nameStart = from;
|
||||
int valueStart = -1;
|
||||
int i;
|
||||
@ -258,7 +258,7 @@ public class QueryStringDecoder {
|
||||
String value = decodeComponent(s, valueStart, valueEnd, charset, false);
|
||||
List<String> values = params.get(name);
|
||||
if (values == null) {
|
||||
values = new ArrayList<String>(1); // Often there's only 1 value.
|
||||
values = new ArrayList<>(1); // Often there's only 1 value.
|
||||
params.put(name, values);
|
||||
}
|
||||
values.add(value);
|
||||
|
@ -132,7 +132,7 @@ public final class ReadOnlyHttpHeaders extends HttpHeaders {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
final int nameHash = AsciiString.hashCode(name);
|
||||
List<String> values = new ArrayList<String>(4);
|
||||
List<String> values = new ArrayList<>(4);
|
||||
for (int i = 0; i < nameValuePairs.length; i += 2) {
|
||||
CharSequence roName = nameValuePairs[i];
|
||||
if (AsciiString.hashCode(roName) == nameHash && contentEqualsIgnoreCase(roName, name)) {
|
||||
@ -147,9 +147,9 @@ public final class ReadOnlyHttpHeaders extends HttpHeaders {
|
||||
if (isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
List<Map.Entry<String, String>> entries = new ArrayList<Map.Entry<String, String>>(size());
|
||||
List<Map.Entry<String, String>> entries = new ArrayList<>(size());
|
||||
for (int i = 0; i < nameValuePairs.length; i += 2) {
|
||||
entries.add(new SimpleImmutableEntry<String, String>(nameValuePairs[i].toString(),
|
||||
entries.add(new SimpleImmutableEntry<>(nameValuePairs[i].toString(),
|
||||
nameValuePairs[i + 1].toString()));
|
||||
}
|
||||
return entries;
|
||||
@ -220,7 +220,7 @@ public final class ReadOnlyHttpHeaders extends HttpHeaders {
|
||||
if (isEmpty()) {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
Set<String> names = new LinkedHashSet<String>(size());
|
||||
Set<String> names = new LinkedHashSet<>(size());
|
||||
for (int i = 0; i < nameValuePairs.length; i += 2) {
|
||||
names.add(nameValuePairs[i].toString());
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ public final class ServerCookieDecoder extends CookieDecoder {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
Set<Cookie> cookies = new TreeSet<Cookie>();
|
||||
Set<Cookie> cookies = new TreeSet<>();
|
||||
|
||||
int i = 0;
|
||||
|
||||
|
@ -139,7 +139,7 @@ public final class ServerCookieEncoder extends CookieEncoder {
|
||||
for (int idx : nameToLastIndex.values()) {
|
||||
isLastInstance[idx] = true;
|
||||
}
|
||||
List<String> dedupd = new ArrayList<String>(nameToLastIndex.size());
|
||||
List<String> dedupd = new ArrayList<>(nameToLastIndex.size());
|
||||
for (int i = 0, n = encoded.size(); i < n; i++) {
|
||||
if (isLastInstance[i]) {
|
||||
dedupd.add(encoded.get(i));
|
||||
@ -159,8 +159,8 @@ public final class ServerCookieEncoder extends CookieEncoder {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
List<String> encoded = new ArrayList<String>(cookies.length);
|
||||
Map<String, Integer> nameToIndex = strict && cookies.length > 1 ? new HashMap<String, Integer>() : null;
|
||||
List<String> encoded = new ArrayList<>(cookies.length);
|
||||
Map<String, Integer> nameToIndex = strict && cookies.length > 1 ? new HashMap<>() : null;
|
||||
boolean hasDupdName = false;
|
||||
for (int i = 0; i < cookies.length; i++) {
|
||||
Cookie c = cookies[i];
|
||||
@ -183,8 +183,8 @@ public final class ServerCookieEncoder extends CookieEncoder {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
List<String> encoded = new ArrayList<String>(cookies.size());
|
||||
Map<String, Integer> nameToIndex = strict && cookies.size() > 1 ? new HashMap<String, Integer>() : null;
|
||||
List<String> encoded = new ArrayList<>(cookies.size());
|
||||
Map<String, Integer> nameToIndex = strict && cookies.size() > 1 ? new HashMap<>() : null;
|
||||
int i = 0;
|
||||
boolean hasDupdName = false;
|
||||
for (Cookie c : cookies) {
|
||||
@ -208,9 +208,9 @@ public final class ServerCookieEncoder extends CookieEncoder {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
List<String> encoded = new ArrayList<String>();
|
||||
List<String> encoded = new ArrayList<>();
|
||||
Cookie firstCookie = cookiesIt.next();
|
||||
Map<String, Integer> nameToIndex = strict && cookiesIt.hasNext() ? new HashMap<String, Integer>() : null;
|
||||
Map<String, Integer> nameToIndex = strict && cookiesIt.hasNext() ? new HashMap<>() : null;
|
||||
int i = 0;
|
||||
encoded.add(encode(firstCookie));
|
||||
boolean hasDupdName = nameToIndex != null && nameToIndex.put(firstCookie.name(), i++) != null;
|
||||
|
@ -47,7 +47,7 @@ public final class CorsConfig {
|
||||
private final boolean shortCircuit;
|
||||
|
||||
CorsConfig(final CorsConfigBuilder builder) {
|
||||
origins = new LinkedHashSet<String>(builder.origins);
|
||||
origins = new LinkedHashSet<>(builder.origins);
|
||||
anyOrigin = builder.anyOrigin;
|
||||
enabled = builder.enabled;
|
||||
exposeHeaders = builder.exposeHeaders;
|
||||
|
@ -68,11 +68,11 @@ public final class CorsConfigBuilder {
|
||||
boolean allowNullOrigin;
|
||||
boolean enabled = true;
|
||||
boolean allowCredentials;
|
||||
final Set<String> exposeHeaders = new HashSet<String>();
|
||||
final Set<String> exposeHeaders = new HashSet<>();
|
||||
long maxAge;
|
||||
final Set<HttpMethod> requestMethods = new HashSet<HttpMethod>();
|
||||
final Set<String> requestHeaders = new HashSet<String>();
|
||||
final Map<CharSequence, Callable<?>> preflightHeaders = new HashMap<CharSequence, Callable<?>>();
|
||||
final Set<HttpMethod> requestMethods = new HashSet<>();
|
||||
final Set<String> requestHeaders = new HashSet<>();
|
||||
final Map<CharSequence, Callable<?>> preflightHeaders = new HashMap<>();
|
||||
private boolean noPreflightHeaders;
|
||||
boolean shortCircuit;
|
||||
|
||||
@ -82,7 +82,7 @@ public final class CorsConfigBuilder {
|
||||
* @param origins the origin to be used for this builder.
|
||||
*/
|
||||
CorsConfigBuilder(final String... origins) {
|
||||
this.origins = new LinkedHashSet<String>(Arrays.asList(origins));
|
||||
this.origins = new LinkedHashSet<>(Arrays.asList(origins));
|
||||
anyOrigin = false;
|
||||
}
|
||||
|
||||
|
@ -67,7 +67,7 @@ public class DefaultHttpDataFactory implements HttpDataFactory {
|
||||
* different data items may be equal.
|
||||
*/
|
||||
private final Map<HttpRequest, List<HttpData>> requestFileDeleteMap =
|
||||
Collections.synchronizedMap(new IdentityHashMap<HttpRequest, List<HttpData>>());
|
||||
Collections.synchronizedMap(new IdentityHashMap<>());
|
||||
|
||||
/**
|
||||
* HttpData will be in memory if less than default size (16KB).
|
||||
@ -122,7 +122,7 @@ public class DefaultHttpDataFactory implements HttpDataFactory {
|
||||
private List<HttpData> getList(HttpRequest request) {
|
||||
List<HttpData> list = requestFileDeleteMap.get(request);
|
||||
if (list == null) {
|
||||
list = new ArrayList<HttpData>();
|
||||
list = new ArrayList<>();
|
||||
requestFileDeleteMap.put(request, list);
|
||||
}
|
||||
return list;
|
||||
|
@ -79,12 +79,12 @@ public class HttpPostMultipartRequestDecoder implements InterfaceHttpPostRequest
|
||||
/**
|
||||
* HttpDatas from Body
|
||||
*/
|
||||
private final List<InterfaceHttpData> bodyListHttpData = new ArrayList<InterfaceHttpData>();
|
||||
private final List<InterfaceHttpData> bodyListHttpData = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* HttpDatas as Map from Body
|
||||
*/
|
||||
private final Map<String, List<InterfaceHttpData>> bodyMapHttpData = new TreeMap<String, List<InterfaceHttpData>>(
|
||||
private final Map<String, List<InterfaceHttpData>> bodyMapHttpData = new TreeMap<>(
|
||||
CaseIgnoringComparator.INSTANCE);
|
||||
|
||||
/**
|
||||
@ -424,7 +424,7 @@ public class HttpPostMultipartRequestDecoder implements InterfaceHttpPostRequest
|
||||
}
|
||||
List<InterfaceHttpData> datas = bodyMapHttpData.get(data.getName());
|
||||
if (datas == null) {
|
||||
datas = new ArrayList<InterfaceHttpData>(1);
|
||||
datas = new ArrayList<>(1);
|
||||
bodyMapHttpData.put(data.getName(), datas);
|
||||
}
|
||||
datas.add(data);
|
||||
@ -669,7 +669,7 @@ public class HttpPostMultipartRequestDecoder implements InterfaceHttpPostRequest
|
||||
private InterfaceHttpData findMultipartDisposition() {
|
||||
int readerIndex = undecodedChunk.readerIndex();
|
||||
if (currentStatus == MultiPartStatus.DISPOSITION) {
|
||||
currentFieldAttributes = new TreeMap<CharSequence, Attribute>(CaseIgnoringComparator.INSTANCE);
|
||||
currentFieldAttributes = new TreeMap<>(CaseIgnoringComparator.INSTANCE);
|
||||
}
|
||||
// read many lines until empty line with newline found! Store all data
|
||||
while (!skipOneLine()) {
|
||||
@ -1453,7 +1453,7 @@ public class HttpPostMultipartRequestDecoder implements InterfaceHttpPostRequest
|
||||
* follows by several values that were separated by ';' or ','
|
||||
*/
|
||||
private static String[] splitMultipartHeader(String sb) {
|
||||
ArrayList<String> headers = new ArrayList<String>(1);
|
||||
ArrayList<String> headers = new ArrayList<>(1);
|
||||
int nameStart;
|
||||
int nameEnd;
|
||||
int colonEnd;
|
||||
|
@ -98,9 +98,9 @@ public class HttpPostRequestEncoder implements ChunkedInput<HttpContent> {
|
||||
|
||||
static {
|
||||
percentEncodings = new Map.Entry[] {
|
||||
new SimpleImmutableEntry<Pattern, String>(Pattern.compile("\\*"), "%2A"),
|
||||
new SimpleImmutableEntry<Pattern, String>(Pattern.compile("\\+"), "%20"),
|
||||
new SimpleImmutableEntry<Pattern, String>(Pattern.compile("~"), "%7E")
|
||||
new SimpleImmutableEntry<>(Pattern.compile("\\*"), "%2A"),
|
||||
new SimpleImmutableEntry<>(Pattern.compile("\\+"), "%20"),
|
||||
new SimpleImmutableEntry<>(Pattern.compile("~"), "%7E")
|
||||
};
|
||||
}
|
||||
|
||||
@ -216,12 +216,12 @@ public class HttpPostRequestEncoder implements ChunkedInput<HttpContent> {
|
||||
throw new ErrorDataEncoderException("Cannot create a Encoder if request is a TRACE");
|
||||
}
|
||||
// Fill default values
|
||||
bodyListDatas = new ArrayList<InterfaceHttpData>();
|
||||
bodyListDatas = new ArrayList<>();
|
||||
// default mode
|
||||
isLastChunk = false;
|
||||
isLastChunkSent = false;
|
||||
isMultipart = multipart;
|
||||
multipartHttpDatas = new ArrayList<InterfaceHttpData>();
|
||||
multipartHttpDatas = new ArrayList<>();
|
||||
this.encoderMode = encoderMode;
|
||||
if (isMultipart) {
|
||||
initDataMultipart();
|
||||
|
@ -68,12 +68,12 @@ public class HttpPostStandardRequestDecoder implements InterfaceHttpPostRequestD
|
||||
/**
|
||||
* HttpDatas from Body
|
||||
*/
|
||||
private final List<InterfaceHttpData> bodyListHttpData = new ArrayList<InterfaceHttpData>();
|
||||
private final List<InterfaceHttpData> bodyListHttpData = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* HttpDatas as Map from Body
|
||||
*/
|
||||
private final Map<String, List<InterfaceHttpData>> bodyMapHttpData = new TreeMap<String, List<InterfaceHttpData>>(
|
||||
private final Map<String, List<InterfaceHttpData>> bodyMapHttpData = new TreeMap<>(
|
||||
CaseIgnoringComparator.INSTANCE);
|
||||
|
||||
/**
|
||||
@ -369,7 +369,7 @@ public class HttpPostStandardRequestDecoder implements InterfaceHttpPostRequestD
|
||||
}
|
||||
List<InterfaceHttpData> datas = bodyMapHttpData.get(data.getName());
|
||||
if (datas == null) {
|
||||
datas = new ArrayList<InterfaceHttpData>(1);
|
||||
datas = new ArrayList<>(1);
|
||||
bodyMapHttpData.put(data.getName(), datas);
|
||||
}
|
||||
datas.add(data);
|
||||
|
@ -28,7 +28,7 @@ import java.util.List;
|
||||
* (like Multipart Mixed mode)
|
||||
*/
|
||||
final class InternalAttribute extends AbstractReferenceCounted implements InterfaceHttpData {
|
||||
private final List<ByteBuf> value = new ArrayList<ByteBuf>();
|
||||
private final List<ByteBuf> value = new ArrayList<>();
|
||||
private final Charset charset;
|
||||
private int size;
|
||||
|
||||
|
@ -106,7 +106,7 @@ public abstract class WebSocketServerHandshaker {
|
||||
* Returns the CSV of supported sub protocols
|
||||
*/
|
||||
public Set<String> subprotocols() {
|
||||
Set<String> ret = new LinkedHashSet<String>();
|
||||
Set<String> ret = new LinkedHashSet<>();
|
||||
Collections.addAll(ret, subprotocols);
|
||||
return ret;
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ public class WebSocketClientExtensionHandler extends ChannelDuplexHandler {
|
||||
List<WebSocketExtensionData> extensions =
|
||||
WebSocketExtensionUtil.extractExtensions(extensionsHeader);
|
||||
List<WebSocketClientExtension> validExtensions =
|
||||
new ArrayList<WebSocketClientExtension>(extensions.size());
|
||||
new ArrayList<>(extensions.size());
|
||||
int rsv = 0;
|
||||
|
||||
for (WebSocketExtensionData extensionData : extensions) {
|
||||
|
@ -44,13 +44,13 @@ public final class WebSocketExtensionUtil {
|
||||
public static List<WebSocketExtensionData> extractExtensions(String extensionHeader) {
|
||||
String[] rawExtensions = extensionHeader.split(EXTENSION_SEPARATOR);
|
||||
if (rawExtensions.length > 0) {
|
||||
List<WebSocketExtensionData> extensions = new ArrayList<WebSocketExtensionData>(rawExtensions.length);
|
||||
List<WebSocketExtensionData> extensions = new ArrayList<>(rawExtensions.length);
|
||||
for (String rawExtension : rawExtensions) {
|
||||
String[] extensionParameters = rawExtension.split(PARAMETER_SEPARATOR);
|
||||
String name = extensionParameters[0].trim();
|
||||
Map<String, String> parameters;
|
||||
if (extensionParameters.length > 1) {
|
||||
parameters = new HashMap<String, String>(extensionParameters.length - 1);
|
||||
parameters = new HashMap<>(extensionParameters.length - 1);
|
||||
for (int i = 1; i < extensionParameters.length; i++) {
|
||||
String parameter = extensionParameters[i].trim();
|
||||
Matcher parameterMatcher = PARAMETER.matcher(parameter);
|
||||
|
@ -89,7 +89,7 @@ public class WebSocketServerExtensionHandler extends ChannelDuplexHandler {
|
||||
|
||||
if (validExtension != null && ((validExtension.rsv() & rsv) == 0)) {
|
||||
if (validExtensions == null) {
|
||||
validExtensions = new ArrayList<WebSocketServerExtension>(1);
|
||||
validExtensions = new ArrayList<>(1);
|
||||
}
|
||||
rsv = rsv | validExtension.rsv();
|
||||
validExtensions.add(validExtension);
|
||||
|
@ -85,7 +85,7 @@ public final class PerMessageDeflateClientExtensionHandshaker implements WebSock
|
||||
|
||||
@Override
|
||||
public WebSocketExtensionData newRequestData() {
|
||||
HashMap<String, String> parameters = new HashMap<String, String>(4);
|
||||
HashMap<String, String> parameters = new HashMap<>(4);
|
||||
if (requestedServerWindowSize != MAX_WINDOW_SIZE) {
|
||||
parameters.put(SERVER_NO_CONTEXT, null);
|
||||
}
|
||||
|
@ -177,7 +177,7 @@ public final class PerMessageDeflateServerExtensionHandshaker implements WebSock
|
||||
|
||||
@Override
|
||||
public WebSocketExtensionData newReponseData() {
|
||||
HashMap<String, String> parameters = new HashMap<String, String>(4);
|
||||
HashMap<String, String> parameters = new HashMap<>(4);
|
||||
if (serverNoContext) {
|
||||
parameters.put(SERVER_NO_CONTEXT, null);
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ public final class RtspMethods {
|
||||
*/
|
||||
public static final HttpMethod RECORD = new HttpMethod("RECORD");
|
||||
|
||||
private static final Map<String, HttpMethod> methodMap = new HashMap<String, HttpMethod>();
|
||||
private static final Map<String, HttpMethod> methodMap = new HashMap<>();
|
||||
|
||||
static {
|
||||
methodMap.put(DESCRIBE.toString(), DESCRIBE);
|
||||
|
@ -27,7 +27,7 @@ import java.util.TreeMap;
|
||||
public class DefaultSpdySettingsFrame implements SpdySettingsFrame {
|
||||
|
||||
private boolean clear;
|
||||
private final Map<Integer, Setting> settingsMap = new TreeMap<Integer, Setting>();
|
||||
private final Map<Integer, Setting> settingsMap = new TreeMap<>();
|
||||
|
||||
@Override
|
||||
public Set<Integer> ids() {
|
||||
|
@ -59,7 +59,7 @@ public class SpdyHttpDecoder extends MessageToMessageDecoder<SpdyFrame> {
|
||||
* a {@link TooLongFrameException} will be raised.
|
||||
*/
|
||||
public SpdyHttpDecoder(SpdyVersion version, int maxContentLength) {
|
||||
this(version, maxContentLength, new HashMap<Integer, FullHttpMessage>(), true);
|
||||
this(version, maxContentLength, new HashMap<>(), true);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -72,7 +72,7 @@ public class SpdyHttpDecoder extends MessageToMessageDecoder<SpdyFrame> {
|
||||
* @param validateHeaders {@code true} if http headers should be validated
|
||||
*/
|
||||
public SpdyHttpDecoder(SpdyVersion version, int maxContentLength, boolean validateHeaders) {
|
||||
this(version, maxContentLength, new HashMap<Integer, FullHttpMessage>(), validateHeaders);
|
||||
this(version, maxContentLength, new HashMap<>(), validateHeaders);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -33,7 +33,7 @@ import java.util.Queue;
|
||||
public class SpdyHttpResponseStreamIdHandler extends
|
||||
MessageToMessageCodec<Object, HttpMessage> {
|
||||
private static final Integer NO_ID = -1;
|
||||
private final Queue<Integer> ids = new LinkedList<Integer>();
|
||||
private final Queue<Integer> ids = new LinkedList<>();
|
||||
|
||||
@Override
|
||||
public boolean acceptInboundMessage(Object msg) throws Exception {
|
||||
|
@ -59,7 +59,7 @@ final class SpdySession {
|
||||
|
||||
// Stream-IDs should be iterated in priority order
|
||||
Map<Integer, StreamState> activeStreams() {
|
||||
Map<Integer, StreamState> streams = new TreeMap<Integer, StreamState>(streamComparator);
|
||||
Map<Integer, StreamState> streams = new TreeMap<>(streamComparator);
|
||||
streams.putAll(activeStreams);
|
||||
return streams;
|
||||
}
|
||||
@ -239,7 +239,7 @@ final class SpdySession {
|
||||
private final AtomicInteger sendWindowSize;
|
||||
private final AtomicInteger receiveWindowSize;
|
||||
private int receiveWindowSizeLowerBound;
|
||||
private final Queue<PendingWrite> pendingWriteQueue = new ConcurrentLinkedQueue<PendingWrite>();
|
||||
private final Queue<PendingWrite> pendingWriteQueue = new ConcurrentLinkedQueue<>();
|
||||
|
||||
StreamState(
|
||||
byte priority, boolean remoteSideClosed, boolean localSideClosed,
|
||||
|
@ -273,7 +273,7 @@ public class HttpContentDecoderTest {
|
||||
HttpRequestDecoder decoder = new HttpRequestDecoder();
|
||||
final int maxBytes = 10;
|
||||
HttpObjectAggregator aggregator = new HttpObjectAggregator(maxBytes);
|
||||
final AtomicReference<FullHttpRequest> secondRequestRef = new AtomicReference<FullHttpRequest>();
|
||||
final AtomicReference<FullHttpRequest> secondRequestRef = new AtomicReference<>();
|
||||
EmbeddedChannel channel = new EmbeddedChannel(decoder, aggregator, new ChannelInboundHandlerAdapter() {
|
||||
@Override
|
||||
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
@ -571,7 +571,7 @@ public class HttpContentDecoderTest {
|
||||
|
||||
int outputSize = 0;
|
||||
ByteBuf o;
|
||||
List<ByteBuf> inbound = new ArrayList<ByteBuf>();
|
||||
List<ByteBuf> inbound = new ArrayList<>();
|
||||
while ((o = channel.readInbound()) != null) {
|
||||
inbound.add(o);
|
||||
outputSize += o.readableBytes();
|
||||
@ -626,7 +626,7 @@ public class HttpContentDecoderTest {
|
||||
|
||||
int outputSize = 0;
|
||||
ByteBuf o;
|
||||
List<ByteBuf> outbound = new ArrayList<ByteBuf>();
|
||||
List<ByteBuf> outbound = new ArrayList<>();
|
||||
while ((o = channel.readOutbound()) != null) {
|
||||
outbound.add(o);
|
||||
outputSize += o.readableBytes();
|
||||
|
@ -54,7 +54,7 @@ public final class HttpHeadersTestUtils {
|
||||
|
||||
public List<CharSequence> asList() {
|
||||
if (array == null) {
|
||||
List<CharSequence> list = new ArrayList<CharSequence>(nr);
|
||||
List<CharSequence> list = new ArrayList<>(nr);
|
||||
for (int i = 1; i <= nr; i++) {
|
||||
list.add(of(i).toString());
|
||||
}
|
||||
@ -68,7 +68,7 @@ public final class HttpHeadersTestUtils {
|
||||
--from;
|
||||
final int size = nr - from;
|
||||
final int end = from + size;
|
||||
List<CharSequence> list = new ArrayList<CharSequence>(size);
|
||||
List<CharSequence> list = new ArrayList<>(size);
|
||||
List<CharSequence> fullList = asList();
|
||||
for (int i = from; i < end; ++i) {
|
||||
list.add(fullList.get(i));
|
||||
@ -117,7 +117,7 @@ public final class HttpHeadersTestUtils {
|
||||
private static final Map<Integer, HeaderValue> MAP;
|
||||
|
||||
static {
|
||||
final Map<Integer, HeaderValue> map = new HashMap<Integer, HeaderValue>();
|
||||
final Map<Integer, HeaderValue> map = new HashMap<>();
|
||||
for (HeaderValue v : values()) {
|
||||
final int nr = v.nr;
|
||||
map.put(Integer.valueOf(nr), v);
|
||||
|
@ -194,7 +194,7 @@ public class HttpUtilTest {
|
||||
}
|
||||
|
||||
private static List<String> allPossibleCasesOfContinue() {
|
||||
final List<String> cases = new ArrayList<String>();
|
||||
final List<String> cases = new ArrayList<>();
|
||||
final String c = "continue";
|
||||
for (int i = 0; i < Math.pow(2, c.length()); i++) {
|
||||
final StringBuilder sb = new StringBuilder(c.length());
|
||||
|
@ -118,11 +118,11 @@ public class ClientCookieDecoderTest {
|
||||
|
||||
@Test
|
||||
public void testDecodingQuotedCookie() {
|
||||
Collection<String> sources = new ArrayList<String>();
|
||||
Collection<String> sources = new ArrayList<>();
|
||||
sources.add("a=\"\",");
|
||||
sources.add("b=\"1\",");
|
||||
|
||||
Collection<Cookie> cookies = new ArrayList<Cookie>();
|
||||
Collection<Cookie> cookies = new ArrayList<>();
|
||||
for (String source : sources) {
|
||||
cookies.add(ClientCookieDecoder.STRICT.decode(source));
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ public class ServerCookieEncoderTest {
|
||||
|
||||
@Test
|
||||
public void testEncodingMultipleCookiesStrict() {
|
||||
List<String> result = new ArrayList<String>();
|
||||
List<String> result = new ArrayList<>();
|
||||
result.add("cookie2=value2");
|
||||
result.add("cookie1=value3");
|
||||
Cookie cookie1 = new DefaultCookie("cookie1", "value1");
|
||||
@ -82,7 +82,7 @@ public class ServerCookieEncoderTest {
|
||||
|
||||
@Test
|
||||
public void illegalCharInCookieNameMakesStrictEncoderThrowsException() {
|
||||
Set<Character> illegalChars = new HashSet<Character>();
|
||||
Set<Character> illegalChars = new HashSet<>();
|
||||
// CTLs
|
||||
for (int i = 0x00; i <= 0x1F; i++) {
|
||||
illegalChars.add((char) i);
|
||||
@ -109,7 +109,7 @@ public class ServerCookieEncoderTest {
|
||||
|
||||
@Test
|
||||
public void illegalCharInCookieValueMakesStrictEncoderThrowsException() {
|
||||
Set<Character> illegalChars = new HashSet<Character>();
|
||||
Set<Character> illegalChars = new HashSet<>();
|
||||
// CTLs
|
||||
for (int i = 0x00; i <= 0x1F; i++) {
|
||||
illegalChars.add((char) i);
|
||||
@ -144,7 +144,7 @@ public class ServerCookieEncoderTest {
|
||||
|
||||
@Test
|
||||
public void testEncodingMultipleCookiesLax() {
|
||||
List<String> result = new ArrayList<String>();
|
||||
List<String> result = new ArrayList<>();
|
||||
result.add("cookie1=value1");
|
||||
result.add("cookie2=value2");
|
||||
result.add("cookie1=value3");
|
||||
|
@ -38,11 +38,11 @@ public class WebSocket08FrameDecoderTest {
|
||||
|
||||
@Test
|
||||
public void supportIanaStatusCodes() throws Exception {
|
||||
Set<Integer> forbiddenIanaCodes = new HashSet<Integer>();
|
||||
Set<Integer> forbiddenIanaCodes = new HashSet<>();
|
||||
forbiddenIanaCodes.add(1004);
|
||||
forbiddenIanaCodes.add(1005);
|
||||
forbiddenIanaCodes.add(1006);
|
||||
Set<Integer> validIanaCodes = new HashSet<Integer>();
|
||||
Set<Integer> validIanaCodes = new HashSet<>();
|
||||
for (int i = 1000; i < 1015; i++) {
|
||||
validIanaCodes.add(i);
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ import static org.junit.Assert.*;
|
||||
|
||||
public class WebSocketServerProtocolHandlerTest {
|
||||
|
||||
private final Queue<FullHttpResponse> responses = new ArrayDeque<FullHttpResponse>();
|
||||
private final Queue<FullHttpResponse> responses = new ArrayDeque<>();
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
|
@ -71,7 +71,7 @@ public class DeflateFrameClientExtensionHandshakerTest {
|
||||
DeflateFrameClientExtensionHandshaker handshaker =
|
||||
new DeflateFrameClientExtensionHandshaker(false);
|
||||
|
||||
Map<String, String> parameters = new HashMap<String, String>();
|
||||
Map<String, String> parameters = new HashMap<>();
|
||||
parameters.put("invalid", "12");
|
||||
|
||||
// execute
|
||||
|
@ -70,7 +70,7 @@ public class DeflateFrameServerExtensionHandshakerTest {
|
||||
new DeflateFrameServerExtensionHandshaker();
|
||||
|
||||
Map<String, String> parameters;
|
||||
parameters = new HashMap<String, String>();
|
||||
parameters = new HashMap<>();
|
||||
parameters.put("unknown", "11");
|
||||
|
||||
// execute
|
||||
|
@ -84,7 +84,7 @@ public class PerMessageDeflateClientExtensionHandshakerTest {
|
||||
PerMessageDeflateClientExtensionHandshaker handshaker =
|
||||
new PerMessageDeflateClientExtensionHandshaker(6, true, 10, true, true);
|
||||
|
||||
parameters = new HashMap<String, String>();
|
||||
parameters = new HashMap<>();
|
||||
parameters.put(CLIENT_MAX_WINDOW, "12");
|
||||
parameters.put(SERVER_MAX_WINDOW, "10");
|
||||
parameters.put(CLIENT_NO_CONTEXT, null);
|
||||
@ -101,7 +101,7 @@ public class PerMessageDeflateClientExtensionHandshakerTest {
|
||||
assertTrue(extension.newExtensionEncoder() instanceof PerMessageDeflateEncoder);
|
||||
|
||||
// initialize
|
||||
parameters = new HashMap<String, String>();
|
||||
parameters = new HashMap<>();
|
||||
parameters.put(SERVER_MAX_WINDOW, "10");
|
||||
parameters.put(SERVER_NO_CONTEXT, null);
|
||||
|
||||
@ -116,7 +116,7 @@ public class PerMessageDeflateClientExtensionHandshakerTest {
|
||||
assertTrue(extension.newExtensionEncoder() instanceof PerMessageDeflateEncoder);
|
||||
|
||||
// initialize
|
||||
parameters = new HashMap<String, String>();
|
||||
parameters = new HashMap<>();
|
||||
|
||||
// execute
|
||||
extension = handshaker.handshakeExtension(
|
||||
|
@ -56,7 +56,7 @@ public class PerMessageDeflateServerExtensionHandshakerTest {
|
||||
assertTrue(data.parameters().isEmpty());
|
||||
|
||||
// initialize
|
||||
parameters = new HashMap<String, String>();
|
||||
parameters = new HashMap<>();
|
||||
parameters.put(CLIENT_MAX_WINDOW, null);
|
||||
parameters.put(CLIENT_NO_CONTEXT, null);
|
||||
|
||||
@ -78,7 +78,7 @@ public class PerMessageDeflateServerExtensionHandshakerTest {
|
||||
assertTrue(data.parameters().isEmpty());
|
||||
|
||||
// initialize
|
||||
parameters = new HashMap<String, String>();
|
||||
parameters = new HashMap<>();
|
||||
parameters.put(SERVER_MAX_WINDOW, "12");
|
||||
parameters.put(SERVER_NO_CONTEXT, null);
|
||||
|
||||
@ -100,7 +100,7 @@ public class PerMessageDeflateServerExtensionHandshakerTest {
|
||||
PerMessageDeflateServerExtensionHandshaker handshaker =
|
||||
new PerMessageDeflateServerExtensionHandshaker(6, true, 10, true, true);
|
||||
|
||||
parameters = new HashMap<String, String>();
|
||||
parameters = new HashMap<>();
|
||||
parameters.put(CLIENT_MAX_WINDOW, null);
|
||||
parameters.put(SERVER_MAX_WINDOW, "12");
|
||||
parameters.put(CLIENT_NO_CONTEXT, null);
|
||||
@ -129,7 +129,7 @@ public class PerMessageDeflateServerExtensionHandshakerTest {
|
||||
assertTrue(data.parameters().containsKey(SERVER_MAX_WINDOW));
|
||||
|
||||
// initialize
|
||||
parameters = new HashMap<String, String>();
|
||||
parameters = new HashMap<>();
|
||||
parameters.put(SERVER_MAX_WINDOW, "12");
|
||||
parameters.put(SERVER_NO_CONTEXT, null);
|
||||
|
||||
@ -154,7 +154,7 @@ public class PerMessageDeflateServerExtensionHandshakerTest {
|
||||
assertTrue(data.parameters().containsKey(SERVER_NO_CONTEXT));
|
||||
|
||||
// initialize
|
||||
parameters = new HashMap<String, String>();
|
||||
parameters = new HashMap<>();
|
||||
|
||||
// execute
|
||||
extension = handshaker.handshakeExtension(
|
||||
|
@ -48,7 +48,7 @@ public class SpdyFrameDecoderTest {
|
||||
}
|
||||
|
||||
private final class TestSpdyFrameDecoderDelegate implements SpdyFrameDecoderDelegate {
|
||||
private final Queue<ByteBuf> buffers = new ArrayDeque<ByteBuf>();
|
||||
private final Queue<ByteBuf> buffers = new ArrayDeque<>();
|
||||
|
||||
@Override
|
||||
public void readDataFrame(int streamId, boolean last, ByteBuf data) {
|
||||
|
@ -78,7 +78,7 @@ public class DefaultHttp2Connection implements Http2Connection {
|
||||
* (local/remote flow controller and {@link StreamByteDistributor}) and we leave room for 1 extra.
|
||||
* We could be more aggressive but the ArrayList resize will double the size if we are too small.
|
||||
*/
|
||||
final List<Listener> listeners = new ArrayList<Listener>(4);
|
||||
final List<Listener> listeners = new ArrayList<>(4);
|
||||
final ActiveStreams activeStreams;
|
||||
Promise<Void> closePromise;
|
||||
|
||||
@ -102,8 +102,8 @@ public class DefaultHttp2Connection implements Http2Connection {
|
||||
// in response to any locally enforced limits being exceeded [2].
|
||||
// [1] https://tools.ietf.org/html/rfc7540#section-5.1.2
|
||||
// [2] https://tools.ietf.org/html/rfc7540#section-8.2.2
|
||||
localEndpoint = new DefaultEndpoint<Http2LocalFlowController>(server, server ? MAX_VALUE : maxReservedStreams);
|
||||
remoteEndpoint = new DefaultEndpoint<Http2RemoteFlowController>(!server, maxReservedStreams);
|
||||
localEndpoint = new DefaultEndpoint<>(server, server ? MAX_VALUE : maxReservedStreams);
|
||||
remoteEndpoint = new DefaultEndpoint<>(!server, maxReservedStreams);
|
||||
|
||||
// Add the connection stream to the map.
|
||||
streamMap.put(connectionStream.id(), connectionStream);
|
||||
@ -127,7 +127,7 @@ public class DefaultHttp2Connection implements Http2Connection {
|
||||
} else if ((promise instanceof ChannelPromise) && ((ChannelPromise) closePromise).isVoid()) {
|
||||
closePromise = promise;
|
||||
} else {
|
||||
closePromise.addListener(new UnaryPromiseNotifier<Void>(promise));
|
||||
closePromise.addListener(new UnaryPromiseNotifier<>(promise));
|
||||
}
|
||||
} else {
|
||||
closePromise = promise;
|
||||
@ -926,8 +926,8 @@ public class DefaultHttp2Connection implements Http2Connection {
|
||||
*/
|
||||
private final class ActiveStreams {
|
||||
private final List<Listener> listeners;
|
||||
private final Queue<Event> pendingEvents = new ArrayDeque<Event>(4);
|
||||
private final Set<Http2Stream> streams = new LinkedHashSet<Http2Stream>();
|
||||
private final Queue<Event> pendingEvents = new ArrayDeque<>(4);
|
||||
private final Set<Http2Stream> streams = new LinkedHashSet<>();
|
||||
private int pendingIterations;
|
||||
|
||||
public ActiveStreams(List<Listener> listeners) {
|
||||
@ -1055,7 +1055,7 @@ public class DefaultHttp2Connection implements Http2Connection {
|
||||
* (local/remote flow controller and {@link StreamByteDistributor}) and we leave room for 1 extra.
|
||||
* We could be more aggressive but the ArrayList resize will double the size if we are too small.
|
||||
*/
|
||||
final List<DefaultPropertyKey> keys = new ArrayList<DefaultPropertyKey>(4);
|
||||
final List<DefaultPropertyKey> keys = new ArrayList<>(4);
|
||||
|
||||
/**
|
||||
* Registers a new property key.
|
||||
|
@ -43,7 +43,7 @@ public class DefaultHttp2ConnectionEncoder implements Http2ConnectionEncoder {
|
||||
private Http2LifecycleManager lifecycleManager;
|
||||
// We prefer ArrayDeque to LinkedList because later will produce more GC.
|
||||
// This initial capacity is plenty for SETTINGS traffic.
|
||||
private final ArrayDeque<Http2Settings> outstandingLocalSettingsQueue = new ArrayDeque<Http2Settings>(4);
|
||||
private final ArrayDeque<Http2Settings> outstandingLocalSettingsQueue = new ArrayDeque<>(4);
|
||||
|
||||
public DefaultHttp2ConnectionEncoder(Http2Connection connection, Http2FrameWriter frameWriter) {
|
||||
this.connection = checkNotNull(connection, "connection");
|
||||
|
@ -287,7 +287,7 @@ public class DefaultHttp2RemoteFlowController implements Http2RemoteFlowControll
|
||||
|
||||
FlowState(Http2Stream stream) {
|
||||
this.stream = stream;
|
||||
pendingWriteQueue = new ArrayDeque<FlowControlled>(2);
|
||||
pendingWriteQueue = new ArrayDeque<>(2);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -170,7 +170,7 @@ final class HpackStaticTable {
|
||||
private static CharSequenceMap<Integer> createMap() {
|
||||
int length = STATIC_TABLE.size();
|
||||
@SuppressWarnings("unchecked")
|
||||
CharSequenceMap<Integer> ret = new CharSequenceMap<Integer>(true,
|
||||
CharSequenceMap<Integer> ret = new CharSequenceMap<>(true,
|
||||
UnsupportedValueConverter.<Integer>instance(), length);
|
||||
// Iterate through the static table in reverse order to
|
||||
// save the smallest index for a given name in the map.
|
||||
|
@ -275,7 +275,7 @@ public class Http2Exception extends Exception {
|
||||
|
||||
public CompositeStreamException(Http2Error error, int initialCapacity) {
|
||||
super(error, ShutdownHint.NO_SHUTDOWN);
|
||||
exceptions = new ArrayList<StreamException>(initialCapacity);
|
||||
exceptions = new ArrayList<>(initialCapacity);
|
||||
}
|
||||
|
||||
public void add(StreamException e) {
|
||||
|
@ -62,7 +62,7 @@ public interface Http2Headers extends Headers<CharSequence, CharSequence, Http2H
|
||||
|
||||
private final AsciiString value;
|
||||
private final boolean requestOnly;
|
||||
private static final CharSequenceMap<PseudoHeaderName> PSEUDO_HEADERS = new CharSequenceMap<PseudoHeaderName>();
|
||||
private static final CharSequenceMap<PseudoHeaderName> PSEUDO_HEADERS = new CharSequenceMap<>();
|
||||
|
||||
static {
|
||||
for (PseudoHeaderName pseudoHeader : PseudoHeaderName.values()) {
|
||||
|
@ -790,7 +790,7 @@ public class Http2MultiplexCodec extends Http2FrameCodec {
|
||||
}
|
||||
} else {
|
||||
if (inboundBuffer == null) {
|
||||
inboundBuffer = new ArrayDeque<Object>(4);
|
||||
inboundBuffer = new ArrayDeque<>(4);
|
||||
}
|
||||
inboundBuffer.add(frame);
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ public final class Http2SecurityUtil {
|
||||
));
|
||||
|
||||
static {
|
||||
CIPHERS = Collections.unmodifiableList(new ArrayList<String>(CIPHERS_JAVA_MOZILLA_MODERN_SECURITY));
|
||||
CIPHERS = Collections.unmodifiableList(new ArrayList<>(CIPHERS_JAVA_MOZILLA_MODERN_SECURITY));
|
||||
}
|
||||
|
||||
private Http2SecurityUtil() { }
|
||||
|
@ -40,8 +40,8 @@ import java.util.Map;
|
||||
public final class Http2StreamChannelBootstrap {
|
||||
private static final InternalLogger logger = InternalLoggerFactory.getInstance(Http2StreamChannelBootstrap.class);
|
||||
|
||||
private final Map<ChannelOption<?>, Object> options = new LinkedHashMap<ChannelOption<?>, Object>();
|
||||
private final Map<AttributeKey<?>, Object> attrs = new LinkedHashMap<AttributeKey<?>, Object>();
|
||||
private final Map<ChannelOption<?>, Object> options = new LinkedHashMap<>();
|
||||
private final Map<AttributeKey<?>, Object> attrs = new LinkedHashMap<>();
|
||||
private final Channel channel;
|
||||
private volatile ChannelHandler handler;
|
||||
|
||||
|
@ -72,7 +72,7 @@ public final class HttpConversionUtil {
|
||||
* The set of headers that should not be directly copied when converting headers from HTTP to HTTP/2.
|
||||
*/
|
||||
private static final CharSequenceMap<AsciiString> HTTP_TO_HTTP2_HEADER_BLACKLIST =
|
||||
new CharSequenceMap<AsciiString>();
|
||||
new CharSequenceMap<>();
|
||||
static {
|
||||
HTTP_TO_HTTP2_HEADER_BLACKLIST.add(CONNECTION, EMPTY_STRING);
|
||||
@SuppressWarnings("deprecation")
|
||||
@ -424,7 +424,7 @@ public final class HttpConversionUtil {
|
||||
private static CharSequenceMap<AsciiString> toLowercaseMap(Iterator<? extends CharSequence> valuesIter,
|
||||
int arraySizeHint) {
|
||||
UnsupportedValueConverter<AsciiString> valueConverter = UnsupportedValueConverter.<AsciiString>instance();
|
||||
CharSequenceMap<AsciiString> result = new CharSequenceMap<AsciiString>(true, valueConverter, arraySizeHint);
|
||||
CharSequenceMap<AsciiString> result = new CharSequenceMap<>(true, valueConverter, arraySizeHint);
|
||||
|
||||
while (valuesIter.hasNext()) {
|
||||
AsciiString lowerCased = AsciiString.of(valuesIter.next()).toLowerCase();
|
||||
@ -590,9 +590,9 @@ public final class HttpConversionUtil {
|
||||
* Translations from HTTP/2 header name to the HTTP/1.x equivalent.
|
||||
*/
|
||||
private static final CharSequenceMap<AsciiString>
|
||||
REQUEST_HEADER_TRANSLATIONS = new CharSequenceMap<AsciiString>();
|
||||
REQUEST_HEADER_TRANSLATIONS = new CharSequenceMap<>();
|
||||
private static final CharSequenceMap<AsciiString>
|
||||
RESPONSE_HEADER_TRANSLATIONS = new CharSequenceMap<AsciiString>();
|
||||
RESPONSE_HEADER_TRANSLATIONS = new CharSequenceMap<>();
|
||||
static {
|
||||
RESPONSE_HEADER_TRANSLATIONS.add(Http2Headers.PseudoHeaderName.AUTHORITY.value(),
|
||||
HttpHeaderNames.HOST);
|
||||
|
@ -199,7 +199,7 @@ public final class ReadOnlyHttp2Headers implements Http2Headers {
|
||||
@Override
|
||||
public List<CharSequence> getAll(CharSequence name) {
|
||||
final int nameHash = AsciiString.hashCode(name);
|
||||
List<CharSequence> values = new ArrayList<CharSequence>();
|
||||
List<CharSequence> values = new ArrayList<>();
|
||||
|
||||
final int pseudoHeadersEnd = pseudoHeaders.length - 1;
|
||||
for (int i = 0; i < pseudoHeadersEnd; i += 2) {
|
||||
@ -501,7 +501,7 @@ public final class ReadOnlyHttp2Headers implements Http2Headers {
|
||||
if (isEmpty()) {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
Set<CharSequence> names = new LinkedHashSet<CharSequence>(size());
|
||||
Set<CharSequence> names = new LinkedHashSet<>(size());
|
||||
final int pseudoHeadersEnd = pseudoHeaders.length - 1;
|
||||
for (int i = 0; i < pseudoHeadersEnd; i += 2) {
|
||||
names.add(pseudoHeaders[i]);
|
||||
|
@ -103,7 +103,7 @@ public class StreamBufferingEncoder extends DecoratingHttp2ConnectionEncoder {
|
||||
* Buffer for any streams and corresponding frames that could not be created due to the maximum
|
||||
* concurrent stream limit being hit.
|
||||
*/
|
||||
private final TreeMap<Integer, PendingStream> pendingStreams = new TreeMap<Integer, PendingStream>();
|
||||
private final TreeMap<Integer, PendingStream> pendingStreams = new TreeMap<>();
|
||||
private int maxConcurrentStreams;
|
||||
private boolean closed;
|
||||
|
||||
@ -274,7 +274,7 @@ public class StreamBufferingEncoder extends DecoratingHttp2ConnectionEncoder {
|
||||
private static final class PendingStream {
|
||||
final ChannelHandlerContext ctx;
|
||||
final int streamId;
|
||||
final Queue<Frame> frames = new ArrayDeque<Frame>(2);
|
||||
final Queue<Frame> frames = new ArrayDeque<>(2);
|
||||
|
||||
PendingStream(ChannelHandlerContext ctx, int streamId) {
|
||||
this.ctx = ctx;
|
||||
|
@ -36,7 +36,7 @@ import static java.lang.Math.min;
|
||||
@UnstableApi
|
||||
public final class UniformStreamByteDistributor implements StreamByteDistributor {
|
||||
private final Http2Connection.PropertyKey stateKey;
|
||||
private final Deque<State> queue = new ArrayDeque<State>(4);
|
||||
private final Deque<State> queue = new ArrayDeque<>(4);
|
||||
|
||||
/**
|
||||
* The minimum number of bytes that we will attempt to allocate to a stream. This is to
|
||||
|
@ -105,7 +105,7 @@ public final class WeightedFairQueueByteDistributor implements StreamByteDistrib
|
||||
stateOnlyMap = new IntObjectHashMap<State>(maxStateOnlySize);
|
||||
// +2 because we may exceed the limit by 2 if a new dependency has no associated Http2Stream object. We need
|
||||
// to create the State objects to put them into the dependency tree, which then impacts priority.
|
||||
stateOnlyRemovalQueue = new DefaultPriorityQueue<State>(StateOnlyComparator.INSTANCE, maxStateOnlySize + 2);
|
||||
stateOnlyRemovalQueue = new DefaultPriorityQueue<>(StateOnlyComparator.INSTANCE, maxStateOnlySize + 2);
|
||||
}
|
||||
this.maxStateOnlySize = maxStateOnlySize;
|
||||
|
||||
@ -122,7 +122,7 @@ public final class WeightedFairQueueByteDistributor implements StreamByteDistrib
|
||||
if (state == null) {
|
||||
state = new State(stream);
|
||||
// Only the stream which was just added will change parents. So we only need an array of size 1.
|
||||
List<ParentChangedEvent> events = new ArrayList<ParentChangedEvent>(1);
|
||||
List<ParentChangedEvent> events = new ArrayList<>(1);
|
||||
connectionState.takeChild(state, false, events);
|
||||
notifyParentChanged(events);
|
||||
} else {
|
||||
@ -221,7 +221,7 @@ public final class WeightedFairQueueByteDistributor implements StreamByteDistrib
|
||||
stateOnlyRemovalQueue.add(newParent);
|
||||
stateOnlyMap.put(parentStreamId, newParent);
|
||||
// Only the stream which was just added will change parents. So we only need an array of size 1.
|
||||
List<ParentChangedEvent> events = new ArrayList<ParentChangedEvent>(1);
|
||||
List<ParentChangedEvent> events = new ArrayList<>(1);
|
||||
connectionState.takeChild(newParent, false, events);
|
||||
notifyParentChanged(events);
|
||||
}
|
||||
@ -236,10 +236,10 @@ public final class WeightedFairQueueByteDistributor implements StreamByteDistrib
|
||||
if (newParent != state.parent || (exclusive && newParent.children.size() != 1)) {
|
||||
final List<ParentChangedEvent> events;
|
||||
if (newParent.isDescendantOf(state)) {
|
||||
events = new ArrayList<ParentChangedEvent>(2 + (exclusive ? newParent.children.size() : 0));
|
||||
events = new ArrayList<>(2 + (exclusive ? newParent.children.size() : 0));
|
||||
state.parent.takeChild(newParent, false, events);
|
||||
} else {
|
||||
events = new ArrayList<ParentChangedEvent>(1 + (exclusive ? newParent.children.size() : 0));
|
||||
events = new ArrayList<>(1 + (exclusive ? newParent.children.size() : 0));
|
||||
}
|
||||
newParent.takeChild(state, exclusive, events);
|
||||
notifyParentChanged(events);
|
||||
@ -487,7 +487,7 @@ public final class WeightedFairQueueByteDistributor implements StreamByteDistrib
|
||||
State(int streamId, Http2Stream stream, int initialSize) {
|
||||
this.stream = stream;
|
||||
this.streamId = streamId;
|
||||
pseudoTimeQueue = new DefaultPriorityQueue<State>(StatePseudoTimeComparator.INSTANCE, initialSize);
|
||||
pseudoTimeQueue = new DefaultPriorityQueue<>(StatePseudoTimeComparator.INSTANCE, initialSize);
|
||||
}
|
||||
|
||||
boolean isDescendantOf(State state) {
|
||||
@ -547,7 +547,7 @@ public final class WeightedFairQueueByteDistributor implements StreamByteDistrib
|
||||
*/
|
||||
void removeChild(State child) {
|
||||
if (children.remove(child.streamId) != null) {
|
||||
List<ParentChangedEvent> events = new ArrayList<ParentChangedEvent>(1 + child.children.size());
|
||||
List<ParentChangedEvent> events = new ArrayList<>(1 + child.children.size());
|
||||
events.add(new ParentChangedEvent(child, child.parent));
|
||||
child.setParent(null);
|
||||
|
||||
|
@ -70,7 +70,7 @@ public class CleartextHttp2ServerUpgradeHandlerTest {
|
||||
}
|
||||
};
|
||||
|
||||
userEvents = new ArrayList<Object>();
|
||||
userEvents = new ArrayList<>();
|
||||
|
||||
HttpServerCodec httpServerCodec = new HttpServerCodec();
|
||||
HttpServerUpgradeHandler upgradeHandler = new HttpServerUpgradeHandler(httpServerCodec, upgradeCodecFactory);
|
||||
@ -213,7 +213,7 @@ public class CleartextHttp2ServerUpgradeHandlerTest {
|
||||
};
|
||||
http2ConnectionHandler = http2Codec;
|
||||
|
||||
userEvents = new ArrayList<Object>();
|
||||
userEvents = new ArrayList<>();
|
||||
|
||||
HttpServerCodec httpServerCodec = new HttpServerCodec();
|
||||
HttpServerUpgradeHandler upgradeHandler = new HttpServerUpgradeHandler(httpServerCodec, upgradeCodecFactory);
|
||||
|
@ -150,8 +150,8 @@ public class DefaultHttp2ConnectionEncoderTest {
|
||||
return ((ChannelPromise) in.getArguments()[4]).setSuccess();
|
||||
}
|
||||
}).when(writer).writeGoAway(eq(ctx), anyInt(), anyInt(), any(ByteBuf.class), any(ChannelPromise.class));
|
||||
writtenData = new ArrayList<String>();
|
||||
writtenPadding = new ArrayList<Integer>();
|
||||
writtenData = new ArrayList<>();
|
||||
writtenPadding = new ArrayList<>();
|
||||
when(writer.writeData(eq(ctx), anyInt(), any(ByteBuf.class), anyInt(), anyBoolean(),
|
||||
any(ChannelPromise.class))).then(new Answer<ChannelFuture>() {
|
||||
@Override
|
||||
|
@ -43,7 +43,7 @@ public final class HashCollisionTest {
|
||||
|
||||
public static void main(String[] args) throws IllegalAccessException, IOException, URISyntaxException {
|
||||
// Big initial size for when all name sources are pulled in.
|
||||
List<CharSequence> strings = new ArrayList<CharSequence>(350000);
|
||||
List<CharSequence> strings = new ArrayList<>(350000);
|
||||
addHttpHeaderNames(strings);
|
||||
addHttpHeaderValues(strings);
|
||||
addHttp2HeaderNames(strings);
|
||||
@ -118,14 +118,14 @@ public final class HashCollisionTest {
|
||||
|
||||
private static Map<Integer, List<CharSequence>> calculateDuplicates(List<CharSequence> strings,
|
||||
Function<CharSequence, Integer> hasher) {
|
||||
Map<Integer, List<CharSequence>> hashResults = new HashMap<Integer, List<CharSequence>>();
|
||||
Set<Integer> duplicateHashCodes = new HashSet<Integer>();
|
||||
Map<Integer, List<CharSequence>> hashResults = new HashMap<>();
|
||||
Set<Integer> duplicateHashCodes = new HashSet<>();
|
||||
|
||||
for (CharSequence str : strings) {
|
||||
Integer hash = hasher.apply(str);
|
||||
List<CharSequence> results = hashResults.get(hash);
|
||||
if (results == null) {
|
||||
results = new ArrayList<CharSequence>(1);
|
||||
results = new ArrayList<>(1);
|
||||
hashResults.put(hash, results);
|
||||
} else {
|
||||
duplicateHashCodes.add(hash);
|
||||
@ -137,9 +137,9 @@ public final class HashCollisionTest {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
Map<Integer, List<CharSequence>> duplicates =
|
||||
new HashMap<Integer, List<CharSequence>>(duplicateHashCodes.size());
|
||||
new HashMap<>(duplicateHashCodes.size());
|
||||
for (Integer duplicateHashCode : duplicateHashCodes) {
|
||||
List<CharSequence> realDups = new ArrayList<CharSequence>(2);
|
||||
List<CharSequence> realDups = new ArrayList<>(2);
|
||||
Iterator<CharSequence> itr = hashResults.get(duplicateHashCode).iterator();
|
||||
// there should be at least 2 elements in the list ... bcz there may be duplicates
|
||||
realDups.add(itr.next());
|
||||
|
@ -61,7 +61,7 @@ public class HpackTest {
|
||||
throw new NullPointerException("files");
|
||||
}
|
||||
|
||||
ArrayList<Object[]> data = new ArrayList<Object[]>();
|
||||
ArrayList<Object[]> data = new ArrayList<>();
|
||||
for (File file : files) {
|
||||
data.add(new Object[]{file.getName()});
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ final class HpackTestCase {
|
||||
"\nACTUAL:\n" + StringUtil.toHexString(actual));
|
||||
}
|
||||
|
||||
List<HpackHeaderField> actualDynamicTable = new ArrayList<HpackHeaderField>();
|
||||
List<HpackHeaderField> actualDynamicTable = new ArrayList<>();
|
||||
for (int index = 0; index < hpackEncoder.length(); index++) {
|
||||
actualDynamicTable.add(hpackEncoder.getHeaderField(index));
|
||||
}
|
||||
@ -123,7 +123,7 @@ final class HpackTestCase {
|
||||
|
||||
List<HpackHeaderField> actualHeaders = decode(hpackDecoder, headerBlock.encodedBytes);
|
||||
|
||||
List<HpackHeaderField> expectedHeaders = new ArrayList<HpackHeaderField>();
|
||||
List<HpackHeaderField> expectedHeaders = new ArrayList<>();
|
||||
for (HpackHeaderField h : headerBlock.getHeaders()) {
|
||||
expectedHeaders.add(new HpackHeaderField(h.name, h.value));
|
||||
}
|
||||
@ -134,7 +134,7 @@ final class HpackTestCase {
|
||||
"\nACTUAL:\n" + actualHeaders);
|
||||
}
|
||||
|
||||
List<HpackHeaderField> actualDynamicTable = new ArrayList<HpackHeaderField>();
|
||||
List<HpackHeaderField> actualDynamicTable = new ArrayList<>();
|
||||
for (int index = 0; index < hpackDecoder.length(); index++) {
|
||||
actualDynamicTable.add(hpackDecoder.getHeaderField(index));
|
||||
}
|
||||
@ -212,7 +212,7 @@ final class HpackTestCase {
|
||||
private static List<HpackHeaderField> decode(HpackDecoder hpackDecoder, byte[] expected) throws Exception {
|
||||
ByteBuf in = Unpooled.wrappedBuffer(expected);
|
||||
try {
|
||||
List<HpackHeaderField> headers = new ArrayList<HpackHeaderField>();
|
||||
List<HpackHeaderField> headers = new ArrayList<>();
|
||||
TestHeaderListener listener = new TestHeaderListener(headers);
|
||||
hpackDecoder.decode(0, in, listener, true);
|
||||
return headers;
|
||||
|
@ -238,9 +238,9 @@ public class Http2ConnectionRoundtripTest {
|
||||
final CountDownLatch serverRevHeadersLatch = new CountDownLatch(1);
|
||||
final CountDownLatch clientHeadersLatch = new CountDownLatch(1);
|
||||
final CountDownLatch clientDataWrite = new CountDownLatch(1);
|
||||
final AtomicReference<Throwable> clientHeadersWriteException = new AtomicReference<Throwable>();
|
||||
final AtomicReference<Throwable> clientHeadersWriteException2 = new AtomicReference<Throwable>();
|
||||
final AtomicReference<Throwable> clientDataWriteException = new AtomicReference<Throwable>();
|
||||
final AtomicReference<Throwable> clientHeadersWriteException = new AtomicReference<>();
|
||||
final AtomicReference<Throwable> clientHeadersWriteException2 = new AtomicReference<>();
|
||||
final AtomicReference<Throwable> clientDataWriteException = new AtomicReference<>();
|
||||
|
||||
final Http2Headers headers = dummyHeaders();
|
||||
|
||||
@ -520,7 +520,7 @@ public class Http2ConnectionRoundtripTest {
|
||||
|
||||
final CountDownLatch serverGotRstLatch = new CountDownLatch(1);
|
||||
final CountDownLatch serverWriteHeadersLatch = new CountDownLatch(1);
|
||||
final AtomicReference<Throwable> serverWriteHeadersCauseRef = new AtomicReference<Throwable>();
|
||||
final AtomicReference<Throwable> serverWriteHeadersCauseRef = new AtomicReference<>();
|
||||
|
||||
final Http2Headers headers = dummyHeaders();
|
||||
final int streamId = 3;
|
||||
@ -907,7 +907,7 @@ public class Http2ConnectionRoundtripTest {
|
||||
verify(clientListener).onGoAwayRead(any(ChannelHandlerContext.class), eq(3), eq(NO_ERROR.code()),
|
||||
any(ByteBuf.class));
|
||||
|
||||
final AtomicReference<ChannelFuture> clientWriteAfterGoAwayFutureRef = new AtomicReference<ChannelFuture>();
|
||||
final AtomicReference<ChannelFuture> clientWriteAfterGoAwayFutureRef = new AtomicReference<>();
|
||||
final CountDownLatch clientWriteAfterGoAwayLatch = new CountDownLatch(1);
|
||||
runInChannel(clientChannel, new Http2Runnable() {
|
||||
@Override
|
||||
@ -962,7 +962,7 @@ public class Http2ConnectionRoundtripTest {
|
||||
setServerGracefulShutdownTime(10000);
|
||||
|
||||
final Http2Headers headers = dummyHeaders();
|
||||
final AtomicReference<ChannelFuture> clientWriteAfterGoAwayFutureRef = new AtomicReference<ChannelFuture>();
|
||||
final AtomicReference<ChannelFuture> clientWriteAfterGoAwayFutureRef = new AtomicReference<>();
|
||||
final CountDownLatch clientWriteAfterGoAwayLatch = new CountDownLatch(1);
|
||||
doAnswer(new Answer<Void>() {
|
||||
@Override
|
||||
@ -1189,7 +1189,7 @@ public class Http2ConnectionRoundtripTest {
|
||||
sb = new ServerBootstrap();
|
||||
cb = new Bootstrap();
|
||||
|
||||
final AtomicReference<Http2ConnectionHandler> serverHandlerRef = new AtomicReference<Http2ConnectionHandler>();
|
||||
final AtomicReference<Http2ConnectionHandler> serverHandlerRef = new AtomicReference<>();
|
||||
final CountDownLatch serverInitLatch = new CountDownLatch(1);
|
||||
sb.group(new LocalEventLoopGroup());
|
||||
sb.channel(LocalServerChannel.class);
|
||||
|
@ -570,7 +570,7 @@ public class Http2FrameCodecTest {
|
||||
assertNotNull(stream);
|
||||
assertFalse(isStreamIdValid(stream.id()));
|
||||
|
||||
final Promise<Void> listenerExecuted = new DefaultPromise<Void>(GlobalEventExecutor.INSTANCE);
|
||||
final Promise<Void> listenerExecuted = new DefaultPromise<>(GlobalEventExecutor.INSTANCE);
|
||||
|
||||
channel.writeAndFlush(new DefaultHttp2HeadersFrame(new DefaultHttp2Headers(), false).stream(stream))
|
||||
.addListener(new ChannelFutureListener() {
|
||||
@ -734,7 +734,7 @@ public class Http2FrameCodecTest {
|
||||
@SuppressWarnings("unused")
|
||||
Http2FrameStream idleStream = frameCodec.newStream();
|
||||
|
||||
final Set<Http2FrameStream> activeStreams = new HashSet<Http2FrameStream>();
|
||||
final Set<Http2FrameStream> activeStreams = new HashSet<>();
|
||||
frameCodec.forEachActiveStream(new Http2FrameStreamVisitor() {
|
||||
@Override
|
||||
public boolean visit(Http2FrameStream stream) {
|
||||
@ -745,7 +745,7 @@ public class Http2FrameCodecTest {
|
||||
|
||||
assertEquals(2, activeStreams.size());
|
||||
|
||||
Set<Http2FrameStream> expectedStreams = new HashSet<Http2FrameStream>();
|
||||
Set<Http2FrameStream> expectedStreams = new HashSet<>();
|
||||
expectedStreams.add(activeInbond);
|
||||
expectedStreams.add(activeOutbound);
|
||||
assertEquals(expectedStreams, activeStreams);
|
||||
|
@ -88,7 +88,7 @@ public class Http2FrameRoundtripTest {
|
||||
|
||||
private Http2FrameWriter writer;
|
||||
private Http2FrameReader reader;
|
||||
private final List<ByteBuf> needReleasing = new LinkedList<ByteBuf>();
|
||||
private final List<ByteBuf> needReleasing = new LinkedList<>();
|
||||
|
||||
@Before
|
||||
public void setup() throws Exception {
|
||||
|
@ -155,7 +155,7 @@ public class Http2MultiplexCodecTest {
|
||||
|
||||
private Http2StreamChannel newInboundStream(int streamId, boolean endStream,
|
||||
AtomicInteger maxReads, final ChannelHandler childHandler) {
|
||||
final AtomicReference<Http2StreamChannel> streamChannelRef = new AtomicReference<Http2StreamChannel>();
|
||||
final AtomicReference<Http2StreamChannel> streamChannelRef = new AtomicReference<>();
|
||||
childChannelInitializer.maxReads = maxReads;
|
||||
childChannelInitializer.handler = new ChannelInboundHandlerAdapter() {
|
||||
@Override
|
||||
@ -595,7 +595,7 @@ public class Http2MultiplexCodecTest {
|
||||
|
||||
@Test
|
||||
public void channelClosedWhenWriteFutureFails() {
|
||||
final Queue<ChannelPromise> writePromises = new ArrayDeque<ChannelPromise>();
|
||||
final Queue<ChannelPromise> writePromises = new ArrayDeque<>();
|
||||
|
||||
LastInboundHandler inboundHandler = new LastInboundHandler();
|
||||
Http2StreamChannel childChannel = newInboundStream(3, false, inboundHandler);
|
||||
|
@ -446,7 +446,7 @@ public class Http2StreamFrameToHttpObjectCodecTest {
|
||||
|
||||
@Test
|
||||
public void testEncodeHttpsSchemeWhenSslHandlerExists() throws Exception {
|
||||
final Queue<Http2StreamFrame> frames = new ConcurrentLinkedQueue<Http2StreamFrame>();
|
||||
final Queue<Http2StreamFrame> frames = new ConcurrentLinkedQueue<>();
|
||||
|
||||
final SslContext ctx = SslContextBuilder.forClient().sslProvider(SslProvider.JDK).build();
|
||||
EmbeddedChannel ch = new EmbeddedChannel(ctx.newHandler(ByteBufAllocator.DEFAULT),
|
||||
@ -875,7 +875,7 @@ public class Http2StreamFrameToHttpObjectCodecTest {
|
||||
|
||||
@Test
|
||||
public void testIsSharableBetweenChannels() throws Exception {
|
||||
final Queue<Http2StreamFrame> frames = new ConcurrentLinkedQueue<Http2StreamFrame>();
|
||||
final Queue<Http2StreamFrame> frames = new ConcurrentLinkedQueue<>();
|
||||
final ChannelHandler sharedHandler = new Http2StreamFrameToHttpObjectCodec(false);
|
||||
|
||||
final SslContext ctx = SslContextBuilder.forClient().sslProvider(SslProvider.JDK).build();
|
||||
|
@ -572,7 +572,7 @@ public final class Http2TestUtil {
|
||||
}
|
||||
};
|
||||
|
||||
final ConcurrentLinkedQueue<ByteBuf> buffers = new ConcurrentLinkedQueue<ByteBuf>();
|
||||
final ConcurrentLinkedQueue<ByteBuf> buffers = new ConcurrentLinkedQueue<>();
|
||||
|
||||
Http2FrameWriter frameWriter = Mockito.mock(Http2FrameWriter.class);
|
||||
doAnswer(new Answer() {
|
||||
|
@ -335,7 +335,7 @@ public class HttpToHttp2ConnectionHandlerTest {
|
||||
@Test
|
||||
public void testRequestWithBody() throws Exception {
|
||||
final String text = "foooooogoooo";
|
||||
final List<String> receivedBuffers = Collections.synchronizedList(new ArrayList<String>());
|
||||
final List<String> receivedBuffers = Collections.synchronizedList(new ArrayList<>());
|
||||
doAnswer(new Answer<Void>() {
|
||||
@Override
|
||||
public Void answer(InvocationOnMock in) throws Throwable {
|
||||
@ -378,7 +378,7 @@ public class HttpToHttp2ConnectionHandlerTest {
|
||||
@Test
|
||||
public void testRequestWithBodyAndTrailingHeaders() throws Exception {
|
||||
final String text = "foooooogoooo";
|
||||
final List<String> receivedBuffers = Collections.synchronizedList(new ArrayList<String>());
|
||||
final List<String> receivedBuffers = Collections.synchronizedList(new ArrayList<>());
|
||||
doAnswer(new Answer<Void>() {
|
||||
@Override
|
||||
public Void answer(InvocationOnMock in) throws Throwable {
|
||||
@ -430,7 +430,7 @@ public class HttpToHttp2ConnectionHandlerTest {
|
||||
public void testChunkedRequestWithBodyAndTrailingHeaders() throws Exception {
|
||||
final String text = "foooooo";
|
||||
final String text2 = "goooo";
|
||||
final List<String> receivedBuffers = Collections.synchronizedList(new ArrayList<String>());
|
||||
final List<String> receivedBuffers = Collections.synchronizedList(new ArrayList<>());
|
||||
doAnswer(new Answer<Void>() {
|
||||
@Override
|
||||
public Void answer(InvocationOnMock in) throws Throwable {
|
||||
|
@ -34,7 +34,7 @@ import static java.util.concurrent.TimeUnit.MILLISECONDS;
|
||||
* Channel handler that allows to easily access inbound messages.
|
||||
*/
|
||||
public class LastInboundHandler extends ChannelDuplexHandler {
|
||||
private final List<Object> queue = new ArrayList<Object>();
|
||||
private final List<Object> queue = new ArrayList<>();
|
||||
private final Consumer<ChannelHandlerContext> channelReadCompleteConsumer;
|
||||
private Throwable lastException;
|
||||
private ChannelHandlerContext ctx;
|
||||
|
@ -240,7 +240,7 @@ public class StreamBufferingEncoderTest {
|
||||
setMaxConcurrentStreams(5);
|
||||
|
||||
int streamId = 3;
|
||||
List<ChannelFuture> futures = new ArrayList<ChannelFuture>();
|
||||
List<ChannelFuture> futures = new ArrayList<>();
|
||||
for (int i = 0; i < 9; i++) {
|
||||
futures.add(encoderWriteHeaders(streamId, newPromise()));
|
||||
streamId += 2;
|
||||
|
@ -34,7 +34,7 @@ public enum MqttConnectReturnCode {
|
||||
private static final Map<Byte, MqttConnectReturnCode> VALUE_TO_CODE_MAP;
|
||||
|
||||
static {
|
||||
final Map<Byte, MqttConnectReturnCode> valueMap = new HashMap<Byte, MqttConnectReturnCode>();
|
||||
final Map<Byte, MqttConnectReturnCode> valueMap = new HashMap<>();
|
||||
for (MqttConnectReturnCode code: values()) {
|
||||
valueMap.put(code.byteValue, code);
|
||||
}
|
||||
|
@ -201,9 +201,9 @@ public final class MqttDecoder extends ReplayingDecoder<DecoderState> {
|
||||
case PINGRESP:
|
||||
case DISCONNECT:
|
||||
// Empty variable header
|
||||
return new Result<Object>(null, 0);
|
||||
return new Result<>(null, 0);
|
||||
}
|
||||
return new Result<Object>(null, 0); //should never reach here
|
||||
return new Result<>(null, 0); //should never reach here
|
||||
}
|
||||
|
||||
private static Result<MqttConnectVariableHeader> decodeConnectionVariableHeader(ByteBuf buffer) {
|
||||
@ -247,7 +247,7 @@ public final class MqttDecoder extends ReplayingDecoder<DecoderState> {
|
||||
willFlag,
|
||||
cleanSession,
|
||||
keepAlive.value);
|
||||
return new Result<MqttConnectVariableHeader>(mqttConnectVariableHeader, numberOfBytesConsumed);
|
||||
return new Result<>(mqttConnectVariableHeader, numberOfBytesConsumed);
|
||||
}
|
||||
|
||||
private static Result<MqttConnAckVariableHeader> decodeConnAckVariableHeader(ByteBuf buffer) {
|
||||
@ -256,12 +256,12 @@ public final class MqttDecoder extends ReplayingDecoder<DecoderState> {
|
||||
final int numberOfBytesConsumed = 2;
|
||||
final MqttConnAckVariableHeader mqttConnAckVariableHeader =
|
||||
new MqttConnAckVariableHeader(MqttConnectReturnCode.valueOf(returnCode), sessionPresent);
|
||||
return new Result<MqttConnAckVariableHeader>(mqttConnAckVariableHeader, numberOfBytesConsumed);
|
||||
return new Result<>(mqttConnAckVariableHeader, numberOfBytesConsumed);
|
||||
}
|
||||
|
||||
private static Result<MqttMessageIdVariableHeader> decodeMessageIdVariableHeader(ByteBuf buffer) {
|
||||
final Result<Integer> messageId = decodeMessageId(buffer);
|
||||
return new Result<MqttMessageIdVariableHeader>(
|
||||
return new Result<>(
|
||||
MqttMessageIdVariableHeader.from(messageId.value),
|
||||
messageId.numberOfBytesConsumed);
|
||||
}
|
||||
@ -283,7 +283,7 @@ public final class MqttDecoder extends ReplayingDecoder<DecoderState> {
|
||||
}
|
||||
final MqttPublishVariableHeader mqttPublishVariableHeader =
|
||||
new MqttPublishVariableHeader(decodedTopic.value, messageId);
|
||||
return new Result<MqttPublishVariableHeader>(mqttPublishVariableHeader, numberOfBytesConsumed);
|
||||
return new Result<>(mqttPublishVariableHeader, numberOfBytesConsumed);
|
||||
}
|
||||
|
||||
private static Result<Integer> decodeMessageId(ByteBuf buffer) {
|
||||
@ -326,7 +326,7 @@ public final class MqttDecoder extends ReplayingDecoder<DecoderState> {
|
||||
|
||||
default:
|
||||
// unknown payload , no byte consumed
|
||||
return new Result<Object>(null, 0);
|
||||
return new Result<>(null, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -368,13 +368,13 @@ public final class MqttDecoder extends ReplayingDecoder<DecoderState> {
|
||||
decodedWillMessage != null ? decodedWillMessage.value : null,
|
||||
decodedUserName != null ? decodedUserName.value : null,
|
||||
decodedPassword != null ? decodedPassword.value : null);
|
||||
return new Result<MqttConnectPayload>(mqttConnectPayload, numberOfBytesConsumed);
|
||||
return new Result<>(mqttConnectPayload, numberOfBytesConsumed);
|
||||
}
|
||||
|
||||
private static Result<MqttSubscribePayload> decodeSubscribePayload(
|
||||
ByteBuf buffer,
|
||||
int bytesRemainingInVariablePart) {
|
||||
final List<MqttTopicSubscription> subscribeTopics = new ArrayList<MqttTopicSubscription>();
|
||||
final List<MqttTopicSubscription> subscribeTopics = new ArrayList<>();
|
||||
int numberOfBytesConsumed = 0;
|
||||
while (numberOfBytesConsumed < bytesRemainingInVariablePart) {
|
||||
final Result<String> decodedTopicName = decodeString(buffer);
|
||||
@ -383,13 +383,13 @@ public final class MqttDecoder extends ReplayingDecoder<DecoderState> {
|
||||
numberOfBytesConsumed++;
|
||||
subscribeTopics.add(new MqttTopicSubscription(decodedTopicName.value, MqttQoS.valueOf(qos)));
|
||||
}
|
||||
return new Result<MqttSubscribePayload>(new MqttSubscribePayload(subscribeTopics), numberOfBytesConsumed);
|
||||
return new Result<>(new MqttSubscribePayload(subscribeTopics), numberOfBytesConsumed);
|
||||
}
|
||||
|
||||
private static Result<MqttSubAckPayload> decodeSubackPayload(
|
||||
ByteBuf buffer,
|
||||
int bytesRemainingInVariablePart) {
|
||||
final List<Integer> grantedQos = new ArrayList<Integer>();
|
||||
final List<Integer> grantedQos = new ArrayList<>();
|
||||
int numberOfBytesConsumed = 0;
|
||||
while (numberOfBytesConsumed < bytesRemainingInVariablePart) {
|
||||
int qos = buffer.readUnsignedByte();
|
||||
@ -399,27 +399,27 @@ public final class MqttDecoder extends ReplayingDecoder<DecoderState> {
|
||||
numberOfBytesConsumed++;
|
||||
grantedQos.add(qos);
|
||||
}
|
||||
return new Result<MqttSubAckPayload>(new MqttSubAckPayload(grantedQos), numberOfBytesConsumed);
|
||||
return new Result<>(new MqttSubAckPayload(grantedQos), numberOfBytesConsumed);
|
||||
}
|
||||
|
||||
private static Result<MqttUnsubscribePayload> decodeUnsubscribePayload(
|
||||
ByteBuf buffer,
|
||||
int bytesRemainingInVariablePart) {
|
||||
final List<String> unsubscribeTopics = new ArrayList<String>();
|
||||
final List<String> unsubscribeTopics = new ArrayList<>();
|
||||
int numberOfBytesConsumed = 0;
|
||||
while (numberOfBytesConsumed < bytesRemainingInVariablePart) {
|
||||
final Result<String> decodedTopicName = decodeString(buffer);
|
||||
numberOfBytesConsumed += decodedTopicName.numberOfBytesConsumed;
|
||||
unsubscribeTopics.add(decodedTopicName.value);
|
||||
}
|
||||
return new Result<MqttUnsubscribePayload>(
|
||||
return new Result<>(
|
||||
new MqttUnsubscribePayload(unsubscribeTopics),
|
||||
numberOfBytesConsumed);
|
||||
}
|
||||
|
||||
private static Result<ByteBuf> decodePublishPayload(ByteBuf buffer, int bytesRemainingInVariablePart) {
|
||||
ByteBuf b = buffer.readRetainedSlice(bytesRemainingInVariablePart);
|
||||
return new Result<ByteBuf>(b, bytesRemainingInVariablePart);
|
||||
return new Result<>(b, bytesRemainingInVariablePart);
|
||||
}
|
||||
|
||||
private static Result<String> decodeString(ByteBuf buffer) {
|
||||
@ -433,12 +433,12 @@ public final class MqttDecoder extends ReplayingDecoder<DecoderState> {
|
||||
if (size < minBytes || size > maxBytes) {
|
||||
buffer.skipBytes(size);
|
||||
numberOfBytesConsumed += size;
|
||||
return new Result<String>(null, numberOfBytesConsumed);
|
||||
return new Result<>(null, numberOfBytesConsumed);
|
||||
}
|
||||
String s = buffer.toString(buffer.readerIndex(), size, CharsetUtil.UTF_8);
|
||||
buffer.skipBytes(size);
|
||||
numberOfBytesConsumed += size;
|
||||
return new Result<String>(s, numberOfBytesConsumed);
|
||||
return new Result<>(s, numberOfBytesConsumed);
|
||||
}
|
||||
|
||||
private static Result<byte[]> decodeByteArray(ByteBuf buffer) {
|
||||
@ -446,7 +446,7 @@ public final class MqttDecoder extends ReplayingDecoder<DecoderState> {
|
||||
int size = decodedSize.value;
|
||||
byte[] bytes = new byte[size];
|
||||
buffer.readBytes(bytes);
|
||||
return new Result<byte[]>(bytes, decodedSize.numberOfBytesConsumed + size);
|
||||
return new Result<>(bytes, decodedSize.numberOfBytesConsumed + size);
|
||||
}
|
||||
|
||||
private static Result<Integer> decodeMsbLsb(ByteBuf buffer) {
|
||||
@ -461,7 +461,7 @@ public final class MqttDecoder extends ReplayingDecoder<DecoderState> {
|
||||
if (result < min || result > max) {
|
||||
result = -1;
|
||||
}
|
||||
return new Result<Integer>(result, numberOfBytesConsumed);
|
||||
return new Result<>(result, numberOfBytesConsumed);
|
||||
}
|
||||
|
||||
private static final class Result<T> {
|
||||
|
@ -200,7 +200,7 @@ public final class MqttMessageBuilders {
|
||||
|
||||
public SubscribeBuilder addSubscription(MqttQoS qos, String topic) {
|
||||
if (subscriptions == null) {
|
||||
subscriptions = new ArrayList<MqttTopicSubscription>(5);
|
||||
subscriptions = new ArrayList<>(5);
|
||||
}
|
||||
subscriptions.add(new MqttTopicSubscription(topic, qos));
|
||||
return this;
|
||||
@ -230,7 +230,7 @@ public final class MqttMessageBuilders {
|
||||
|
||||
public UnsubscribeBuilder addTopicFilter(String topic) {
|
||||
if (topicFilters == null) {
|
||||
topicFilters = new ArrayList<String>(5);
|
||||
topicFilters = new ArrayList<>(5);
|
||||
}
|
||||
topicFilters.add(topic);
|
||||
return this;
|
||||
|
@ -34,7 +34,7 @@ public class MqttSubAckPayload {
|
||||
throw new NullPointerException("grantedQoSLevels");
|
||||
}
|
||||
|
||||
List<Integer> list = new ArrayList<Integer>(grantedQoSLevels.length);
|
||||
List<Integer> list = new ArrayList<>(grantedQoSLevels.length);
|
||||
for (int v: grantedQoSLevels) {
|
||||
list.add(v);
|
||||
}
|
||||
@ -45,7 +45,7 @@ public class MqttSubAckPayload {
|
||||
if (grantedQoSLevels == null) {
|
||||
throw new NullPointerException("grantedQoSLevels");
|
||||
}
|
||||
List<Integer> list = new ArrayList<Integer>();
|
||||
List<Integer> list = new ArrayList<>();
|
||||
for (Integer v: grantedQoSLevels) {
|
||||
if (v == null) {
|
||||
break;
|
||||
|
@ -74,7 +74,7 @@ public class MqttCodecTest {
|
||||
final MqttConnectMessage message = createConnectMessage(MqttVersion.MQTT_3_1);
|
||||
ByteBuf byteBuf = MqttEncoder.doEncode(ALLOCATOR, message);
|
||||
|
||||
final List<Object> out = new LinkedList<Object>();
|
||||
final List<Object> out = new LinkedList<>();
|
||||
mqttDecoder.decode(ctx, byteBuf, out);
|
||||
|
||||
assertEquals("Expected one object but got " + out.size(), 1, out.size());
|
||||
@ -91,7 +91,7 @@ public class MqttCodecTest {
|
||||
final MqttConnectMessage message = createConnectMessage(MqttVersion.MQTT_3_1_1);
|
||||
ByteBuf byteBuf = MqttEncoder.doEncode(ALLOCATOR, message);
|
||||
|
||||
final List<Object> out = new LinkedList<Object>();
|
||||
final List<Object> out = new LinkedList<>();
|
||||
mqttDecoder.decode(ctx, byteBuf, out);
|
||||
|
||||
assertEquals("Expected one object but got " + out.size(), 1, out.size());
|
||||
@ -110,7 +110,7 @@ public class MqttCodecTest {
|
||||
try {
|
||||
// Set the reserved flag in the CONNECT Packet to 1
|
||||
byteBuf.setByte(9, byteBuf.getByte(9) | 0x1);
|
||||
final List<Object> out = new LinkedList<Object>();
|
||||
final List<Object> out = new LinkedList<>();
|
||||
mqttDecoder.decode(ctx, byteBuf, out);
|
||||
|
||||
assertEquals("Expected one object but got " + out.size(), 1, out.size());
|
||||
@ -141,7 +141,7 @@ public class MqttCodecTest {
|
||||
final MqttConnAckMessage message = createConnAckMessage();
|
||||
ByteBuf byteBuf = MqttEncoder.doEncode(ALLOCATOR, message);
|
||||
|
||||
final List<Object> out = new LinkedList<Object>();
|
||||
final List<Object> out = new LinkedList<>();
|
||||
mqttDecoder.decode(ctx, byteBuf, out);
|
||||
|
||||
assertEquals("Expected one object but got " + out.size(), 1, out.size());
|
||||
@ -156,7 +156,7 @@ public class MqttCodecTest {
|
||||
final MqttPublishMessage message = createPublishMessage();
|
||||
ByteBuf byteBuf = MqttEncoder.doEncode(ALLOCATOR, message);
|
||||
|
||||
final List<Object> out = new LinkedList<Object>();
|
||||
final List<Object> out = new LinkedList<>();
|
||||
mqttDecoder.decode(ctx, byteBuf, out);
|
||||
|
||||
assertEquals("Expected one object but got " + out.size(), 1, out.size());
|
||||
@ -192,7 +192,7 @@ public class MqttCodecTest {
|
||||
final MqttSubscribeMessage message = createSubscribeMessage();
|
||||
ByteBuf byteBuf = MqttEncoder.doEncode(ALLOCATOR, message);
|
||||
|
||||
final List<Object> out = new LinkedList<Object>();
|
||||
final List<Object> out = new LinkedList<>();
|
||||
mqttDecoder.decode(ctx, byteBuf, out);
|
||||
|
||||
assertEquals("Expected one object but got " + out.size(), 1, out.size());
|
||||
@ -208,7 +208,7 @@ public class MqttCodecTest {
|
||||
final MqttSubAckMessage message = createSubAckMessage();
|
||||
ByteBuf byteBuf = MqttEncoder.doEncode(ALLOCATOR, message);
|
||||
|
||||
final List<Object> out = new LinkedList<Object>();
|
||||
final List<Object> out = new LinkedList<>();
|
||||
mqttDecoder.decode(ctx, byteBuf, out);
|
||||
|
||||
assertEquals("Expected one object but got " + out.size(), 1, out.size());
|
||||
@ -230,7 +230,7 @@ public class MqttCodecTest {
|
||||
|
||||
ByteBuf byteBuf = MqttEncoder.doEncode(ALLOCATOR, message);
|
||||
|
||||
List<Object> out = new LinkedList<Object>();
|
||||
List<Object> out = new LinkedList<>();
|
||||
mqttDecoder.decode(ctx, byteBuf, out);
|
||||
|
||||
assertEquals("Expected one object but got " + out.size(), 1, out.size());
|
||||
@ -248,7 +248,7 @@ public class MqttCodecTest {
|
||||
final MqttUnsubscribeMessage message = createUnsubscribeMessage();
|
||||
ByteBuf byteBuf = MqttEncoder.doEncode(ALLOCATOR, message);
|
||||
|
||||
final List<Object> out = new LinkedList<Object>();
|
||||
final List<Object> out = new LinkedList<>();
|
||||
mqttDecoder.decode(ctx, byteBuf, out);
|
||||
|
||||
assertEquals("Expected one object but got " + out.size(), 1, out.size());
|
||||
@ -287,7 +287,7 @@ public class MqttCodecTest {
|
||||
try {
|
||||
// setting an invalid message type (15, reserved and forbidden by MQTT 3.1.1 spec)
|
||||
byteBuf.setByte(0, 0xF0);
|
||||
final List<Object> out = new LinkedList<Object>();
|
||||
final List<Object> out = new LinkedList<>();
|
||||
mqttDecoder.decode(ctx, byteBuf, out);
|
||||
|
||||
assertEquals("Expected one object but got " + out.size(), 1, out.size());
|
||||
@ -308,7 +308,7 @@ public class MqttCodecTest {
|
||||
ByteBuf byteBuf = MqttEncoder.doEncode(ALLOCATOR, message);
|
||||
|
||||
try {
|
||||
final List<Object> out = new LinkedList<Object>();
|
||||
final List<Object> out = new LinkedList<>();
|
||||
mqttDecoderLimitedMessageSize.decode(ctx, byteBuf, out);
|
||||
|
||||
assertEquals("Expected one object but got " + out.size(), 1, out.size());
|
||||
@ -330,7 +330,7 @@ public class MqttCodecTest {
|
||||
ByteBuf byteBuf = MqttEncoder.doEncode(ALLOCATOR, message);
|
||||
|
||||
try {
|
||||
final List<Object> out = new LinkedList<Object>();
|
||||
final List<Object> out = new LinkedList<>();
|
||||
mqttDecoderLimitedMessageSize.decode(ctx, byteBuf, out);
|
||||
|
||||
assertEquals("Expected one object but got " + out.size(), 1, out.size());
|
||||
@ -352,7 +352,7 @@ public class MqttCodecTest {
|
||||
ByteBuf byteBuf = MqttEncoder.doEncode(ALLOCATOR, message);
|
||||
|
||||
try {
|
||||
final List<Object> out = new LinkedList<Object>();
|
||||
final List<Object> out = new LinkedList<>();
|
||||
mqttDecoderLimitedMessageSize.decode(ctx, byteBuf, out);
|
||||
|
||||
assertEquals("Expected one object but got " + out.size(), 1, out.size());
|
||||
@ -371,7 +371,7 @@ public class MqttCodecTest {
|
||||
ByteBuf byteBuf = MqttEncoder.doEncode(ALLOCATOR, message);
|
||||
|
||||
try {
|
||||
final List<Object> out = new LinkedList<Object>();
|
||||
final List<Object> out = new LinkedList<>();
|
||||
mqttDecoderLimitedMessageSize.decode(ctx, byteBuf, out);
|
||||
|
||||
assertEquals("Expected one object but got " + out.size(), 1, out.size());
|
||||
@ -393,7 +393,7 @@ public class MqttCodecTest {
|
||||
ByteBuf byteBuf = MqttEncoder.doEncode(ALLOCATOR, message);
|
||||
|
||||
try {
|
||||
final List<Object> out = new LinkedList<Object>();
|
||||
final List<Object> out = new LinkedList<>();
|
||||
mqttDecoderLimitedMessageSize.decode(ctx, byteBuf, out);
|
||||
|
||||
assertEquals("Expected one object but got " + out.size(), 1, out.size());
|
||||
@ -414,7 +414,7 @@ public class MqttCodecTest {
|
||||
ByteBuf byteBuf = MqttEncoder.doEncode(ALLOCATOR, message);
|
||||
|
||||
try {
|
||||
final List<Object> out = new LinkedList<Object>();
|
||||
final List<Object> out = new LinkedList<>();
|
||||
mqttDecoderLimitedMessageSize.decode(ctx, byteBuf, out);
|
||||
|
||||
assertEquals("Expected one object but got " + out.size(), 1, out.size());
|
||||
@ -435,7 +435,7 @@ public class MqttCodecTest {
|
||||
ByteBuf byteBuf = MqttEncoder.doEncode(ALLOCATOR, message);
|
||||
|
||||
try {
|
||||
final List<Object> out = new LinkedList<Object>();
|
||||
final List<Object> out = new LinkedList<>();
|
||||
mqttDecoderLimitedMessageSize.decode(ctx, byteBuf, out);
|
||||
|
||||
assertEquals("Expected one object but got " + out.size(), 1, out.size());
|
||||
@ -454,7 +454,7 @@ public class MqttCodecTest {
|
||||
MqttMessage message = createMessageWithFixedHeader(messageType);
|
||||
ByteBuf byteBuf = MqttEncoder.doEncode(ALLOCATOR, message);
|
||||
|
||||
final List<Object> out = new LinkedList<Object>();
|
||||
final List<Object> out = new LinkedList<>();
|
||||
mqttDecoder.decode(ctx, byteBuf, out);
|
||||
|
||||
assertEquals("Expected one object but got " + out.size(), 1, out.size());
|
||||
@ -469,7 +469,7 @@ public class MqttCodecTest {
|
||||
|
||||
ByteBuf byteBuf = MqttEncoder.doEncode(ALLOCATOR, message);
|
||||
|
||||
final List<Object> out = new LinkedList<Object>();
|
||||
final List<Object> out = new LinkedList<>();
|
||||
mqttDecoder.decode(ctx, byteBuf, out);
|
||||
|
||||
assertEquals("Expected one object but got " + out.size(), 1, out.size());
|
||||
@ -541,7 +541,7 @@ public class MqttCodecTest {
|
||||
new MqttFixedHeader(MqttMessageType.SUBSCRIBE, false, MqttQoS.AT_LEAST_ONCE, true, 0);
|
||||
MqttMessageIdVariableHeader mqttMessageIdVariableHeader = MqttMessageIdVariableHeader.from(12345);
|
||||
|
||||
List<MqttTopicSubscription> topicSubscriptions = new LinkedList<MqttTopicSubscription>();
|
||||
List<MqttTopicSubscription> topicSubscriptions = new LinkedList<>();
|
||||
topicSubscriptions.add(new MqttTopicSubscription("/abc", MqttQoS.AT_LEAST_ONCE));
|
||||
topicSubscriptions.add(new MqttTopicSubscription("/def", MqttQoS.AT_LEAST_ONCE));
|
||||
topicSubscriptions.add(new MqttTopicSubscription("/xyz", MqttQoS.EXACTLY_ONCE));
|
||||
@ -563,7 +563,7 @@ public class MqttCodecTest {
|
||||
new MqttFixedHeader(MqttMessageType.UNSUBSCRIBE, false, MqttQoS.AT_LEAST_ONCE, true, 0);
|
||||
MqttMessageIdVariableHeader mqttMessageIdVariableHeader = MqttMessageIdVariableHeader.from(12345);
|
||||
|
||||
List<String> topics = new LinkedList<String>();
|
||||
List<String> topics = new LinkedList<>();
|
||||
topics.add("/abc");
|
||||
topics.add("/def");
|
||||
topics.add("/xyz");
|
||||
|
@ -83,8 +83,8 @@ public final class FixedRedisMessagePool implements RedisMessagePool {
|
||||
* Creates a {@link FixedRedisMessagePool} instance.
|
||||
*/
|
||||
private FixedRedisMessagePool() {
|
||||
byteBufToSimpleStrings = new HashMap<ByteBuf, SimpleStringRedisMessage>(DEFAULT_SIMPLE_STRINGS.length, 1.0f);
|
||||
stringToSimpleStrings = new HashMap<String, SimpleStringRedisMessage>(DEFAULT_SIMPLE_STRINGS.length, 1.0f);
|
||||
byteBufToSimpleStrings = new HashMap<>(DEFAULT_SIMPLE_STRINGS.length, 1.0f);
|
||||
stringToSimpleStrings = new HashMap<>(DEFAULT_SIMPLE_STRINGS.length, 1.0f);
|
||||
for (String message : DEFAULT_SIMPLE_STRINGS) {
|
||||
ByteBuf key = Unpooled.unmodifiableBuffer(
|
||||
Unpooled.unreleasableBuffer(Unpooled.wrappedBuffer(message.getBytes(CharsetUtil.UTF_8))));
|
||||
@ -93,8 +93,8 @@ public final class FixedRedisMessagePool implements RedisMessagePool {
|
||||
stringToSimpleStrings.put(message, cached);
|
||||
}
|
||||
|
||||
byteBufToErrors = new HashMap<ByteBuf, ErrorRedisMessage>(DEFAULT_ERRORS.length, 1.0f);
|
||||
stringToErrors = new HashMap<String, ErrorRedisMessage>(DEFAULT_ERRORS.length, 1.0f);
|
||||
byteBufToErrors = new HashMap<>(DEFAULT_ERRORS.length, 1.0f);
|
||||
stringToErrors = new HashMap<>(DEFAULT_ERRORS.length, 1.0f);
|
||||
for (String message : DEFAULT_ERRORS) {
|
||||
ByteBuf key = Unpooled.unmodifiableBuffer(
|
||||
Unpooled.unreleasableBuffer(Unpooled.wrappedBuffer(message.getBytes(CharsetUtil.UTF_8))));
|
||||
@ -103,7 +103,7 @@ public final class FixedRedisMessagePool implements RedisMessagePool {
|
||||
stringToErrors.put(message, cached);
|
||||
}
|
||||
|
||||
byteBufToIntegers = new HashMap<ByteBuf, IntegerRedisMessage>(SIZE_CACHED_INTEGER_NUMBER, 1.0f);
|
||||
byteBufToIntegers = new HashMap<>(SIZE_CACHED_INTEGER_NUMBER, 1.0f);
|
||||
longToIntegers = new LongObjectHashMap<IntegerRedisMessage>(SIZE_CACHED_INTEGER_NUMBER, 1.0f);
|
||||
longToByteBufs = new LongObjectHashMap<byte[]>(SIZE_CACHED_INTEGER_NUMBER, 1.0f);
|
||||
for (long value = MIN_CACHED_INTEGER_NUMBER; value < MAX_CACHED_INTEGER_NUMBER; value++) {
|
||||
|
@ -33,7 +33,7 @@ import java.util.List;
|
||||
@UnstableApi
|
||||
public final class RedisArrayAggregator extends MessageToMessageDecoder<RedisMessage> {
|
||||
|
||||
private final Deque<AggregateState> depths = new ArrayDeque<AggregateState>(4);
|
||||
private final Deque<AggregateState> depths = new ArrayDeque<>(4);
|
||||
|
||||
@Override
|
||||
protected void decode(ChannelHandlerContext ctx, RedisMessage msg, List<Object> out) throws Exception {
|
||||
@ -87,7 +87,7 @@ public final class RedisArrayAggregator extends MessageToMessageDecoder<RedisMes
|
||||
private final List<RedisMessage> children;
|
||||
AggregateState(int length) {
|
||||
this.length = length;
|
||||
this.children = new ArrayList<RedisMessage>(length);
|
||||
this.children = new ArrayList<>(length);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -127,7 +127,7 @@ public class RedisEncoderTest {
|
||||
|
||||
@Test
|
||||
public void shouldEncodeSimpleArray() {
|
||||
List<RedisMessage> children = new ArrayList<RedisMessage>();
|
||||
List<RedisMessage> children = new ArrayList<>();
|
||||
children.add(new FullBulkStringRedisMessage(byteBufOf("foo").retain()));
|
||||
children.add(new FullBulkStringRedisMessage(byteBufOf("bar").retain()));
|
||||
RedisMessage msg = new ArrayRedisMessage(children);
|
||||
@ -166,10 +166,10 @@ public class RedisEncoderTest {
|
||||
|
||||
@Test
|
||||
public void shouldEncodeNestedArray() {
|
||||
List<RedisMessage> grandChildren = new ArrayList<RedisMessage>();
|
||||
List<RedisMessage> grandChildren = new ArrayList<>();
|
||||
grandChildren.add(new FullBulkStringRedisMessage(byteBufOf("bar")));
|
||||
grandChildren.add(new IntegerRedisMessage(-1234L));
|
||||
List<RedisMessage> children = new ArrayList<RedisMessage>();
|
||||
List<RedisMessage> children = new ArrayList<>();
|
||||
children.add(new SimpleStringRedisMessage("foo"));
|
||||
children.add(new ArrayRedisMessage(grandChildren));
|
||||
RedisMessage msg = new ArrayRedisMessage(children);
|
||||
|
@ -41,7 +41,7 @@ public final class SmtpCommand {
|
||||
public static final SmtpCommand HELP = new SmtpCommand(AsciiString.cached("HELP"));
|
||||
public static final SmtpCommand QUIT = new SmtpCommand(AsciiString.cached("QUIT"));
|
||||
|
||||
private static final Map<String, SmtpCommand> COMMANDS = new HashMap<String, SmtpCommand>();
|
||||
private static final Map<String, SmtpCommand> COMMANDS = new HashMap<>();
|
||||
static {
|
||||
COMMANDS.put(EHLO.name().toString(), EHLO);
|
||||
COMMANDS.put(HELO.name().toString(), HELO);
|
||||
|
@ -92,7 +92,7 @@ public final class SmtpRequests {
|
||||
return new DefaultSmtpRequest(SmtpCommand.MAIL,
|
||||
sender != null ? "FROM:<" + sender + '>' : FROM_NULL_SENDER);
|
||||
} else {
|
||||
List<CharSequence> params = new ArrayList<CharSequence>(mailParameters.length + 1);
|
||||
List<CharSequence> params = new ArrayList<>(mailParameters.length + 1);
|
||||
params.add(sender != null? "FROM:<" + sender + '>' : FROM_NULL_SENDER);
|
||||
for (CharSequence param : mailParameters) {
|
||||
params.add(param);
|
||||
@ -109,7 +109,7 @@ public final class SmtpRequests {
|
||||
if (rcptParameters == null || rcptParameters.length == 0) {
|
||||
return new DefaultSmtpRequest(SmtpCommand.RCPT, "TO:<" + recipient + '>');
|
||||
} else {
|
||||
List<CharSequence> params = new ArrayList<CharSequence>(rcptParameters.length + 1);
|
||||
List<CharSequence> params = new ArrayList<>(rcptParameters.length + 1);
|
||||
params.add("TO:<" + recipient + '>');
|
||||
for (CharSequence param : rcptParameters) {
|
||||
params.add(param);
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user