diff --git a/buffer/src/main/java/io/netty/buffer/CompositeByteBuf.java b/buffer/src/main/java/io/netty/buffer/CompositeByteBuf.java index 4fcc732147..f582da293c 100644 --- a/buffer/src/main/java/io/netty/buffer/CompositeByteBuf.java +++ b/buffer/src/main/java/io/netty/buffer/CompositeByteBuf.java @@ -637,7 +637,7 @@ public class CompositeByteBuf extends AbstractReferenceCountedByteBuf implements return Collections.singletonList(slice); } - List sliceList = new ArrayList(componentCount - componentId); + List sliceList = new ArrayList<>(componentCount - componentId); sliceList.add(slice); // Add all the slices until there is nothing more left and then return the List. diff --git a/buffer/src/main/java/io/netty/buffer/PoolArena.java b/buffer/src/main/java/io/netty/buffer/PoolArena.java index 8ef5d76ea8..46374a8ab8 100644 --- a/buffer/src/main/java/io/netty/buffer/PoolArena.java +++ b/buffer/src/main/java/io/netty/buffer/PoolArena.java @@ -128,7 +128,7 @@ abstract class PoolArena implements PoolArenaMetric { } private PoolSubpage newSubpagePoolHead(int pageSize) { - PoolSubpage head = new PoolSubpage(pageSize); + PoolSubpage head = new PoolSubpage<>(pageSize); head.prev = head; head.next = head; return head; diff --git a/buffer/src/main/java/io/netty/buffer/PoolChunk.java b/buffer/src/main/java/io/netty/buffer/PoolChunk.java index 0a19a5a1d4..abcabdc453 100644 --- a/buffer/src/main/java/io/netty/buffer/PoolChunk.java +++ b/buffer/src/main/java/io/netty/buffer/PoolChunk.java @@ -173,7 +173,7 @@ final class PoolChunk implements PoolChunkMetric { } subpages = newSubpageArray(maxSubpageAllocs); - cachedNioBuffers = new ArrayDeque(8); + cachedNioBuffers = new ArrayDeque<>(8); } /** Creates a special chunk that is not pooled. */ @@ -355,7 +355,7 @@ final class PoolChunk implements PoolChunkMetric { int subpageIdx = subpageIdx(id); PoolSubpage subpage = subpages[subpageIdx]; if (subpage == null) { - subpage = new PoolSubpage(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); diff --git a/buffer/src/main/java/io/netty/buffer/PoolChunkList.java b/buffer/src/main/java/io/netty/buffer/PoolChunkList.java index e610be8e9b..5302be5421 100644 --- a/buffer/src/main/java/io/netty/buffer/PoolChunkList.java +++ b/buffer/src/main/java/io/netty/buffer/PoolChunkList.java @@ -192,7 +192,7 @@ final class PoolChunkList implements PoolChunkListMetric { if (head == null) { return EMPTY_METRICS; } - List metrics = new ArrayList(); + List metrics = new ArrayList<>(); for (PoolChunk cur = head;;) { metrics.add(cur); cur = cur.next; diff --git a/buffer/src/main/java/io/netty/buffer/PoolThreadCache.java b/buffer/src/main/java/io/netty/buffer/PoolThreadCache.java index de2a9be060..09b1aa12b0 100644 --- a/buffer/src/main/java/io/netty/buffer/PoolThreadCache.java +++ b/buffer/src/main/java/io/netty/buffer/PoolThreadCache.java @@ -126,7 +126,7 @@ final class PoolThreadCache { MemoryRegionCache[] cache = new MemoryRegionCache[numCaches]; for (int i = 0; i < cache.length; i++) { // TODO: maybe use cacheSize / cache.length - cache[i] = new SubPageMemoryRegionCache(cacheSize, sizeClass); + cache[i] = new SubPageMemoryRegionCache<>(cacheSize, sizeClass); } return cache; } else { @@ -143,7 +143,7 @@ final class PoolThreadCache { @SuppressWarnings("unchecked") MemoryRegionCache[] cache = new MemoryRegionCache[arraySize]; for (int i = 0; i < cache.length; i++) { - cache[i] = new NormalMemoryRegionCache(cacheSize); + cache[i] = new NormalMemoryRegionCache<>(cacheSize); } return cache; } else { diff --git a/buffer/src/main/java/io/netty/buffer/PooledByteBufAllocator.java b/buffer/src/main/java/io/netty/buffer/PooledByteBufAllocator.java index de6eee1d54..f79f83d221 100644 --- a/buffer/src/main/java/io/netty/buffer/PooledByteBufAllocator.java +++ b/buffer/src/main/java/io/netty/buffer/PooledByteBufAllocator.java @@ -239,7 +239,7 @@ public class PooledByteBufAllocator extends AbstractByteBufAllocator implements if (nHeapArena > 0) { heapArenas = newArenaArray(nHeapArena); - List metrics = new ArrayList(heapArenas.length); + List 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 metrics = new ArrayList(directArenas.length); + List 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); diff --git a/buffer/src/test/java/io/netty/buffer/AbstractByteBufTest.java b/buffer/src/test/java/io/netty/buffer/AbstractByteBufTest.java index 082c9a89d5..24fbe25df7 100644 --- a/buffer/src/test/java/io/netty/buffer/AbstractByteBufTest.java +++ b/buffer/src/test/java/io/netty/buffer/AbstractByteBufTest.java @@ -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 errorRef = new AtomicReference(); - List threads = new ArrayList(); + final AtomicReference errorRef = new AtomicReference<>(); + List 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 set = new HashSet(); + Set 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 cause = new AtomicReference(); + final AtomicReference cause = new AtomicReference<>(); final CountDownLatch latch = new CountDownLatch(60000); final CyclicBarrier barrier = new CyclicBarrier(11); for (int i = 0; i < 10; i++) { diff --git a/buffer/src/test/java/io/netty/buffer/AbstractCompositeByteBufTest.java b/buffer/src/test/java/io/netty/buffer/AbstractCompositeByteBufTest.java index 92374bcf8b..c5dac64aba 100644 --- a/buffer/src/test/java/io/netty/buffer/AbstractCompositeByteBufTest.java +++ b/buffer/src/test/java/io/netty/buffer/AbstractCompositeByteBufTest.java @@ -67,7 +67,7 @@ public abstract class AbstractCompositeByteBufTest extends AbstractByteBufTest { protected ByteBuf newBuffer(int length, int maxCapacity) { Assume.assumeTrue(maxCapacity == Integer.MAX_VALUE); - List buffers = new ArrayList(); + List 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 components = new ArrayList(); + List components = new ArrayList<>(); Collections.addAll(components, c1, c2, c3); buf.addComponents(components); diff --git a/buffer/src/test/java/io/netty/buffer/ByteBufUtilTest.java b/buffer/src/test/java/io/netty/buffer/ByteBufUtilTest.java index 828c874e6b..272933dea2 100644 --- a/buffer/src/test/java/io/netty/buffer/ByteBufUtilTest.java +++ b/buffer/src/test/java/io/netty/buffer/ByteBufUtilTest.java @@ -677,8 +677,8 @@ public class ByteBufUtilTest { try { final AtomicInteger counter = new AtomicInteger(60000); - final AtomicReference errorRef = new AtomicReference(); - List threads = new ArrayList(); + final AtomicReference errorRef = new AtomicReference<>(); + List threads = new ArrayList<>(); for (int i = 0; i < 10; i++) { Thread thread = new Thread(new Runnable() { @Override diff --git a/buffer/src/test/java/io/netty/buffer/PooledByteBufAllocatorTest.java b/buffer/src/test/java/io/netty/buffer/PooledByteBufAllocatorTest.java index 495bb76540..de004fc7a1 100644 --- a/buffer/src/test/java/io/netty/buffer/PooledByteBufAllocatorTest.java +++ b/buffer/src/test/java/io/netty/buffer/PooledByteBufAllocatorTest.java @@ -416,7 +416,7 @@ public class PooledByteBufAllocatorTest extends AbstractByteBufAllocatorTest threads = new ArrayList(); + List 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 buffers = new ConcurrentLinkedQueue(); + private final Queue buffers = new ConcurrentLinkedQueue<>(); private final ByteBufAllocator allocator; - private final AtomicReference finish = new AtomicReference(); + private final AtomicReference finish = new AtomicReference<>(); public AllocationThread(ByteBufAllocator allocator) { this.allocator = allocator; diff --git a/buffer/src/test/java/io/netty/buffer/SimpleLeakAwareByteBufTest.java b/buffer/src/test/java/io/netty/buffer/SimpleLeakAwareByteBufTest.java index 66ca89fad3..7aaeec3de1 100644 --- a/buffer/src/test/java/io/netty/buffer/SimpleLeakAwareByteBufTest.java +++ b/buffer/src/test/java/io/netty/buffer/SimpleLeakAwareByteBufTest.java @@ -28,7 +28,7 @@ import static org.junit.Assert.assertTrue; public class SimpleLeakAwareByteBufTest extends BigEndianHeapByteBufTest { private final Class clazz = leakClass(); - private final Queue> trackers = new ArrayDeque>(); + private final Queue> 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 tracker = new NoopResourceLeakTracker(); + NoopResourceLeakTracker tracker = new NoopResourceLeakTracker<>(); ByteBuf leakAwareBuf = wrap(buffer, tracker); trackers.add(tracker); return leakAwareBuf; diff --git a/buffer/src/test/java/io/netty/buffer/SimpleLeakAwareCompositeByteBufTest.java b/buffer/src/test/java/io/netty/buffer/SimpleLeakAwareCompositeByteBufTest.java index 713fe728a4..580bcdbb72 100644 --- a/buffer/src/test/java/io/netty/buffer/SimpleLeakAwareCompositeByteBufTest.java +++ b/buffer/src/test/java/io/netty/buffer/SimpleLeakAwareCompositeByteBufTest.java @@ -29,11 +29,11 @@ import static org.junit.Assert.assertTrue; public class SimpleLeakAwareCompositeByteBufTest extends WrappedCompositeByteBufTest { private final Class clazz = leakClass(); - private final Queue> trackers = new ArrayDeque>(); + private final Queue> trackers = new ArrayDeque<>(); @Override protected final WrappedCompositeByteBuf wrap(CompositeByteBuf buffer) { - NoopResourceLeakTracker tracker = new NoopResourceLeakTracker(); + NoopResourceLeakTracker tracker = new NoopResourceLeakTracker<>(); WrappedCompositeByteBuf leakAwareBuf = wrap(buffer, tracker); trackers.add(tracker); return leakAwareBuf; diff --git a/buffer/src/test/java/io/netty/buffer/UnpooledTest.java b/buffer/src/test/java/io/netty/buffer/UnpooledTest.java index f7fd30ba91..458f51eb5b 100644 --- a/buffer/src/test/java/io/netty/buffer/UnpooledTest.java +++ b/buffer/src/test/java/io/netty/buffer/UnpooledTest.java @@ -60,7 +60,7 @@ public class UnpooledTest { @Test public void testHashCode() { - Map map = new LinkedHashMap(); + Map 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 expected = new ArrayList(); + List 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})); diff --git a/codec-dns/src/main/java/io/netty/handler/codec/dns/AbstractDnsMessage.java b/codec-dns/src/main/java/io/netty/handler/codec/dns/AbstractDnsMessage.java index 5d0a3933e0..f7f2f12f8a 100644 --- a/codec-dns/src/main/java/io/netty/handler/codec/dns/AbstractDnsMessage.java +++ b/codec-dns/src/main/java/io/netty/handler/codec/dns/AbstractDnsMessage.java @@ -469,6 +469,6 @@ public abstract class AbstractDnsMessage extends AbstractReferenceCounted implem } private static ArrayList newRecordList() { - return new ArrayList(2); + return new ArrayList<>(2); } } diff --git a/codec-dns/src/main/java/io/netty/handler/codec/dns/DnsRecordType.java b/codec-dns/src/main/java/io/netty/handler/codec/dns/DnsRecordType.java index 1c5f79b8d7..31e8443f06 100644 --- a/codec-dns/src/main/java/io/netty/handler/codec/dns/DnsRecordType.java +++ b/codec-dns/src/main/java/io/netty/handler/codec/dns/DnsRecordType.java @@ -303,7 +303,7 @@ public class DnsRecordType implements Comparable { */ public static final DnsRecordType DLV = new DnsRecordType(0x8001, "DLV"); - private static final Map BY_NAME = new HashMap(); + private static final Map BY_NAME = new HashMap<>(); private static final IntObjectHashMap BY_TYPE = new IntObjectHashMap(); private static final String EXPECTED; diff --git a/codec-dns/src/test/java/io/netty/handler/codec/dns/DnsQueryTest.java b/codec-dns/src/test/java/io/netty/handler/codec/dns/DnsQueryTest.java index d322f61a01..a14427db58 100644 --- a/codec-dns/src/test/java/io/netty/handler/codec/dns/DnsQueryTest.java +++ b/codec-dns/src/test/java/io/netty/handler/codec/dns/DnsQueryTest.java @@ -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 queries = new ArrayList(5); + List 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))); diff --git a/codec-dns/src/test/java/io/netty/handler/codec/dns/DnsRecordTypeTest.java b/codec-dns/src/test/java/io/netty/handler/codec/dns/DnsRecordTypeTest.java index aeeab95b04..d261e6e58e 100644 --- a/codec-dns/src/test/java/io/netty/handler/codec/dns/DnsRecordTypeTest.java +++ b/codec-dns/src/test/java/io/netty/handler/codec/dns/DnsRecordTypeTest.java @@ -28,7 +28,7 @@ import static org.junit.Assert.*; public class DnsRecordTypeTest { private static List allTypes() throws Exception { - List result = new ArrayList(); + List 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(allTypes()).size()); + allTypes().size(), new HashSet<>(allTypes()).size()); } /** diff --git a/codec-haproxy/src/main/java/io/netty/handler/codec/haproxy/HAProxyMessage.java b/codec-haproxy/src/main/java/io/netty/handler/codec/haproxy/HAProxyMessage.java index b40bf42df2..cff30adc2f 100644 --- a/codec-haproxy/src/main/java/io/netty/handler/codec/haproxy/HAProxyMessage.java +++ b/codec-haproxy/src/main/java/io/netty/handler/codec/haproxy/HAProxyMessage.java @@ -243,7 +243,7 @@ public final class HAProxyMessage { return Collections.emptyList(); } // In most cases there are less than 4 TLVs available - List haProxyTLVs = new ArrayList(4); + List haProxyTLVs = new ArrayList<>(4); do { haProxyTLVs.add(haProxyTLV); @@ -274,7 +274,7 @@ public final class HAProxyMessage { if (byteBuf.readableBytes() >= 4) { - final List encapsulatedTlvs = new ArrayList(4); + final List encapsulatedTlvs = new ArrayList<>(4); do { final HAProxyTLV haProxyTLV = readNextTLV(byteBuf); if (haProxyTLV == null) { diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/CookieDecoder.java b/codec-http/src/main/java/io/netty/handler/codec/http/CookieDecoder.java index 040e12d710..f4cf3926e1 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/CookieDecoder.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/CookieDecoder.java @@ -82,8 +82,8 @@ public final class CookieDecoder { * @return the decoded {@link Cookie}s */ private Set doDecode(String header) { - List names = new ArrayList(8); - List values = new ArrayList(8); + List names = new ArrayList<>(8); + List values = new ArrayList<>(8); extractKeyValuePairs(header, names, values); if (names.isEmpty()) { @@ -111,7 +111,7 @@ public final class CookieDecoder { return Collections.emptySet(); } - Set cookies = new TreeSet(); + Set 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 ports = new ArrayList(2); + List ports = new ArrayList<>(2); for (int j = i + 1; j < names.size(); j++, i++) { name = names.get(j); diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/DefaultCookie.java b/codec-http/src/main/java/io/netty/handler/codec/http/DefaultCookie.java index 902ba16a2d..ad96bb8899 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/DefaultCookie.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/DefaultCookie.java @@ -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 newPorts = new TreeSet(); + Set 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 ports) { - Set newPorts = new TreeSet(); + Set newPorts = new TreeSet<>(); for (int p: ports) { if (p <= 0 || p > 65535) { throw new IllegalArgumentException("port out of range: " + p); diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/DefaultHttpHeaders.java b/codec-http/src/main/java/io/netty/handler/codec/http/DefaultHttpHeaders.java index 88af27f738..019365582b 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/DefaultHttpHeaders.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/DefaultHttpHeaders.java @@ -83,9 +83,9 @@ public class DefaultHttpHeaders extends HttpHeaders { } protected DefaultHttpHeaders(boolean validate, NameValidator nameValidator) { - this(new DefaultHeadersImpl(CASE_INSENSITIVE_HASHER, - valueConverter(validate), - nameValidator)); + this(new DefaultHeadersImpl<>(CASE_INSENSITIVE_HASHER, + valueConverter(validate), + nameValidator)); } protected DefaultHttpHeaders(DefaultHeaders headers) { @@ -257,7 +257,7 @@ public class DefaultHttpHeaders extends HttpHeaders { if (isEmpty()) { return Collections.emptyList(); } - List> entriesConverted = new ArrayList>( + List> entriesConverted = new ArrayList<>( headers.size()); for (Entry entry : this) { entriesConverted.add(entry); diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/HttpClientCodec.java b/codec-http/src/main/java/io/netty/handler/codec/http/HttpClientCodec.java index 8770202d0d..8eff1d07d7 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/HttpClientCodec.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/HttpClientCodec.java @@ -46,7 +46,7 @@ public final class HttpClientCodec extends CombinedChannelDuplexHandler queue = new ArrayDeque(); + private final Queue queue = new ArrayDeque<>(); private final boolean parseHttpAfterConnectRequest; /** If true, decoding stops (i.e. pass-through) */ diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/HttpClientUpgradeHandler.java b/codec-http/src/main/java/io/netty/handler/codec/http/HttpClientUpgradeHandler.java index 241a347bc9..d17cfc6c1d 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/HttpClientUpgradeHandler.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/HttpClientUpgradeHandler.java @@ -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 connectionParts = new LinkedHashSet(2); + Set 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. diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/HttpContentEncoder.java b/codec-http/src/main/java/io/netty/handler/codec/http/HttpContentEncoder.java index c486a67ed8..4c18933f38 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/HttpContentEncoder.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/HttpContentEncoder.java @@ -61,7 +61,7 @@ public abstract class HttpContentEncoder extends MessageToMessageCodec acceptEncodingQueue = new ArrayDeque(); + private final Queue acceptEncodingQueue = new ArrayDeque<>(); private EmbeddedChannel encoder; private State state = State.AWAIT_HEADERS; diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/HttpMethod.java b/codec-http/src/main/java/io/netty/handler/codec/http/HttpMethod.java index 3d975516d5..c361f2285e 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/HttpMethod.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/HttpMethod.java @@ -88,16 +88,16 @@ public class HttpMethod implements Comparable { private static final EnumNameMap methodMap; static { - 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)); + 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)); } /** diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/HttpServerCodec.java b/codec-http/src/main/java/io/netty/handler/codec/http/HttpServerCodec.java index f72484e4f2..66883d4cee 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/HttpServerCodec.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/HttpServerCodec.java @@ -33,7 +33,7 @@ public final class HttpServerCodec extends CombinedChannelDuplexHandler queue = new ArrayDeque(); + private final Queue queue = new ArrayDeque<>(); /** * Creates a new instance with the default decoder options diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/HttpServerUpgradeHandler.java b/codec-http/src/main/java/io/netty/handler/codec/http/HttpServerUpgradeHandler.java index f1f3efcb1d..a720661fd3 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/HttpServerUpgradeHandler.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/HttpServerUpgradeHandler.java @@ -359,7 +359,7 @@ public class HttpServerUpgradeHandler extends HttpObjectAggregator { */ private static List splitHeader(CharSequence header) { final StringBuilder builder = new StringBuilder(header.length()); - final List protocols = new ArrayList(4); + final List protocols = new ArrayList<>(4); for (int i = 0; i < header.length(); ++i) { char c = header.charAt(i); if (Character.isWhitespace(c)) { diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/HttpUtil.java b/codec-http/src/main/java/io/netty/handler/codec/http/HttpUtil.java index 8e04b10db6..a668b8942a 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/HttpUtil.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/HttpUtil.java @@ -325,7 +325,7 @@ public final class HttpUtil { if (encodings.isEmpty()) { return; } - List values = new ArrayList(encodings); + List values = new ArrayList<>(encodings); Iterator valuesIt = values.iterator(); while (valuesIt.hasNext()) { CharSequence value = valuesIt.next(); diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/QueryStringDecoder.java b/codec-http/src/main/java/io/netty/handler/codec/http/QueryStringDecoder.java index 7c631f31ce..fadb610adb 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/QueryStringDecoder.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/QueryStringDecoder.java @@ -212,7 +212,7 @@ public class QueryStringDecoder { if (s.charAt(from) == '?') { from++; } - Map> params = new LinkedHashMap>(); + Map> 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 values = params.get(name); if (values == null) { - values = new ArrayList(1); // Often there's only 1 value. + values = new ArrayList<>(1); // Often there's only 1 value. params.put(name, values); } values.add(value); diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/ReadOnlyHttpHeaders.java b/codec-http/src/main/java/io/netty/handler/codec/http/ReadOnlyHttpHeaders.java index 995e2ad90a..75301d4b2f 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/ReadOnlyHttpHeaders.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/ReadOnlyHttpHeaders.java @@ -132,7 +132,7 @@ public final class ReadOnlyHttpHeaders extends HttpHeaders { return Collections.emptyList(); } final int nameHash = AsciiString.hashCode(name); - List values = new ArrayList(4); + List 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> entries = new ArrayList>(size()); + List> entries = new ArrayList<>(size()); for (int i = 0; i < nameValuePairs.length; i += 2) { - entries.add(new SimpleImmutableEntry(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 names = new LinkedHashSet(size()); + Set names = new LinkedHashSet<>(size()); for (int i = 0; i < nameValuePairs.length; i += 2) { names.add(nameValuePairs[i].toString()); } diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/cookie/ServerCookieDecoder.java b/codec-http/src/main/java/io/netty/handler/codec/http/cookie/ServerCookieDecoder.java index cf5349b086..4ec93d8335 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/cookie/ServerCookieDecoder.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/cookie/ServerCookieDecoder.java @@ -68,7 +68,7 @@ public final class ServerCookieDecoder extends CookieDecoder { return Collections.emptySet(); } - Set cookies = new TreeSet(); + Set cookies = new TreeSet<>(); int i = 0; diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/cookie/ServerCookieEncoder.java b/codec-http/src/main/java/io/netty/handler/codec/http/cookie/ServerCookieEncoder.java index b707dc33d1..de130b7f3b 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/cookie/ServerCookieEncoder.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/cookie/ServerCookieEncoder.java @@ -139,7 +139,7 @@ public final class ServerCookieEncoder extends CookieEncoder { for (int idx : nameToLastIndex.values()) { isLastInstance[idx] = true; } - List dedupd = new ArrayList(nameToLastIndex.size()); + List 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 encoded = new ArrayList(cookies.length); - Map nameToIndex = strict && cookies.length > 1 ? new HashMap() : null; + List encoded = new ArrayList<>(cookies.length); + Map 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 encoded = new ArrayList(cookies.size()); - Map nameToIndex = strict && cookies.size() > 1 ? new HashMap() : null; + List encoded = new ArrayList<>(cookies.size()); + Map 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 encoded = new ArrayList(); + List encoded = new ArrayList<>(); Cookie firstCookie = cookiesIt.next(); - Map nameToIndex = strict && cookiesIt.hasNext() ? new HashMap() : null; + Map nameToIndex = strict && cookiesIt.hasNext() ? new HashMap<>() : null; int i = 0; encoded.add(encode(firstCookie)); boolean hasDupdName = nameToIndex != null && nameToIndex.put(firstCookie.name(), i++) != null; diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/cors/CorsConfig.java b/codec-http/src/main/java/io/netty/handler/codec/http/cors/CorsConfig.java index 5ccae5d641..317e44517f 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/cors/CorsConfig.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/cors/CorsConfig.java @@ -47,7 +47,7 @@ public final class CorsConfig { private final boolean shortCircuit; CorsConfig(final CorsConfigBuilder builder) { - origins = new LinkedHashSet(builder.origins); + origins = new LinkedHashSet<>(builder.origins); anyOrigin = builder.anyOrigin; enabled = builder.enabled; exposeHeaders = builder.exposeHeaders; diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/cors/CorsConfigBuilder.java b/codec-http/src/main/java/io/netty/handler/codec/http/cors/CorsConfigBuilder.java index c55eed184b..6b1c083149 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/cors/CorsConfigBuilder.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/cors/CorsConfigBuilder.java @@ -68,11 +68,11 @@ public final class CorsConfigBuilder { boolean allowNullOrigin; boolean enabled = true; boolean allowCredentials; - final Set exposeHeaders = new HashSet(); + final Set exposeHeaders = new HashSet<>(); long maxAge; - final Set requestMethods = new HashSet(); - final Set requestHeaders = new HashSet(); - final Map> preflightHeaders = new HashMap>(); + final Set requestMethods = new HashSet<>(); + final Set requestHeaders = new HashSet<>(); + final Map> 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(Arrays.asList(origins)); + this.origins = new LinkedHashSet<>(Arrays.asList(origins)); anyOrigin = false; } diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/multipart/DefaultHttpDataFactory.java b/codec-http/src/main/java/io/netty/handler/codec/http/multipart/DefaultHttpDataFactory.java index 6387ecaac7..9f92325bf4 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/multipart/DefaultHttpDataFactory.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/multipart/DefaultHttpDataFactory.java @@ -67,7 +67,7 @@ public class DefaultHttpDataFactory implements HttpDataFactory { * different data items may be equal. */ private final Map> requestFileDeleteMap = - Collections.synchronizedMap(new IdentityHashMap>()); + 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 getList(HttpRequest request) { List list = requestFileDeleteMap.get(request); if (list == null) { - list = new ArrayList(); + list = new ArrayList<>(); requestFileDeleteMap.put(request, list); } return list; diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/multipart/HttpPostMultipartRequestDecoder.java b/codec-http/src/main/java/io/netty/handler/codec/http/multipart/HttpPostMultipartRequestDecoder.java index e910e889ed..2bc91dc510 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/multipart/HttpPostMultipartRequestDecoder.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/multipart/HttpPostMultipartRequestDecoder.java @@ -79,12 +79,12 @@ public class HttpPostMultipartRequestDecoder implements InterfaceHttpPostRequest /** * HttpDatas from Body */ - private final List bodyListHttpData = new ArrayList(); + private final List bodyListHttpData = new ArrayList<>(); /** * HttpDatas as Map from Body */ - private final Map> bodyMapHttpData = new TreeMap>( + private final Map> bodyMapHttpData = new TreeMap<>( CaseIgnoringComparator.INSTANCE); /** @@ -424,7 +424,7 @@ public class HttpPostMultipartRequestDecoder implements InterfaceHttpPostRequest } List datas = bodyMapHttpData.get(data.getName()); if (datas == null) { - datas = new ArrayList(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(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 headers = new ArrayList(1); + ArrayList headers = new ArrayList<>(1); int nameStart; int nameEnd; int colonEnd; diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/multipart/HttpPostRequestEncoder.java b/codec-http/src/main/java/io/netty/handler/codec/http/multipart/HttpPostRequestEncoder.java index 21faffe4a3..361215068a 100755 --- a/codec-http/src/main/java/io/netty/handler/codec/http/multipart/HttpPostRequestEncoder.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/multipart/HttpPostRequestEncoder.java @@ -98,9 +98,9 @@ public class HttpPostRequestEncoder implements ChunkedInput { static { percentEncodings = new Map.Entry[] { - new SimpleImmutableEntry(Pattern.compile("\\*"), "%2A"), - new SimpleImmutableEntry(Pattern.compile("\\+"), "%20"), - new SimpleImmutableEntry(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 { throw new ErrorDataEncoderException("Cannot create a Encoder if request is a TRACE"); } // Fill default values - bodyListDatas = new ArrayList(); + bodyListDatas = new ArrayList<>(); // default mode isLastChunk = false; isLastChunkSent = false; isMultipart = multipart; - multipartHttpDatas = new ArrayList(); + multipartHttpDatas = new ArrayList<>(); this.encoderMode = encoderMode; if (isMultipart) { initDataMultipart(); diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/multipart/HttpPostStandardRequestDecoder.java b/codec-http/src/main/java/io/netty/handler/codec/http/multipart/HttpPostStandardRequestDecoder.java index 88cf05ee60..8bce1c4a93 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/multipart/HttpPostStandardRequestDecoder.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/multipart/HttpPostStandardRequestDecoder.java @@ -68,12 +68,12 @@ public class HttpPostStandardRequestDecoder implements InterfaceHttpPostRequestD /** * HttpDatas from Body */ - private final List bodyListHttpData = new ArrayList(); + private final List bodyListHttpData = new ArrayList<>(); /** * HttpDatas as Map from Body */ - private final Map> bodyMapHttpData = new TreeMap>( + private final Map> bodyMapHttpData = new TreeMap<>( CaseIgnoringComparator.INSTANCE); /** @@ -369,7 +369,7 @@ public class HttpPostStandardRequestDecoder implements InterfaceHttpPostRequestD } List datas = bodyMapHttpData.get(data.getName()); if (datas == null) { - datas = new ArrayList(1); + datas = new ArrayList<>(1); bodyMapHttpData.put(data.getName(), datas); } datas.add(data); diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/multipart/InternalAttribute.java b/codec-http/src/main/java/io/netty/handler/codec/http/multipart/InternalAttribute.java index 991100ed20..24059355ee 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/multipart/InternalAttribute.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/multipart/InternalAttribute.java @@ -28,7 +28,7 @@ import java.util.List; * (like Multipart Mixed mode) */ final class InternalAttribute extends AbstractReferenceCounted implements InterfaceHttpData { - private final List value = new ArrayList(); + private final List value = new ArrayList<>(); private final Charset charset; private int size; diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketServerHandshaker.java b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketServerHandshaker.java index 4eb43484c4..439595514a 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketServerHandshaker.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketServerHandshaker.java @@ -106,7 +106,7 @@ public abstract class WebSocketServerHandshaker { * Returns the CSV of supported sub protocols */ public Set subprotocols() { - Set ret = new LinkedHashSet(); + Set ret = new LinkedHashSet<>(); Collections.addAll(ret, subprotocols); return ret; } diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/extensions/WebSocketClientExtensionHandler.java b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/extensions/WebSocketClientExtensionHandler.java index 92ee9cc35d..ab8b782568 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/extensions/WebSocketClientExtensionHandler.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/extensions/WebSocketClientExtensionHandler.java @@ -90,7 +90,7 @@ public class WebSocketClientExtensionHandler extends ChannelDuplexHandler { List extensions = WebSocketExtensionUtil.extractExtensions(extensionsHeader); List validExtensions = - new ArrayList(extensions.size()); + new ArrayList<>(extensions.size()); int rsv = 0; for (WebSocketExtensionData extensionData : extensions) { diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/extensions/WebSocketExtensionUtil.java b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/extensions/WebSocketExtensionUtil.java index fd91f72eab..86f4731af6 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/extensions/WebSocketExtensionUtil.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/extensions/WebSocketExtensionUtil.java @@ -44,13 +44,13 @@ public final class WebSocketExtensionUtil { public static List extractExtensions(String extensionHeader) { String[] rawExtensions = extensionHeader.split(EXTENSION_SEPARATOR); if (rawExtensions.length > 0) { - List extensions = new ArrayList(rawExtensions.length); + List extensions = new ArrayList<>(rawExtensions.length); for (String rawExtension : rawExtensions) { String[] extensionParameters = rawExtension.split(PARAMETER_SEPARATOR); String name = extensionParameters[0].trim(); Map parameters; if (extensionParameters.length > 1) { - parameters = new HashMap(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); diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/extensions/WebSocketServerExtensionHandler.java b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/extensions/WebSocketServerExtensionHandler.java index 1b2e39189c..f63401d865 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/extensions/WebSocketServerExtensionHandler.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/extensions/WebSocketServerExtensionHandler.java @@ -89,7 +89,7 @@ public class WebSocketServerExtensionHandler extends ChannelDuplexHandler { if (validExtension != null && ((validExtension.rsv() & rsv) == 0)) { if (validExtensions == null) { - validExtensions = new ArrayList(1); + validExtensions = new ArrayList<>(1); } rsv = rsv | validExtension.rsv(); validExtensions.add(validExtension); diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/extensions/compression/PerMessageDeflateClientExtensionHandshaker.java b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/extensions/compression/PerMessageDeflateClientExtensionHandshaker.java index ddebaaa92f..58370518c9 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/extensions/compression/PerMessageDeflateClientExtensionHandshaker.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/extensions/compression/PerMessageDeflateClientExtensionHandshaker.java @@ -85,7 +85,7 @@ public final class PerMessageDeflateClientExtensionHandshaker implements WebSock @Override public WebSocketExtensionData newRequestData() { - HashMap parameters = new HashMap(4); + HashMap parameters = new HashMap<>(4); if (requestedServerWindowSize != MAX_WINDOW_SIZE) { parameters.put(SERVER_NO_CONTEXT, null); } diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/extensions/compression/PerMessageDeflateServerExtensionHandshaker.java b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/extensions/compression/PerMessageDeflateServerExtensionHandshaker.java index 0bf0162e8a..ff592ef2aa 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/extensions/compression/PerMessageDeflateServerExtensionHandshaker.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/extensions/compression/PerMessageDeflateServerExtensionHandshaker.java @@ -177,7 +177,7 @@ public final class PerMessageDeflateServerExtensionHandshaker implements WebSock @Override public WebSocketExtensionData newReponseData() { - HashMap parameters = new HashMap(4); + HashMap parameters = new HashMap<>(4); if (serverNoContext) { parameters.put(SERVER_NO_CONTEXT, null); } diff --git a/codec-http/src/main/java/io/netty/handler/codec/rtsp/RtspMethods.java b/codec-http/src/main/java/io/netty/handler/codec/rtsp/RtspMethods.java index 3e62928012..1419c87605 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/rtsp/RtspMethods.java +++ b/codec-http/src/main/java/io/netty/handler/codec/rtsp/RtspMethods.java @@ -95,7 +95,7 @@ public final class RtspMethods { */ public static final HttpMethod RECORD = new HttpMethod("RECORD"); - private static final Map methodMap = new HashMap(); + private static final Map methodMap = new HashMap<>(); static { methodMap.put(DESCRIBE.toString(), DESCRIBE); diff --git a/codec-http/src/main/java/io/netty/handler/codec/spdy/DefaultSpdySettingsFrame.java b/codec-http/src/main/java/io/netty/handler/codec/spdy/DefaultSpdySettingsFrame.java index 5097048601..cbebb4a0b0 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/spdy/DefaultSpdySettingsFrame.java +++ b/codec-http/src/main/java/io/netty/handler/codec/spdy/DefaultSpdySettingsFrame.java @@ -27,7 +27,7 @@ import java.util.TreeMap; public class DefaultSpdySettingsFrame implements SpdySettingsFrame { private boolean clear; - private final Map settingsMap = new TreeMap(); + private final Map settingsMap = new TreeMap<>(); @Override public Set ids() { diff --git a/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyHttpDecoder.java b/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyHttpDecoder.java index 366ad15b66..221201958b 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyHttpDecoder.java +++ b/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyHttpDecoder.java @@ -59,7 +59,7 @@ public class SpdyHttpDecoder extends MessageToMessageDecoder { * a {@link TooLongFrameException} will be raised. */ public SpdyHttpDecoder(SpdyVersion version, int maxContentLength) { - this(version, maxContentLength, new HashMap(), true); + this(version, maxContentLength, new HashMap<>(), true); } /** @@ -72,7 +72,7 @@ public class SpdyHttpDecoder extends MessageToMessageDecoder { * @param validateHeaders {@code true} if http headers should be validated */ public SpdyHttpDecoder(SpdyVersion version, int maxContentLength, boolean validateHeaders) { - this(version, maxContentLength, new HashMap(), validateHeaders); + this(version, maxContentLength, new HashMap<>(), validateHeaders); } /** diff --git a/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyHttpResponseStreamIdHandler.java b/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyHttpResponseStreamIdHandler.java index 4ad32e4dc2..e57c167a77 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyHttpResponseStreamIdHandler.java +++ b/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyHttpResponseStreamIdHandler.java @@ -33,7 +33,7 @@ import java.util.Queue; public class SpdyHttpResponseStreamIdHandler extends MessageToMessageCodec { private static final Integer NO_ID = -1; - private final Queue ids = new LinkedList(); + private final Queue ids = new LinkedList<>(); @Override public boolean acceptInboundMessage(Object msg) throws Exception { diff --git a/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdySession.java b/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdySession.java index e34dc27f6d..136e71fb37 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdySession.java +++ b/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdySession.java @@ -59,7 +59,7 @@ final class SpdySession { // Stream-IDs should be iterated in priority order Map activeStreams() { - Map streams = new TreeMap(streamComparator); + Map 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 pendingWriteQueue = new ConcurrentLinkedQueue(); + private final Queue pendingWriteQueue = new ConcurrentLinkedQueue<>(); StreamState( byte priority, boolean remoteSideClosed, boolean localSideClosed, diff --git a/codec-http/src/test/java/io/netty/handler/codec/http/HttpContentDecoderTest.java b/codec-http/src/test/java/io/netty/handler/codec/http/HttpContentDecoderTest.java index 8646558c9f..eb66a6fb7b 100644 --- a/codec-http/src/test/java/io/netty/handler/codec/http/HttpContentDecoderTest.java +++ b/codec-http/src/test/java/io/netty/handler/codec/http/HttpContentDecoderTest.java @@ -273,7 +273,7 @@ public class HttpContentDecoderTest { HttpRequestDecoder decoder = new HttpRequestDecoder(); final int maxBytes = 10; HttpObjectAggregator aggregator = new HttpObjectAggregator(maxBytes); - final AtomicReference secondRequestRef = new AtomicReference(); + final AtomicReference 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 inbound = new ArrayList(); + List 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 outbound = new ArrayList(); + List outbound = new ArrayList<>(); while ((o = channel.readOutbound()) != null) { outbound.add(o); outputSize += o.readableBytes(); diff --git a/codec-http/src/test/java/io/netty/handler/codec/http/HttpHeadersTestUtils.java b/codec-http/src/test/java/io/netty/handler/codec/http/HttpHeadersTestUtils.java index d5e453c39f..d415b61373 100644 --- a/codec-http/src/test/java/io/netty/handler/codec/http/HttpHeadersTestUtils.java +++ b/codec-http/src/test/java/io/netty/handler/codec/http/HttpHeadersTestUtils.java @@ -54,7 +54,7 @@ public final class HttpHeadersTestUtils { public List asList() { if (array == null) { - List list = new ArrayList(nr); + List 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 list = new ArrayList(size); + List list = new ArrayList<>(size); List 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 MAP; static { - final Map map = new HashMap(); + final Map map = new HashMap<>(); for (HeaderValue v : values()) { final int nr = v.nr; map.put(Integer.valueOf(nr), v); diff --git a/codec-http/src/test/java/io/netty/handler/codec/http/HttpUtilTest.java b/codec-http/src/test/java/io/netty/handler/codec/http/HttpUtilTest.java index 31596067ae..b4a6d939b9 100644 --- a/codec-http/src/test/java/io/netty/handler/codec/http/HttpUtilTest.java +++ b/codec-http/src/test/java/io/netty/handler/codec/http/HttpUtilTest.java @@ -194,7 +194,7 @@ public class HttpUtilTest { } private static List allPossibleCasesOfContinue() { - final List cases = new ArrayList(); + final List 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()); diff --git a/codec-http/src/test/java/io/netty/handler/codec/http/cookie/ClientCookieDecoderTest.java b/codec-http/src/test/java/io/netty/handler/codec/http/cookie/ClientCookieDecoderTest.java index 2cd69f98dc..1aa7a2f5dc 100644 --- a/codec-http/src/test/java/io/netty/handler/codec/http/cookie/ClientCookieDecoderTest.java +++ b/codec-http/src/test/java/io/netty/handler/codec/http/cookie/ClientCookieDecoderTest.java @@ -118,11 +118,11 @@ public class ClientCookieDecoderTest { @Test public void testDecodingQuotedCookie() { - Collection sources = new ArrayList(); + Collection sources = new ArrayList<>(); sources.add("a=\"\","); sources.add("b=\"1\","); - Collection cookies = new ArrayList(); + Collection cookies = new ArrayList<>(); for (String source : sources) { cookies.add(ClientCookieDecoder.STRICT.decode(source)); } diff --git a/codec-http/src/test/java/io/netty/handler/codec/http/cookie/ServerCookieEncoderTest.java b/codec-http/src/test/java/io/netty/handler/codec/http/cookie/ServerCookieEncoderTest.java index 82f813ff47..afa6f39bf1 100644 --- a/codec-http/src/test/java/io/netty/handler/codec/http/cookie/ServerCookieEncoderTest.java +++ b/codec-http/src/test/java/io/netty/handler/codec/http/cookie/ServerCookieEncoderTest.java @@ -70,7 +70,7 @@ public class ServerCookieEncoderTest { @Test public void testEncodingMultipleCookiesStrict() { - List result = new ArrayList(); + List 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 illegalChars = new HashSet(); + Set 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 illegalChars = new HashSet(); + Set 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 result = new ArrayList(); + List result = new ArrayList<>(); result.add("cookie1=value1"); result.add("cookie2=value2"); result.add("cookie1=value3"); diff --git a/codec-http/src/test/java/io/netty/handler/codec/http/websocketx/WebSocket08FrameDecoderTest.java b/codec-http/src/test/java/io/netty/handler/codec/http/websocketx/WebSocket08FrameDecoderTest.java index cb6c187efc..fc80180378 100644 --- a/codec-http/src/test/java/io/netty/handler/codec/http/websocketx/WebSocket08FrameDecoderTest.java +++ b/codec-http/src/test/java/io/netty/handler/codec/http/websocketx/WebSocket08FrameDecoderTest.java @@ -38,11 +38,11 @@ public class WebSocket08FrameDecoderTest { @Test public void supportIanaStatusCodes() throws Exception { - Set forbiddenIanaCodes = new HashSet(); + Set forbiddenIanaCodes = new HashSet<>(); forbiddenIanaCodes.add(1004); forbiddenIanaCodes.add(1005); forbiddenIanaCodes.add(1006); - Set validIanaCodes = new HashSet(); + Set validIanaCodes = new HashSet<>(); for (int i = 1000; i < 1015; i++) { validIanaCodes.add(i); } diff --git a/codec-http/src/test/java/io/netty/handler/codec/http/websocketx/WebSocketServerProtocolHandlerTest.java b/codec-http/src/test/java/io/netty/handler/codec/http/websocketx/WebSocketServerProtocolHandlerTest.java index 50bd6bebea..0e9c075369 100644 --- a/codec-http/src/test/java/io/netty/handler/codec/http/websocketx/WebSocketServerProtocolHandlerTest.java +++ b/codec-http/src/test/java/io/netty/handler/codec/http/websocketx/WebSocketServerProtocolHandlerTest.java @@ -42,7 +42,7 @@ import static org.junit.Assert.*; public class WebSocketServerProtocolHandlerTest { - private final Queue responses = new ArrayDeque(); + private final Queue responses = new ArrayDeque<>(); @Before public void setUp() { diff --git a/codec-http/src/test/java/io/netty/handler/codec/http/websocketx/extensions/compression/DeflateFrameClientExtensionHandshakerTest.java b/codec-http/src/test/java/io/netty/handler/codec/http/websocketx/extensions/compression/DeflateFrameClientExtensionHandshakerTest.java index d3ee5a4c1f..0d241db78e 100644 --- a/codec-http/src/test/java/io/netty/handler/codec/http/websocketx/extensions/compression/DeflateFrameClientExtensionHandshakerTest.java +++ b/codec-http/src/test/java/io/netty/handler/codec/http/websocketx/extensions/compression/DeflateFrameClientExtensionHandshakerTest.java @@ -71,7 +71,7 @@ public class DeflateFrameClientExtensionHandshakerTest { DeflateFrameClientExtensionHandshaker handshaker = new DeflateFrameClientExtensionHandshaker(false); - Map parameters = new HashMap(); + Map parameters = new HashMap<>(); parameters.put("invalid", "12"); // execute diff --git a/codec-http/src/test/java/io/netty/handler/codec/http/websocketx/extensions/compression/DeflateFrameServerExtensionHandshakerTest.java b/codec-http/src/test/java/io/netty/handler/codec/http/websocketx/extensions/compression/DeflateFrameServerExtensionHandshakerTest.java index 1d6f8ba5af..a18df0aac2 100644 --- a/codec-http/src/test/java/io/netty/handler/codec/http/websocketx/extensions/compression/DeflateFrameServerExtensionHandshakerTest.java +++ b/codec-http/src/test/java/io/netty/handler/codec/http/websocketx/extensions/compression/DeflateFrameServerExtensionHandshakerTest.java @@ -70,7 +70,7 @@ public class DeflateFrameServerExtensionHandshakerTest { new DeflateFrameServerExtensionHandshaker(); Map parameters; - parameters = new HashMap(); + parameters = new HashMap<>(); parameters.put("unknown", "11"); // execute diff --git a/codec-http/src/test/java/io/netty/handler/codec/http/websocketx/extensions/compression/PerMessageDeflateClientExtensionHandshakerTest.java b/codec-http/src/test/java/io/netty/handler/codec/http/websocketx/extensions/compression/PerMessageDeflateClientExtensionHandshakerTest.java index 8ed3a7c25f..6f94bbe571 100644 --- a/codec-http/src/test/java/io/netty/handler/codec/http/websocketx/extensions/compression/PerMessageDeflateClientExtensionHandshakerTest.java +++ b/codec-http/src/test/java/io/netty/handler/codec/http/websocketx/extensions/compression/PerMessageDeflateClientExtensionHandshakerTest.java @@ -84,7 +84,7 @@ public class PerMessageDeflateClientExtensionHandshakerTest { PerMessageDeflateClientExtensionHandshaker handshaker = new PerMessageDeflateClientExtensionHandshaker(6, true, 10, true, true); - parameters = new HashMap(); + 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(); + 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(); + parameters = new HashMap<>(); // execute extension = handshaker.handshakeExtension( diff --git a/codec-http/src/test/java/io/netty/handler/codec/http/websocketx/extensions/compression/PerMessageDeflateServerExtensionHandshakerTest.java b/codec-http/src/test/java/io/netty/handler/codec/http/websocketx/extensions/compression/PerMessageDeflateServerExtensionHandshakerTest.java index a837c4993b..8691b1d23b 100644 --- a/codec-http/src/test/java/io/netty/handler/codec/http/websocketx/extensions/compression/PerMessageDeflateServerExtensionHandshakerTest.java +++ b/codec-http/src/test/java/io/netty/handler/codec/http/websocketx/extensions/compression/PerMessageDeflateServerExtensionHandshakerTest.java @@ -56,7 +56,7 @@ public class PerMessageDeflateServerExtensionHandshakerTest { assertTrue(data.parameters().isEmpty()); // initialize - parameters = new HashMap(); + 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(); + 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(); + 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(); + 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(); + parameters = new HashMap<>(); // execute extension = handshaker.handshakeExtension( diff --git a/codec-http/src/test/java/io/netty/handler/codec/spdy/SpdyFrameDecoderTest.java b/codec-http/src/test/java/io/netty/handler/codec/spdy/SpdyFrameDecoderTest.java index d8f247e2c2..964ec15254 100644 --- a/codec-http/src/test/java/io/netty/handler/codec/spdy/SpdyFrameDecoderTest.java +++ b/codec-http/src/test/java/io/netty/handler/codec/spdy/SpdyFrameDecoderTest.java @@ -48,7 +48,7 @@ public class SpdyFrameDecoderTest { } private final class TestSpdyFrameDecoderDelegate implements SpdyFrameDecoderDelegate { - private final Queue buffers = new ArrayDeque(); + private final Queue buffers = new ArrayDeque<>(); @Override public void readDataFrame(int streamId, boolean last, ByteBuf data) { diff --git a/codec-http2/src/main/java/io/netty/handler/codec/http2/DefaultHttp2Connection.java b/codec-http2/src/main/java/io/netty/handler/codec/http2/DefaultHttp2Connection.java index 8590e06fa2..504184b676 100644 --- a/codec-http2/src/main/java/io/netty/handler/codec/http2/DefaultHttp2Connection.java +++ b/codec-http2/src/main/java/io/netty/handler/codec/http2/DefaultHttp2Connection.java @@ -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 listeners = new ArrayList(4); + final List listeners = new ArrayList<>(4); final ActiveStreams activeStreams; Promise 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(server, server ? MAX_VALUE : maxReservedStreams); - remoteEndpoint = new DefaultEndpoint(!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(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 listeners; - private final Queue pendingEvents = new ArrayDeque(4); - private final Set streams = new LinkedHashSet(); + private final Queue pendingEvents = new ArrayDeque<>(4); + private final Set streams = new LinkedHashSet<>(); private int pendingIterations; public ActiveStreams(List 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 keys = new ArrayList(4); + final List keys = new ArrayList<>(4); /** * Registers a new property key. diff --git a/codec-http2/src/main/java/io/netty/handler/codec/http2/DefaultHttp2ConnectionEncoder.java b/codec-http2/src/main/java/io/netty/handler/codec/http2/DefaultHttp2ConnectionEncoder.java index ce90e24342..2254f1fb90 100644 --- a/codec-http2/src/main/java/io/netty/handler/codec/http2/DefaultHttp2ConnectionEncoder.java +++ b/codec-http2/src/main/java/io/netty/handler/codec/http2/DefaultHttp2ConnectionEncoder.java @@ -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 outstandingLocalSettingsQueue = new ArrayDeque(4); + private final ArrayDeque outstandingLocalSettingsQueue = new ArrayDeque<>(4); public DefaultHttp2ConnectionEncoder(Http2Connection connection, Http2FrameWriter frameWriter) { this.connection = checkNotNull(connection, "connection"); diff --git a/codec-http2/src/main/java/io/netty/handler/codec/http2/DefaultHttp2RemoteFlowController.java b/codec-http2/src/main/java/io/netty/handler/codec/http2/DefaultHttp2RemoteFlowController.java index 217cf8dc25..0742c3657a 100644 --- a/codec-http2/src/main/java/io/netty/handler/codec/http2/DefaultHttp2RemoteFlowController.java +++ b/codec-http2/src/main/java/io/netty/handler/codec/http2/DefaultHttp2RemoteFlowController.java @@ -287,7 +287,7 @@ public class DefaultHttp2RemoteFlowController implements Http2RemoteFlowControll FlowState(Http2Stream stream) { this.stream = stream; - pendingWriteQueue = new ArrayDeque(2); + pendingWriteQueue = new ArrayDeque<>(2); } /** diff --git a/codec-http2/src/main/java/io/netty/handler/codec/http2/HpackStaticTable.java b/codec-http2/src/main/java/io/netty/handler/codec/http2/HpackStaticTable.java index 9621daf2e0..38c321d6e0 100644 --- a/codec-http2/src/main/java/io/netty/handler/codec/http2/HpackStaticTable.java +++ b/codec-http2/src/main/java/io/netty/handler/codec/http2/HpackStaticTable.java @@ -170,7 +170,7 @@ final class HpackStaticTable { private static CharSequenceMap createMap() { int length = STATIC_TABLE.size(); @SuppressWarnings("unchecked") - CharSequenceMap ret = new CharSequenceMap(true, + CharSequenceMap ret = new CharSequenceMap<>(true, UnsupportedValueConverter.instance(), length); // Iterate through the static table in reverse order to // save the smallest index for a given name in the map. diff --git a/codec-http2/src/main/java/io/netty/handler/codec/http2/Http2Exception.java b/codec-http2/src/main/java/io/netty/handler/codec/http2/Http2Exception.java index 258f871eb8..092ab085dc 100644 --- a/codec-http2/src/main/java/io/netty/handler/codec/http2/Http2Exception.java +++ b/codec-http2/src/main/java/io/netty/handler/codec/http2/Http2Exception.java @@ -275,7 +275,7 @@ public class Http2Exception extends Exception { public CompositeStreamException(Http2Error error, int initialCapacity) { super(error, ShutdownHint.NO_SHUTDOWN); - exceptions = new ArrayList(initialCapacity); + exceptions = new ArrayList<>(initialCapacity); } public void add(StreamException e) { diff --git a/codec-http2/src/main/java/io/netty/handler/codec/http2/Http2Headers.java b/codec-http2/src/main/java/io/netty/handler/codec/http2/Http2Headers.java index f0999bf644..dda910020d 100644 --- a/codec-http2/src/main/java/io/netty/handler/codec/http2/Http2Headers.java +++ b/codec-http2/src/main/java/io/netty/handler/codec/http2/Http2Headers.java @@ -62,7 +62,7 @@ public interface Http2Headers extends Headers PSEUDO_HEADERS = new CharSequenceMap(); + private static final CharSequenceMap PSEUDO_HEADERS = new CharSequenceMap<>(); static { for (PseudoHeaderName pseudoHeader : PseudoHeaderName.values()) { diff --git a/codec-http2/src/main/java/io/netty/handler/codec/http2/Http2MultiplexCodec.java b/codec-http2/src/main/java/io/netty/handler/codec/http2/Http2MultiplexCodec.java index b766bd2be6..b6649b5c21 100644 --- a/codec-http2/src/main/java/io/netty/handler/codec/http2/Http2MultiplexCodec.java +++ b/codec-http2/src/main/java/io/netty/handler/codec/http2/Http2MultiplexCodec.java @@ -790,7 +790,7 @@ public class Http2MultiplexCodec extends Http2FrameCodec { } } else { if (inboundBuffer == null) { - inboundBuffer = new ArrayDeque(4); + inboundBuffer = new ArrayDeque<>(4); } inboundBuffer.add(frame); } diff --git a/codec-http2/src/main/java/io/netty/handler/codec/http2/Http2SecurityUtil.java b/codec-http2/src/main/java/io/netty/handler/codec/http2/Http2SecurityUtil.java index 6c08feeaf0..0ecd2c058e 100644 --- a/codec-http2/src/main/java/io/netty/handler/codec/http2/Http2SecurityUtil.java +++ b/codec-http2/src/main/java/io/netty/handler/codec/http2/Http2SecurityUtil.java @@ -67,7 +67,7 @@ public final class Http2SecurityUtil { )); static { - CIPHERS = Collections.unmodifiableList(new ArrayList(CIPHERS_JAVA_MOZILLA_MODERN_SECURITY)); + CIPHERS = Collections.unmodifiableList(new ArrayList<>(CIPHERS_JAVA_MOZILLA_MODERN_SECURITY)); } private Http2SecurityUtil() { } diff --git a/codec-http2/src/main/java/io/netty/handler/codec/http2/Http2StreamChannelBootstrap.java b/codec-http2/src/main/java/io/netty/handler/codec/http2/Http2StreamChannelBootstrap.java index c3f078f748..118be6c7b6 100644 --- a/codec-http2/src/main/java/io/netty/handler/codec/http2/Http2StreamChannelBootstrap.java +++ b/codec-http2/src/main/java/io/netty/handler/codec/http2/Http2StreamChannelBootstrap.java @@ -40,8 +40,8 @@ import java.util.Map; public final class Http2StreamChannelBootstrap { private static final InternalLogger logger = InternalLoggerFactory.getInstance(Http2StreamChannelBootstrap.class); - private final Map, Object> options = new LinkedHashMap, Object>(); - private final Map, Object> attrs = new LinkedHashMap, Object>(); + private final Map, Object> options = new LinkedHashMap<>(); + private final Map, Object> attrs = new LinkedHashMap<>(); private final Channel channel; private volatile ChannelHandler handler; diff --git a/codec-http2/src/main/java/io/netty/handler/codec/http2/HttpConversionUtil.java b/codec-http2/src/main/java/io/netty/handler/codec/http2/HttpConversionUtil.java index 5f808db8df..79ab054166 100644 --- a/codec-http2/src/main/java/io/netty/handler/codec/http2/HttpConversionUtil.java +++ b/codec-http2/src/main/java/io/netty/handler/codec/http2/HttpConversionUtil.java @@ -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 HTTP_TO_HTTP2_HEADER_BLACKLIST = - new CharSequenceMap(); + 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 toLowercaseMap(Iterator valuesIter, int arraySizeHint) { UnsupportedValueConverter valueConverter = UnsupportedValueConverter.instance(); - CharSequenceMap result = new CharSequenceMap(true, valueConverter, arraySizeHint); + CharSequenceMap 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 - REQUEST_HEADER_TRANSLATIONS = new CharSequenceMap(); + REQUEST_HEADER_TRANSLATIONS = new CharSequenceMap<>(); private static final CharSequenceMap - RESPONSE_HEADER_TRANSLATIONS = new CharSequenceMap(); + RESPONSE_HEADER_TRANSLATIONS = new CharSequenceMap<>(); static { RESPONSE_HEADER_TRANSLATIONS.add(Http2Headers.PseudoHeaderName.AUTHORITY.value(), HttpHeaderNames.HOST); diff --git a/codec-http2/src/main/java/io/netty/handler/codec/http2/ReadOnlyHttp2Headers.java b/codec-http2/src/main/java/io/netty/handler/codec/http2/ReadOnlyHttp2Headers.java index b74a5661cf..83633768df 100644 --- a/codec-http2/src/main/java/io/netty/handler/codec/http2/ReadOnlyHttp2Headers.java +++ b/codec-http2/src/main/java/io/netty/handler/codec/http2/ReadOnlyHttp2Headers.java @@ -199,7 +199,7 @@ public final class ReadOnlyHttp2Headers implements Http2Headers { @Override public List getAll(CharSequence name) { final int nameHash = AsciiString.hashCode(name); - List values = new ArrayList(); + List 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 names = new LinkedHashSet(size()); + Set names = new LinkedHashSet<>(size()); final int pseudoHeadersEnd = pseudoHeaders.length - 1; for (int i = 0; i < pseudoHeadersEnd; i += 2) { names.add(pseudoHeaders[i]); diff --git a/codec-http2/src/main/java/io/netty/handler/codec/http2/StreamBufferingEncoder.java b/codec-http2/src/main/java/io/netty/handler/codec/http2/StreamBufferingEncoder.java index 60a5588db4..2120520b88 100644 --- a/codec-http2/src/main/java/io/netty/handler/codec/http2/StreamBufferingEncoder.java +++ b/codec-http2/src/main/java/io/netty/handler/codec/http2/StreamBufferingEncoder.java @@ -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 pendingStreams = new TreeMap(); + private final TreeMap 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 frames = new ArrayDeque(2); + final Queue frames = new ArrayDeque<>(2); PendingStream(ChannelHandlerContext ctx, int streamId) { this.ctx = ctx; diff --git a/codec-http2/src/main/java/io/netty/handler/codec/http2/UniformStreamByteDistributor.java b/codec-http2/src/main/java/io/netty/handler/codec/http2/UniformStreamByteDistributor.java index 421d3488b2..f02484f1ed 100644 --- a/codec-http2/src/main/java/io/netty/handler/codec/http2/UniformStreamByteDistributor.java +++ b/codec-http2/src/main/java/io/netty/handler/codec/http2/UniformStreamByteDistributor.java @@ -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 queue = new ArrayDeque(4); + private final Deque queue = new ArrayDeque<>(4); /** * The minimum number of bytes that we will attempt to allocate to a stream. This is to diff --git a/codec-http2/src/main/java/io/netty/handler/codec/http2/WeightedFairQueueByteDistributor.java b/codec-http2/src/main/java/io/netty/handler/codec/http2/WeightedFairQueueByteDistributor.java index 461c3a72a3..4c996d3f55 100644 --- a/codec-http2/src/main/java/io/netty/handler/codec/http2/WeightedFairQueueByteDistributor.java +++ b/codec-http2/src/main/java/io/netty/handler/codec/http2/WeightedFairQueueByteDistributor.java @@ -105,7 +105,7 @@ public final class WeightedFairQueueByteDistributor implements StreamByteDistrib stateOnlyMap = new IntObjectHashMap(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(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 events = new ArrayList(1); + List 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 events = new ArrayList(1); + List 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 events; if (newParent.isDescendantOf(state)) { - events = new ArrayList(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(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(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 events = new ArrayList(1 + child.children.size()); + List events = new ArrayList<>(1 + child.children.size()); events.add(new ParentChangedEvent(child, child.parent)); child.setParent(null); diff --git a/codec-http2/src/test/java/io/netty/handler/codec/http2/CleartextHttp2ServerUpgradeHandlerTest.java b/codec-http2/src/test/java/io/netty/handler/codec/http2/CleartextHttp2ServerUpgradeHandlerTest.java index a544054b66..49b65fa61a 100644 --- a/codec-http2/src/test/java/io/netty/handler/codec/http2/CleartextHttp2ServerUpgradeHandlerTest.java +++ b/codec-http2/src/test/java/io/netty/handler/codec/http2/CleartextHttp2ServerUpgradeHandlerTest.java @@ -70,7 +70,7 @@ public class CleartextHttp2ServerUpgradeHandlerTest { } }; - userEvents = new ArrayList(); + 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(); + userEvents = new ArrayList<>(); HttpServerCodec httpServerCodec = new HttpServerCodec(); HttpServerUpgradeHandler upgradeHandler = new HttpServerUpgradeHandler(httpServerCodec, upgradeCodecFactory); diff --git a/codec-http2/src/test/java/io/netty/handler/codec/http2/DefaultHttp2ConnectionEncoderTest.java b/codec-http2/src/test/java/io/netty/handler/codec/http2/DefaultHttp2ConnectionEncoderTest.java index 9ca7b1fee1..2cda78d8c2 100644 --- a/codec-http2/src/test/java/io/netty/handler/codec/http2/DefaultHttp2ConnectionEncoderTest.java +++ b/codec-http2/src/test/java/io/netty/handler/codec/http2/DefaultHttp2ConnectionEncoderTest.java @@ -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(); - writtenPadding = new ArrayList(); + writtenData = new ArrayList<>(); + writtenPadding = new ArrayList<>(); when(writer.writeData(eq(ctx), anyInt(), any(ByteBuf.class), anyInt(), anyBoolean(), any(ChannelPromise.class))).then(new Answer() { @Override diff --git a/codec-http2/src/test/java/io/netty/handler/codec/http2/HashCollisionTest.java b/codec-http2/src/test/java/io/netty/handler/codec/http2/HashCollisionTest.java index 4fe437a737..9cd8d9bd07 100644 --- a/codec-http2/src/test/java/io/netty/handler/codec/http2/HashCollisionTest.java +++ b/codec-http2/src/test/java/io/netty/handler/codec/http2/HashCollisionTest.java @@ -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 strings = new ArrayList(350000); + List strings = new ArrayList<>(350000); addHttpHeaderNames(strings); addHttpHeaderValues(strings); addHttp2HeaderNames(strings); @@ -118,14 +118,14 @@ public final class HashCollisionTest { private static Map> calculateDuplicates(List strings, Function hasher) { - Map> hashResults = new HashMap>(); - Set duplicateHashCodes = new HashSet(); + Map> hashResults = new HashMap<>(); + Set duplicateHashCodes = new HashSet<>(); for (CharSequence str : strings) { Integer hash = hasher.apply(str); List results = hashResults.get(hash); if (results == null) { - results = new ArrayList(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> duplicates = - new HashMap>(duplicateHashCodes.size()); + new HashMap<>(duplicateHashCodes.size()); for (Integer duplicateHashCode : duplicateHashCodes) { - List realDups = new ArrayList(2); + List realDups = new ArrayList<>(2); Iterator itr = hashResults.get(duplicateHashCode).iterator(); // there should be at least 2 elements in the list ... bcz there may be duplicates realDups.add(itr.next()); diff --git a/codec-http2/src/test/java/io/netty/handler/codec/http2/HpackTest.java b/codec-http2/src/test/java/io/netty/handler/codec/http2/HpackTest.java index fe9fa32601..5238611d39 100644 --- a/codec-http2/src/test/java/io/netty/handler/codec/http2/HpackTest.java +++ b/codec-http2/src/test/java/io/netty/handler/codec/http2/HpackTest.java @@ -61,7 +61,7 @@ public class HpackTest { throw new NullPointerException("files"); } - ArrayList data = new ArrayList(); + ArrayList data = new ArrayList<>(); for (File file : files) { data.add(new Object[]{file.getName()}); } diff --git a/codec-http2/src/test/java/io/netty/handler/codec/http2/HpackTestCase.java b/codec-http2/src/test/java/io/netty/handler/codec/http2/HpackTestCase.java index 33faa50f62..a4dca23a09 100644 --- a/codec-http2/src/test/java/io/netty/handler/codec/http2/HpackTestCase.java +++ b/codec-http2/src/test/java/io/netty/handler/codec/http2/HpackTestCase.java @@ -95,7 +95,7 @@ final class HpackTestCase { "\nACTUAL:\n" + StringUtil.toHexString(actual)); } - List actualDynamicTable = new ArrayList(); + List actualDynamicTable = new ArrayList<>(); for (int index = 0; index < hpackEncoder.length(); index++) { actualDynamicTable.add(hpackEncoder.getHeaderField(index)); } @@ -123,7 +123,7 @@ final class HpackTestCase { List actualHeaders = decode(hpackDecoder, headerBlock.encodedBytes); - List expectedHeaders = new ArrayList(); + List 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 actualDynamicTable = new ArrayList(); + List 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 decode(HpackDecoder hpackDecoder, byte[] expected) throws Exception { ByteBuf in = Unpooled.wrappedBuffer(expected); try { - List headers = new ArrayList(); + List headers = new ArrayList<>(); TestHeaderListener listener = new TestHeaderListener(headers); hpackDecoder.decode(0, in, listener, true); return headers; diff --git a/codec-http2/src/test/java/io/netty/handler/codec/http2/Http2ConnectionRoundtripTest.java b/codec-http2/src/test/java/io/netty/handler/codec/http2/Http2ConnectionRoundtripTest.java index 25e3c6ceaf..e6699bb5f5 100644 --- a/codec-http2/src/test/java/io/netty/handler/codec/http2/Http2ConnectionRoundtripTest.java +++ b/codec-http2/src/test/java/io/netty/handler/codec/http2/Http2ConnectionRoundtripTest.java @@ -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 clientHeadersWriteException = new AtomicReference(); - final AtomicReference clientHeadersWriteException2 = new AtomicReference(); - final AtomicReference clientDataWriteException = new AtomicReference(); + final AtomicReference clientHeadersWriteException = new AtomicReference<>(); + final AtomicReference clientHeadersWriteException2 = new AtomicReference<>(); + final AtomicReference 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 serverWriteHeadersCauseRef = new AtomicReference(); + final AtomicReference 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 clientWriteAfterGoAwayFutureRef = new AtomicReference(); + final AtomicReference 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 clientWriteAfterGoAwayFutureRef = new AtomicReference(); + final AtomicReference clientWriteAfterGoAwayFutureRef = new AtomicReference<>(); final CountDownLatch clientWriteAfterGoAwayLatch = new CountDownLatch(1); doAnswer(new Answer() { @Override @@ -1189,7 +1189,7 @@ public class Http2ConnectionRoundtripTest { sb = new ServerBootstrap(); cb = new Bootstrap(); - final AtomicReference serverHandlerRef = new AtomicReference(); + final AtomicReference serverHandlerRef = new AtomicReference<>(); final CountDownLatch serverInitLatch = new CountDownLatch(1); sb.group(new LocalEventLoopGroup()); sb.channel(LocalServerChannel.class); diff --git a/codec-http2/src/test/java/io/netty/handler/codec/http2/Http2FrameCodecTest.java b/codec-http2/src/test/java/io/netty/handler/codec/http2/Http2FrameCodecTest.java index 27d13cf50b..8800368b67 100644 --- a/codec-http2/src/test/java/io/netty/handler/codec/http2/Http2FrameCodecTest.java +++ b/codec-http2/src/test/java/io/netty/handler/codec/http2/Http2FrameCodecTest.java @@ -570,7 +570,7 @@ public class Http2FrameCodecTest { assertNotNull(stream); assertFalse(isStreamIdValid(stream.id())); - final Promise listenerExecuted = new DefaultPromise(GlobalEventExecutor.INSTANCE); + final Promise 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 activeStreams = new HashSet(); + final Set 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 expectedStreams = new HashSet(); + Set expectedStreams = new HashSet<>(); expectedStreams.add(activeInbond); expectedStreams.add(activeOutbound); assertEquals(expectedStreams, activeStreams); diff --git a/codec-http2/src/test/java/io/netty/handler/codec/http2/Http2FrameRoundtripTest.java b/codec-http2/src/test/java/io/netty/handler/codec/http2/Http2FrameRoundtripTest.java index cf938a1332..dc7348004a 100644 --- a/codec-http2/src/test/java/io/netty/handler/codec/http2/Http2FrameRoundtripTest.java +++ b/codec-http2/src/test/java/io/netty/handler/codec/http2/Http2FrameRoundtripTest.java @@ -88,7 +88,7 @@ public class Http2FrameRoundtripTest { private Http2FrameWriter writer; private Http2FrameReader reader; - private final List needReleasing = new LinkedList(); + private final List needReleasing = new LinkedList<>(); @Before public void setup() throws Exception { diff --git a/codec-http2/src/test/java/io/netty/handler/codec/http2/Http2MultiplexCodecTest.java b/codec-http2/src/test/java/io/netty/handler/codec/http2/Http2MultiplexCodecTest.java index 7788e6dd64..20d6c4b937 100644 --- a/codec-http2/src/test/java/io/netty/handler/codec/http2/Http2MultiplexCodecTest.java +++ b/codec-http2/src/test/java/io/netty/handler/codec/http2/Http2MultiplexCodecTest.java @@ -155,7 +155,7 @@ public class Http2MultiplexCodecTest { private Http2StreamChannel newInboundStream(int streamId, boolean endStream, AtomicInteger maxReads, final ChannelHandler childHandler) { - final AtomicReference streamChannelRef = new AtomicReference(); + final AtomicReference streamChannelRef = new AtomicReference<>(); childChannelInitializer.maxReads = maxReads; childChannelInitializer.handler = new ChannelInboundHandlerAdapter() { @Override @@ -595,7 +595,7 @@ public class Http2MultiplexCodecTest { @Test public void channelClosedWhenWriteFutureFails() { - final Queue writePromises = new ArrayDeque(); + final Queue writePromises = new ArrayDeque<>(); LastInboundHandler inboundHandler = new LastInboundHandler(); Http2StreamChannel childChannel = newInboundStream(3, false, inboundHandler); diff --git a/codec-http2/src/test/java/io/netty/handler/codec/http2/Http2StreamFrameToHttpObjectCodecTest.java b/codec-http2/src/test/java/io/netty/handler/codec/http2/Http2StreamFrameToHttpObjectCodecTest.java index 393a4060ef..e04c6db56d 100644 --- a/codec-http2/src/test/java/io/netty/handler/codec/http2/Http2StreamFrameToHttpObjectCodecTest.java +++ b/codec-http2/src/test/java/io/netty/handler/codec/http2/Http2StreamFrameToHttpObjectCodecTest.java @@ -446,7 +446,7 @@ public class Http2StreamFrameToHttpObjectCodecTest { @Test public void testEncodeHttpsSchemeWhenSslHandlerExists() throws Exception { - final Queue frames = new ConcurrentLinkedQueue(); + final Queue 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 frames = new ConcurrentLinkedQueue(); + final Queue frames = new ConcurrentLinkedQueue<>(); final ChannelHandler sharedHandler = new Http2StreamFrameToHttpObjectCodec(false); final SslContext ctx = SslContextBuilder.forClient().sslProvider(SslProvider.JDK).build(); diff --git a/codec-http2/src/test/java/io/netty/handler/codec/http2/Http2TestUtil.java b/codec-http2/src/test/java/io/netty/handler/codec/http2/Http2TestUtil.java index f660381237..75ca0f4893 100644 --- a/codec-http2/src/test/java/io/netty/handler/codec/http2/Http2TestUtil.java +++ b/codec-http2/src/test/java/io/netty/handler/codec/http2/Http2TestUtil.java @@ -572,7 +572,7 @@ public final class Http2TestUtil { } }; - final ConcurrentLinkedQueue buffers = new ConcurrentLinkedQueue(); + final ConcurrentLinkedQueue buffers = new ConcurrentLinkedQueue<>(); Http2FrameWriter frameWriter = Mockito.mock(Http2FrameWriter.class); doAnswer(new Answer() { diff --git a/codec-http2/src/test/java/io/netty/handler/codec/http2/HttpToHttp2ConnectionHandlerTest.java b/codec-http2/src/test/java/io/netty/handler/codec/http2/HttpToHttp2ConnectionHandlerTest.java index b5925df741..c9eb9eca6d 100644 --- a/codec-http2/src/test/java/io/netty/handler/codec/http2/HttpToHttp2ConnectionHandlerTest.java +++ b/codec-http2/src/test/java/io/netty/handler/codec/http2/HttpToHttp2ConnectionHandlerTest.java @@ -335,7 +335,7 @@ public class HttpToHttp2ConnectionHandlerTest { @Test public void testRequestWithBody() throws Exception { final String text = "foooooogoooo"; - final List receivedBuffers = Collections.synchronizedList(new ArrayList()); + final List receivedBuffers = Collections.synchronizedList(new ArrayList<>()); doAnswer(new Answer() { @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 receivedBuffers = Collections.synchronizedList(new ArrayList()); + final List receivedBuffers = Collections.synchronizedList(new ArrayList<>()); doAnswer(new Answer() { @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 receivedBuffers = Collections.synchronizedList(new ArrayList()); + final List receivedBuffers = Collections.synchronizedList(new ArrayList<>()); doAnswer(new Answer() { @Override public Void answer(InvocationOnMock in) throws Throwable { diff --git a/codec-http2/src/test/java/io/netty/handler/codec/http2/LastInboundHandler.java b/codec-http2/src/test/java/io/netty/handler/codec/http2/LastInboundHandler.java index 38f400af14..a3278c9b80 100644 --- a/codec-http2/src/test/java/io/netty/handler/codec/http2/LastInboundHandler.java +++ b/codec-http2/src/test/java/io/netty/handler/codec/http2/LastInboundHandler.java @@ -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 queue = new ArrayList(); + private final List queue = new ArrayList<>(); private final Consumer channelReadCompleteConsumer; private Throwable lastException; private ChannelHandlerContext ctx; diff --git a/codec-http2/src/test/java/io/netty/handler/codec/http2/StreamBufferingEncoderTest.java b/codec-http2/src/test/java/io/netty/handler/codec/http2/StreamBufferingEncoderTest.java index 15dc168b4d..6a42e37d45 100644 --- a/codec-http2/src/test/java/io/netty/handler/codec/http2/StreamBufferingEncoderTest.java +++ b/codec-http2/src/test/java/io/netty/handler/codec/http2/StreamBufferingEncoderTest.java @@ -240,7 +240,7 @@ public class StreamBufferingEncoderTest { setMaxConcurrentStreams(5); int streamId = 3; - List futures = new ArrayList(); + List futures = new ArrayList<>(); for (int i = 0; i < 9; i++) { futures.add(encoderWriteHeaders(streamId, newPromise())); streamId += 2; diff --git a/codec-mqtt/src/main/java/io/netty/handler/codec/mqtt/MqttConnectReturnCode.java b/codec-mqtt/src/main/java/io/netty/handler/codec/mqtt/MqttConnectReturnCode.java index 802dc196f9..735b3542ca 100644 --- a/codec-mqtt/src/main/java/io/netty/handler/codec/mqtt/MqttConnectReturnCode.java +++ b/codec-mqtt/src/main/java/io/netty/handler/codec/mqtt/MqttConnectReturnCode.java @@ -34,7 +34,7 @@ public enum MqttConnectReturnCode { private static final Map VALUE_TO_CODE_MAP; static { - final Map valueMap = new HashMap(); + final Map valueMap = new HashMap<>(); for (MqttConnectReturnCode code: values()) { valueMap.put(code.byteValue, code); } diff --git a/codec-mqtt/src/main/java/io/netty/handler/codec/mqtt/MqttDecoder.java b/codec-mqtt/src/main/java/io/netty/handler/codec/mqtt/MqttDecoder.java index e93d34bde1..db1234ae1c 100644 --- a/codec-mqtt/src/main/java/io/netty/handler/codec/mqtt/MqttDecoder.java +++ b/codec-mqtt/src/main/java/io/netty/handler/codec/mqtt/MqttDecoder.java @@ -201,9 +201,9 @@ public final class MqttDecoder extends ReplayingDecoder { case PINGRESP: case DISCONNECT: // Empty variable header - return new Result(null, 0); + return new Result<>(null, 0); } - return new Result(null, 0); //should never reach here + return new Result<>(null, 0); //should never reach here } private static Result decodeConnectionVariableHeader(ByteBuf buffer) { @@ -247,7 +247,7 @@ public final class MqttDecoder extends ReplayingDecoder { willFlag, cleanSession, keepAlive.value); - return new Result(mqttConnectVariableHeader, numberOfBytesConsumed); + return new Result<>(mqttConnectVariableHeader, numberOfBytesConsumed); } private static Result decodeConnAckVariableHeader(ByteBuf buffer) { @@ -256,12 +256,12 @@ public final class MqttDecoder extends ReplayingDecoder { final int numberOfBytesConsumed = 2; final MqttConnAckVariableHeader mqttConnAckVariableHeader = new MqttConnAckVariableHeader(MqttConnectReturnCode.valueOf(returnCode), sessionPresent); - return new Result(mqttConnAckVariableHeader, numberOfBytesConsumed); + return new Result<>(mqttConnAckVariableHeader, numberOfBytesConsumed); } private static Result decodeMessageIdVariableHeader(ByteBuf buffer) { final Result messageId = decodeMessageId(buffer); - return new Result( + return new Result<>( MqttMessageIdVariableHeader.from(messageId.value), messageId.numberOfBytesConsumed); } @@ -283,7 +283,7 @@ public final class MqttDecoder extends ReplayingDecoder { } final MqttPublishVariableHeader mqttPublishVariableHeader = new MqttPublishVariableHeader(decodedTopic.value, messageId); - return new Result(mqttPublishVariableHeader, numberOfBytesConsumed); + return new Result<>(mqttPublishVariableHeader, numberOfBytesConsumed); } private static Result decodeMessageId(ByteBuf buffer) { @@ -326,7 +326,7 @@ public final class MqttDecoder extends ReplayingDecoder { default: // unknown payload , no byte consumed - return new Result(null, 0); + return new Result<>(null, 0); } } @@ -368,13 +368,13 @@ public final class MqttDecoder extends ReplayingDecoder { decodedWillMessage != null ? decodedWillMessage.value : null, decodedUserName != null ? decodedUserName.value : null, decodedPassword != null ? decodedPassword.value : null); - return new Result(mqttConnectPayload, numberOfBytesConsumed); + return new Result<>(mqttConnectPayload, numberOfBytesConsumed); } private static Result decodeSubscribePayload( ByteBuf buffer, int bytesRemainingInVariablePart) { - final List subscribeTopics = new ArrayList(); + final List subscribeTopics = new ArrayList<>(); int numberOfBytesConsumed = 0; while (numberOfBytesConsumed < bytesRemainingInVariablePart) { final Result decodedTopicName = decodeString(buffer); @@ -383,13 +383,13 @@ public final class MqttDecoder extends ReplayingDecoder { numberOfBytesConsumed++; subscribeTopics.add(new MqttTopicSubscription(decodedTopicName.value, MqttQoS.valueOf(qos))); } - return new Result(new MqttSubscribePayload(subscribeTopics), numberOfBytesConsumed); + return new Result<>(new MqttSubscribePayload(subscribeTopics), numberOfBytesConsumed); } private static Result decodeSubackPayload( ByteBuf buffer, int bytesRemainingInVariablePart) { - final List grantedQos = new ArrayList(); + final List grantedQos = new ArrayList<>(); int numberOfBytesConsumed = 0; while (numberOfBytesConsumed < bytesRemainingInVariablePart) { int qos = buffer.readUnsignedByte(); @@ -399,27 +399,27 @@ public final class MqttDecoder extends ReplayingDecoder { numberOfBytesConsumed++; grantedQos.add(qos); } - return new Result(new MqttSubAckPayload(grantedQos), numberOfBytesConsumed); + return new Result<>(new MqttSubAckPayload(grantedQos), numberOfBytesConsumed); } private static Result decodeUnsubscribePayload( ByteBuf buffer, int bytesRemainingInVariablePart) { - final List unsubscribeTopics = new ArrayList(); + final List unsubscribeTopics = new ArrayList<>(); int numberOfBytesConsumed = 0; while (numberOfBytesConsumed < bytesRemainingInVariablePart) { final Result decodedTopicName = decodeString(buffer); numberOfBytesConsumed += decodedTopicName.numberOfBytesConsumed; unsubscribeTopics.add(decodedTopicName.value); } - return new Result( + return new Result<>( new MqttUnsubscribePayload(unsubscribeTopics), numberOfBytesConsumed); } private static Result decodePublishPayload(ByteBuf buffer, int bytesRemainingInVariablePart) { ByteBuf b = buffer.readRetainedSlice(bytesRemainingInVariablePart); - return new Result(b, bytesRemainingInVariablePart); + return new Result<>(b, bytesRemainingInVariablePart); } private static Result decodeString(ByteBuf buffer) { @@ -433,12 +433,12 @@ public final class MqttDecoder extends ReplayingDecoder { if (size < minBytes || size > maxBytes) { buffer.skipBytes(size); numberOfBytesConsumed += size; - return new Result(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(s, numberOfBytesConsumed); + return new Result<>(s, numberOfBytesConsumed); } private static Result decodeByteArray(ByteBuf buffer) { @@ -446,7 +446,7 @@ public final class MqttDecoder extends ReplayingDecoder { int size = decodedSize.value; byte[] bytes = new byte[size]; buffer.readBytes(bytes); - return new Result(bytes, decodedSize.numberOfBytesConsumed + size); + return new Result<>(bytes, decodedSize.numberOfBytesConsumed + size); } private static Result decodeMsbLsb(ByteBuf buffer) { @@ -461,7 +461,7 @@ public final class MqttDecoder extends ReplayingDecoder { if (result < min || result > max) { result = -1; } - return new Result(result, numberOfBytesConsumed); + return new Result<>(result, numberOfBytesConsumed); } private static final class Result { diff --git a/codec-mqtt/src/main/java/io/netty/handler/codec/mqtt/MqttMessageBuilders.java b/codec-mqtt/src/main/java/io/netty/handler/codec/mqtt/MqttMessageBuilders.java index 2bb0eaa3eb..01b9bb5304 100644 --- a/codec-mqtt/src/main/java/io/netty/handler/codec/mqtt/MqttMessageBuilders.java +++ b/codec-mqtt/src/main/java/io/netty/handler/codec/mqtt/MqttMessageBuilders.java @@ -200,7 +200,7 @@ public final class MqttMessageBuilders { public SubscribeBuilder addSubscription(MqttQoS qos, String topic) { if (subscriptions == null) { - subscriptions = new ArrayList(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(5); + topicFilters = new ArrayList<>(5); } topicFilters.add(topic); return this; diff --git a/codec-mqtt/src/main/java/io/netty/handler/codec/mqtt/MqttSubAckPayload.java b/codec-mqtt/src/main/java/io/netty/handler/codec/mqtt/MqttSubAckPayload.java index 0e8c909ba4..6b658f808e 100644 --- a/codec-mqtt/src/main/java/io/netty/handler/codec/mqtt/MqttSubAckPayload.java +++ b/codec-mqtt/src/main/java/io/netty/handler/codec/mqtt/MqttSubAckPayload.java @@ -34,7 +34,7 @@ public class MqttSubAckPayload { throw new NullPointerException("grantedQoSLevels"); } - List list = new ArrayList(grantedQoSLevels.length); + List 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 list = new ArrayList(); + List list = new ArrayList<>(); for (Integer v: grantedQoSLevels) { if (v == null) { break; diff --git a/codec-mqtt/src/test/java/io/netty/handler/codec/mqtt/MqttCodecTest.java b/codec-mqtt/src/test/java/io/netty/handler/codec/mqtt/MqttCodecTest.java index 927334cb1d..db6fbcf5b6 100644 --- a/codec-mqtt/src/test/java/io/netty/handler/codec/mqtt/MqttCodecTest.java +++ b/codec-mqtt/src/test/java/io/netty/handler/codec/mqtt/MqttCodecTest.java @@ -74,7 +74,7 @@ public class MqttCodecTest { final MqttConnectMessage message = createConnectMessage(MqttVersion.MQTT_3_1); ByteBuf byteBuf = MqttEncoder.doEncode(ALLOCATOR, message); - final List out = new LinkedList(); + final List 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 out = new LinkedList(); + final List 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 out = new LinkedList(); + final List 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 out = new LinkedList(); + final List 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 out = new LinkedList(); + final List 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 out = new LinkedList(); + final List 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 out = new LinkedList(); + final List 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 out = new LinkedList(); + List 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 out = new LinkedList(); + final List 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 out = new LinkedList(); + final List 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 out = new LinkedList(); + final List 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 out = new LinkedList(); + final List 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 out = new LinkedList(); + final List 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 out = new LinkedList(); + final List 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 out = new LinkedList(); + final List 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 out = new LinkedList(); + final List 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 out = new LinkedList(); + final List 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 out = new LinkedList(); + final List 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 out = new LinkedList(); + final List 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 topicSubscriptions = new LinkedList(); + List 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 topics = new LinkedList(); + List topics = new LinkedList<>(); topics.add("/abc"); topics.add("/def"); topics.add("/xyz"); diff --git a/codec-redis/src/main/java/io/netty/handler/codec/redis/FixedRedisMessagePool.java b/codec-redis/src/main/java/io/netty/handler/codec/redis/FixedRedisMessagePool.java index 0508f2e3dc..e1fe69a3fd 100644 --- a/codec-redis/src/main/java/io/netty/handler/codec/redis/FixedRedisMessagePool.java +++ b/codec-redis/src/main/java/io/netty/handler/codec/redis/FixedRedisMessagePool.java @@ -83,8 +83,8 @@ public final class FixedRedisMessagePool implements RedisMessagePool { * Creates a {@link FixedRedisMessagePool} instance. */ private FixedRedisMessagePool() { - byteBufToSimpleStrings = new HashMap(DEFAULT_SIMPLE_STRINGS.length, 1.0f); - stringToSimpleStrings = new HashMap(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(DEFAULT_ERRORS.length, 1.0f); - stringToErrors = new HashMap(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(SIZE_CACHED_INTEGER_NUMBER, 1.0f); + byteBufToIntegers = new HashMap<>(SIZE_CACHED_INTEGER_NUMBER, 1.0f); longToIntegers = new LongObjectHashMap(SIZE_CACHED_INTEGER_NUMBER, 1.0f); longToByteBufs = new LongObjectHashMap(SIZE_CACHED_INTEGER_NUMBER, 1.0f); for (long value = MIN_CACHED_INTEGER_NUMBER; value < MAX_CACHED_INTEGER_NUMBER; value++) { diff --git a/codec-redis/src/main/java/io/netty/handler/codec/redis/RedisArrayAggregator.java b/codec-redis/src/main/java/io/netty/handler/codec/redis/RedisArrayAggregator.java index d189ab2ea9..513a0a1bdd 100644 --- a/codec-redis/src/main/java/io/netty/handler/codec/redis/RedisArrayAggregator.java +++ b/codec-redis/src/main/java/io/netty/handler/codec/redis/RedisArrayAggregator.java @@ -33,7 +33,7 @@ import java.util.List; @UnstableApi public final class RedisArrayAggregator extends MessageToMessageDecoder { - private final Deque depths = new ArrayDeque(4); + private final Deque depths = new ArrayDeque<>(4); @Override protected void decode(ChannelHandlerContext ctx, RedisMessage msg, List out) throws Exception { @@ -87,7 +87,7 @@ public final class RedisArrayAggregator extends MessageToMessageDecoder children; AggregateState(int length) { this.length = length; - this.children = new ArrayList(length); + this.children = new ArrayList<>(length); } } } diff --git a/codec-redis/src/test/java/io/netty/handler/codec/redis/RedisEncoderTest.java b/codec-redis/src/test/java/io/netty/handler/codec/redis/RedisEncoderTest.java index 926b62116a..9e4f88d26d 100644 --- a/codec-redis/src/test/java/io/netty/handler/codec/redis/RedisEncoderTest.java +++ b/codec-redis/src/test/java/io/netty/handler/codec/redis/RedisEncoderTest.java @@ -127,7 +127,7 @@ public class RedisEncoderTest { @Test public void shouldEncodeSimpleArray() { - List children = new ArrayList(); + List 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 grandChildren = new ArrayList(); + List grandChildren = new ArrayList<>(); grandChildren.add(new FullBulkStringRedisMessage(byteBufOf("bar"))); grandChildren.add(new IntegerRedisMessage(-1234L)); - List children = new ArrayList(); + List children = new ArrayList<>(); children.add(new SimpleStringRedisMessage("foo")); children.add(new ArrayRedisMessage(grandChildren)); RedisMessage msg = new ArrayRedisMessage(children); diff --git a/codec-smtp/src/main/java/io/netty/handler/codec/smtp/SmtpCommand.java b/codec-smtp/src/main/java/io/netty/handler/codec/smtp/SmtpCommand.java index 63ba3f5847..da1d9b5ace 100644 --- a/codec-smtp/src/main/java/io/netty/handler/codec/smtp/SmtpCommand.java +++ b/codec-smtp/src/main/java/io/netty/handler/codec/smtp/SmtpCommand.java @@ -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 COMMANDS = new HashMap(); + private static final Map COMMANDS = new HashMap<>(); static { COMMANDS.put(EHLO.name().toString(), EHLO); COMMANDS.put(HELO.name().toString(), HELO); diff --git a/codec-smtp/src/main/java/io/netty/handler/codec/smtp/SmtpRequests.java b/codec-smtp/src/main/java/io/netty/handler/codec/smtp/SmtpRequests.java index 2c42c5d69e..cd217f34d8 100644 --- a/codec-smtp/src/main/java/io/netty/handler/codec/smtp/SmtpRequests.java +++ b/codec-smtp/src/main/java/io/netty/handler/codec/smtp/SmtpRequests.java @@ -92,7 +92,7 @@ public final class SmtpRequests { return new DefaultSmtpRequest(SmtpCommand.MAIL, sender != null ? "FROM:<" + sender + '>' : FROM_NULL_SENDER); } else { - List params = new ArrayList(mailParameters.length + 1); + List 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 params = new ArrayList(rcptParameters.length + 1); + List params = new ArrayList<>(rcptParameters.length + 1); params.add("TO:<" + recipient + '>'); for (CharSequence param : rcptParameters) { params.add(param); diff --git a/codec-smtp/src/main/java/io/netty/handler/codec/smtp/SmtpResponseDecoder.java b/codec-smtp/src/main/java/io/netty/handler/codec/smtp/SmtpResponseDecoder.java index eadea32654..96c75636dd 100644 --- a/codec-smtp/src/main/java/io/netty/handler/codec/smtp/SmtpResponseDecoder.java +++ b/codec-smtp/src/main/java/io/netty/handler/codec/smtp/SmtpResponseDecoder.java @@ -82,7 +82,7 @@ public final class SmtpResponseDecoder extends LineBasedFrameDecoder { if (details == null) { // Using initial capacity as it is very unlikely that we will receive a multi-line response // with more then 3 lines. - this.details = details = new ArrayList(4); + this.details = details = new ArrayList<>(4); } details.add(detail); } diff --git a/codec-socks/src/main/java/io/netty/handler/codec/socks/SocksInitRequestDecoder.java b/codec-socks/src/main/java/io/netty/handler/codec/socks/SocksInitRequestDecoder.java index e866d876cc..aeb8176a8f 100644 --- a/codec-socks/src/main/java/io/netty/handler/codec/socks/SocksInitRequestDecoder.java +++ b/codec-socks/src/main/java/io/netty/handler/codec/socks/SocksInitRequestDecoder.java @@ -48,7 +48,7 @@ public class SocksInitRequestDecoder extends ReplayingDecoder { final byte authSchemeNum = byteBuf.readByte(); final List authSchemes; if (authSchemeNum > 0) { - authSchemes = new ArrayList(authSchemeNum); + authSchemes = new ArrayList<>(authSchemeNum); for (int i = 0; i < authSchemeNum; i++) { authSchemes.add(SocksAuthScheme.valueOf(byteBuf.readByte())); } diff --git a/codec-socks/src/main/java/io/netty/handler/codec/socksx/v5/DefaultSocks5InitialRequest.java b/codec-socks/src/main/java/io/netty/handler/codec/socksx/v5/DefaultSocks5InitialRequest.java index 0610e04993..3c7cf3eee9 100755 --- a/codec-socks/src/main/java/io/netty/handler/codec/socksx/v5/DefaultSocks5InitialRequest.java +++ b/codec-socks/src/main/java/io/netty/handler/codec/socksx/v5/DefaultSocks5InitialRequest.java @@ -34,7 +34,7 @@ public class DefaultSocks5InitialRequest extends AbstractSocks5Message implement throw new NullPointerException("authMethods"); } - List list = new ArrayList(authMethods.length); + List list = new ArrayList<>(authMethods.length); for (Socks5AuthMethod m: authMethods) { if (m == null) { break; @@ -54,7 +54,7 @@ public class DefaultSocks5InitialRequest extends AbstractSocks5Message implement throw new NullPointerException("authSchemes"); } - List list = new ArrayList(); + List list = new ArrayList<>(); for (Socks5AuthMethod m: authMethods) { if (m == null) { break; diff --git a/codec-xml/src/main/java/io/netty/handler/codec/xml/XmlElement.java b/codec-xml/src/main/java/io/netty/handler/codec/xml/XmlElement.java index 885e814a09..138bd7c1a2 100644 --- a/codec-xml/src/main/java/io/netty/handler/codec/xml/XmlElement.java +++ b/codec-xml/src/main/java/io/netty/handler/codec/xml/XmlElement.java @@ -28,7 +28,7 @@ public abstract class XmlElement { private final String namespace; private final String prefix; - private final List namespaces = new LinkedList(); + private final List namespaces = new LinkedList<>(); protected XmlElement(String name, String namespace, String prefix) { this.name = name; diff --git a/codec-xml/src/main/java/io/netty/handler/codec/xml/XmlElementStart.java b/codec-xml/src/main/java/io/netty/handler/codec/xml/XmlElementStart.java index 17d603eb4c..12479dddd7 100644 --- a/codec-xml/src/main/java/io/netty/handler/codec/xml/XmlElementStart.java +++ b/codec-xml/src/main/java/io/netty/handler/codec/xml/XmlElementStart.java @@ -23,7 +23,7 @@ import java.util.List; */ public class XmlElementStart extends XmlElement { - private final List attributes = new LinkedList(); + private final List attributes = new LinkedList<>(); public XmlElementStart(String name, String namespace, String prefix) { super(name, namespace, prefix); diff --git a/codec/src/main/java/io/netty/handler/codec/DefaultHeaders.java b/codec/src/main/java/io/netty/handler/codec/DefaultHeaders.java index df7266d9e8..3fdc325bdf 100644 --- a/codec/src/main/java/io/netty/handler/codec/DefaultHeaders.java +++ b/codec/src/main/java/io/netty/handler/codec/DefaultHeaders.java @@ -110,7 +110,7 @@ public class DefaultHeaders> implements Headers // than the length of this array, and we want the mask to be > 0. entries = new DefaultHeaders.HeaderEntry[findNextPositivePowerOfTwo(max(2, min(arraySizeHint, 128)))]; hashMask = (byte) (entries.length - 1); - head = new HeaderEntry(); + head = new HeaderEntry<>(); } @Override @@ -160,7 +160,7 @@ public class DefaultHeaders> implements Headers public List getAll(K name) { checkNotNull(name, "name"); - LinkedList values = new LinkedList(); + LinkedList values = new LinkedList<>(); int h = hashingStrategy.hashCode(name); int i = index(h); @@ -281,7 +281,7 @@ public class DefaultHeaders> implements Headers if (isEmpty()) { return Collections.emptySet(); } - Set names = new LinkedHashSet(size()); + Set names = new LinkedHashSet<>(size()); HeaderEntry e = head.after; while (e != head) { names.add(e.getKey()); @@ -958,7 +958,7 @@ public class DefaultHeaders> implements Headers } protected HeaderEntry newHeaderEntry(int h, K name, V value, HeaderEntry next) { - return new HeaderEntry(h, name, value, next, head); + return new HeaderEntry<>(h, name, value, next, head); } protected ValueConverter valueConverter() { @@ -1021,7 +1021,7 @@ public class DefaultHeaders> implements Headers * Returns a deep copy of this instance. */ public DefaultHeaders copy() { - DefaultHeaders copy = new DefaultHeaders( + DefaultHeaders copy = new DefaultHeaders<>( hashingStrategy, valueConverter, nameValidator, entries.length); copy.addImpl(this); return copy; diff --git a/codec/src/main/java/io/netty/handler/codec/HeadersUtils.java b/codec/src/main/java/io/netty/handler/codec/HeadersUtils.java index 0123cf2e43..385ba157bd 100644 --- a/codec/src/main/java/io/netty/handler/codec/HeadersUtils.java +++ b/codec/src/main/java/io/netty/handler/codec/HeadersUtils.java @@ -232,7 +232,7 @@ public final class HeadersUtils { @Override public Iterator iterator() { - return new StringIterator(allNames.iterator()); + return new StringIterator<>(allNames.iterator()); } @Override diff --git a/codec/src/main/java/io/netty/handler/codec/ProtocolDetectionResult.java b/codec/src/main/java/io/netty/handler/codec/ProtocolDetectionResult.java index d4b435939c..f06a331a9a 100644 --- a/codec/src/main/java/io/netty/handler/codec/ProtocolDetectionResult.java +++ b/codec/src/main/java/io/netty/handler/codec/ProtocolDetectionResult.java @@ -55,7 +55,7 @@ public final class ProtocolDetectionResult { */ @SuppressWarnings("unchecked") public static ProtocolDetectionResult detected(T protocol) { - return new ProtocolDetectionResult(ProtocolDetectionState.DETECTED, checkNotNull(protocol, "protocol")); + return new ProtocolDetectionResult<>(ProtocolDetectionState.DETECTED, checkNotNull(protocol, "protocol")); } private ProtocolDetectionResult(ProtocolDetectionState state, T result) { diff --git a/codec/src/main/java/io/netty/handler/codec/marshalling/ThreadLocalMarshallerProvider.java b/codec/src/main/java/io/netty/handler/codec/marshalling/ThreadLocalMarshallerProvider.java index ce13601491..c0a9fb3bc5 100644 --- a/codec/src/main/java/io/netty/handler/codec/marshalling/ThreadLocalMarshallerProvider.java +++ b/codec/src/main/java/io/netty/handler/codec/marshalling/ThreadLocalMarshallerProvider.java @@ -28,7 +28,7 @@ import org.jboss.marshalling.MarshallingConfiguration; * many small {@link Object}'s and your actual Thread count is not to big */ public class ThreadLocalMarshallerProvider implements MarshallerProvider { - private final FastThreadLocal marshallers = new FastThreadLocal(); + private final FastThreadLocal marshallers = new FastThreadLocal<>(); private final MarshallerFactory factory; private final MarshallingConfiguration config; diff --git a/codec/src/main/java/io/netty/handler/codec/marshalling/ThreadLocalUnmarshallerProvider.java b/codec/src/main/java/io/netty/handler/codec/marshalling/ThreadLocalUnmarshallerProvider.java index 080d48921a..6575507a6d 100644 --- a/codec/src/main/java/io/netty/handler/codec/marshalling/ThreadLocalUnmarshallerProvider.java +++ b/codec/src/main/java/io/netty/handler/codec/marshalling/ThreadLocalUnmarshallerProvider.java @@ -28,7 +28,7 @@ import org.jboss.marshalling.Unmarshaller; * many small {@link Object}'s. */ public class ThreadLocalUnmarshallerProvider implements UnmarshallerProvider { - private final FastThreadLocal unmarshallers = new FastThreadLocal(); + private final FastThreadLocal unmarshallers = new FastThreadLocal<>(); private final MarshallerFactory factory; private final MarshallingConfiguration config; diff --git a/codec/src/main/java/io/netty/handler/codec/serialization/ClassResolvers.java b/codec/src/main/java/io/netty/handler/codec/serialization/ClassResolvers.java index 32250ada80..0f65af4fce 100644 --- a/codec/src/main/java/io/netty/handler/codec/serialization/ClassResolvers.java +++ b/codec/src/main/java/io/netty/handler/codec/serialization/ClassResolvers.java @@ -41,7 +41,7 @@ public final class ClassResolvers { public static ClassResolver weakCachingResolver(ClassLoader classLoader) { return new CachingClassResolver( new ClassLoaderClassResolver(defaultClassLoader(classLoader)), - new WeakReferenceMap>(new HashMap>>())); + new WeakReferenceMap<>(new HashMap<>())); } /** @@ -54,7 +54,7 @@ public final class ClassResolvers { public static ClassResolver softCachingResolver(ClassLoader classLoader) { return new CachingClassResolver( new ClassLoaderClassResolver(defaultClassLoader(classLoader)), - new SoftReferenceMap>(new HashMap>>())); + new SoftReferenceMap<>(new HashMap<>())); } /** @@ -67,7 +67,7 @@ public final class ClassResolvers { public static ClassResolver weakCachingConcurrentResolver(ClassLoader classLoader) { return new CachingClassResolver( new ClassLoaderClassResolver(defaultClassLoader(classLoader)), - new WeakReferenceMap>( + new WeakReferenceMap<>( PlatformDependent.>>newConcurrentHashMap())); } @@ -81,7 +81,7 @@ public final class ClassResolvers { public static ClassResolver softCachingConcurrentResolver(ClassLoader classLoader) { return new CachingClassResolver( new ClassLoaderClassResolver(defaultClassLoader(classLoader)), - new SoftReferenceMap>( + new SoftReferenceMap<>( PlatformDependent.>>newConcurrentHashMap())); } diff --git a/codec/src/main/java/io/netty/handler/codec/serialization/SoftReferenceMap.java b/codec/src/main/java/io/netty/handler/codec/serialization/SoftReferenceMap.java index dcc8fe5af7..c0ac4fcd68 100644 --- a/codec/src/main/java/io/netty/handler/codec/serialization/SoftReferenceMap.java +++ b/codec/src/main/java/io/netty/handler/codec/serialization/SoftReferenceMap.java @@ -27,7 +27,7 @@ final class SoftReferenceMap extends ReferenceMap { @Override Reference fold(V value) { - return new SoftReference(value); + return new SoftReference<>(value); } } diff --git a/codec/src/main/java/io/netty/handler/codec/serialization/WeakReferenceMap.java b/codec/src/main/java/io/netty/handler/codec/serialization/WeakReferenceMap.java index 00e720fbcc..52a213044e 100644 --- a/codec/src/main/java/io/netty/handler/codec/serialization/WeakReferenceMap.java +++ b/codec/src/main/java/io/netty/handler/codec/serialization/WeakReferenceMap.java @@ -27,7 +27,7 @@ final class WeakReferenceMap extends ReferenceMap { @Override Reference fold(V value) { - return new WeakReference(value); + return new WeakReference<>(value); } } diff --git a/codec/src/test/java/io/netty/handler/codec/ByteToMessageDecoderTest.java b/codec/src/test/java/io/netty/handler/codec/ByteToMessageDecoderTest.java index 93dd2218ac..f6982fcafe 100644 --- a/codec/src/test/java/io/netty/handler/codec/ByteToMessageDecoderTest.java +++ b/codec/src/test/java/io/netty/handler/codec/ByteToMessageDecoderTest.java @@ -159,7 +159,7 @@ public class ByteToMessageDecoderTest { @Test public void testFireChannelReadCompleteOnInactive() throws InterruptedException { - final BlockingQueue queue = new LinkedBlockingDeque(); + final BlockingQueue queue = new LinkedBlockingDeque<>(); final ByteBuf buf = Unpooled.buffer().writeBytes(new byte[] {'a', 'b'}); EmbeddedChannel channel = new EmbeddedChannel(new ByteToMessageDecoder() { @Override diff --git a/codec/src/test/java/io/netty/handler/codec/DatagramPacketEncoderTest.java b/codec/src/test/java/io/netty/handler/codec/DatagramPacketEncoderTest.java index fdf1cac63f..9c04c7156f 100644 --- a/codec/src/test/java/io/netty/handler/codec/DatagramPacketEncoderTest.java +++ b/codec/src/test/java/io/netty/handler/codec/DatagramPacketEncoderTest.java @@ -54,7 +54,7 @@ public class DatagramPacketEncoderTest { InetSocketAddress recipient = SocketUtils.socketAddress("127.0.0.1", 10000); InetSocketAddress sender = SocketUtils.socketAddress("127.0.0.1", 20000); assertTrue(channel.writeOutbound( - new DefaultAddressedEnvelope("netty", recipient, sender))); + new DefaultAddressedEnvelope<>("netty", recipient, sender))); DatagramPacket packet = channel.readOutbound(); try { assertEquals("netty", packet.content().toString(CharsetUtil.UTF_8)); @@ -70,7 +70,7 @@ public class DatagramPacketEncoderTest { InetSocketAddress recipient = SocketUtils.socketAddress("127.0.0.1", 10000); InetSocketAddress sender = SocketUtils.socketAddress("127.0.0.1", 20000); DefaultAddressedEnvelope envelope = - new DefaultAddressedEnvelope(1L, recipient, sender); + new DefaultAddressedEnvelope<>(1L, recipient, sender); assertTrue(channel.writeOutbound(envelope)); DefaultAddressedEnvelope output = channel.readOutbound(); try { @@ -102,7 +102,7 @@ public class DatagramPacketEncoderTest { new TestMessageToMessageEncoder(sharable); DatagramPacketEncoder> encoder = - new DatagramPacketEncoder>(wrapped); + new DatagramPacketEncoder<>(wrapped); assertEquals(wrapped.isSharable(), encoder.isSharable()); } diff --git a/codec/src/test/java/io/netty/handler/codec/DefaultHeadersTest.java b/codec/src/test/java/io/netty/handler/codec/DefaultHeadersTest.java index 073872bf10..8e4dd1700d 100644 --- a/codec/src/test/java/io/netty/handler/codec/DefaultHeadersTest.java +++ b/codec/src/test/java/io/netty/handler/codec/DefaultHeadersTest.java @@ -117,7 +117,7 @@ public class DefaultHeadersTest { headers.add(of("name"), of("value3")); assertEquals(3, headers.size()); - List values = new ArrayList(); + List values = new ArrayList<>(); Iterator itr = headers.valueIterator(of("name")); while (itr.hasNext()) { values.add(itr.next()); @@ -130,7 +130,7 @@ public class DefaultHeadersTest { public void multipleValuesPerNameIteratorEmpty() { TestDefaultHeaders headers = newInstance(); - List values = new ArrayList(); + List values = new ArrayList<>(); Iterator itr = headers.valueIterator(of("name")); while (itr.hasNext()) { values.add(itr.next()); diff --git a/codec/src/test/java/io/netty/handler/codec/ReplayingDecoderTest.java b/codec/src/test/java/io/netty/handler/codec/ReplayingDecoderTest.java index 5a7e878805..b384700dea 100644 --- a/codec/src/test/java/io/netty/handler/codec/ReplayingDecoderTest.java +++ b/codec/src/test/java/io/netty/handler/codec/ReplayingDecoderTest.java @@ -209,7 +209,7 @@ public class ReplayingDecoderTest { @Test public void testFireChannelReadCompleteOnInactive() throws InterruptedException { - final BlockingQueue queue = new LinkedBlockingDeque(); + final BlockingQueue queue = new LinkedBlockingDeque<>(); final ByteBuf buf = Unpooled.buffer().writeBytes(new byte[]{'a', 'b'}); EmbeddedChannel channel = new EmbeddedChannel(new ReplayingDecoder() { @@ -255,7 +255,7 @@ public class ReplayingDecoderTest { @Test public void testChannelInputShutdownEvent() { - final AtomicReference error = new AtomicReference(); + final AtomicReference error = new AtomicReference<>(); EmbeddedChannel channel = new EmbeddedChannel(new ReplayingDecoder(0) { private boolean decoded; diff --git a/codec/src/test/java/io/netty/handler/codec/compression/Lz4FrameEncoderTest.java b/codec/src/test/java/io/netty/handler/codec/compression/Lz4FrameEncoderTest.java index dabe5a6d95..7068644aff 100644 --- a/codec/src/test/java/io/netty/handler/codec/compression/Lz4FrameEncoderTest.java +++ b/codec/src/test/java/io/netty/handler/codec/compression/Lz4FrameEncoderTest.java @@ -244,7 +244,7 @@ public class Lz4FrameEncoderTest extends AbstractEncoderTest { Channel serverChannel = null; Channel clientChannel = null; final CountDownLatch latch = new CountDownLatch(1); - final AtomicReference writeFailCauseRef = new AtomicReference(); + final AtomicReference writeFailCauseRef = new AtomicReference<>(); try { ServerBootstrap sb = new ServerBootstrap(); sb.group(group); diff --git a/codec/src/test/java/io/netty/handler/codec/compression/LzmaFrameEncoderTest.java b/codec/src/test/java/io/netty/handler/codec/compression/LzmaFrameEncoderTest.java index 08c67101e4..294126650e 100644 --- a/codec/src/test/java/io/netty/handler/codec/compression/LzmaFrameEncoderTest.java +++ b/codec/src/test/java/io/netty/handler/codec/compression/LzmaFrameEncoderTest.java @@ -47,7 +47,7 @@ public class LzmaFrameEncoderTest extends AbstractEncoderTest { @Override protected void testCompressionOfBatchedFlow(final ByteBuf data) throws Exception { - List originalLengths = new ArrayList(); + List originalLengths = new ArrayList<>(); final int dataLength = data.readableBytes(); int written = 0, length = rand.nextInt(50); while (written + length < dataLength) { diff --git a/codec/src/test/java/io/netty/handler/codec/xml/XmlFrameDecoderTest.java b/codec/src/test/java/io/netty/handler/codec/xml/XmlFrameDecoderTest.java index 8fca1bba01..00cc2995b0 100644 --- a/codec/src/test/java/io/netty/handler/codec/xml/XmlFrameDecoderTest.java +++ b/codec/src/test/java/io/netty/handler/codec/xml/XmlFrameDecoderTest.java @@ -164,7 +164,7 @@ public class XmlFrameDecoderTest { } catch (Exception e) { cause = e; } - List actual = new ArrayList(); + List actual = new ArrayList<>(); for (;;) { ByteBuf buf = ch.readInbound(); if (buf == null) { @@ -179,7 +179,7 @@ public class XmlFrameDecoderTest { } try { - List expectedList = new ArrayList(); + List expectedList = new ArrayList<>(); Collections.addAll(expectedList, expected); assertThat(actual, is(expectedList)); } finally { diff --git a/common/src/main/java/io/netty/util/AttributeKey.java b/common/src/main/java/io/netty/util/AttributeKey.java index e4dabded93..ebe63ac166 100644 --- a/common/src/main/java/io/netty/util/AttributeKey.java +++ b/common/src/main/java/io/netty/util/AttributeKey.java @@ -27,7 +27,7 @@ public final class AttributeKey extends AbstractConstant> { private static final ConstantPool> pool = new ConstantPool>() { @Override protected AttributeKey newConstant(int id, String name) { - return new AttributeKey(id, name); + return new AttributeKey<>(id, name); } }; diff --git a/common/src/main/java/io/netty/util/DefaultAttributeMap.java b/common/src/main/java/io/netty/util/DefaultAttributeMap.java index c685e4d0b2..df20dfd27f 100644 --- a/common/src/main/java/io/netty/util/DefaultAttributeMap.java +++ b/common/src/main/java/io/netty/util/DefaultAttributeMap.java @@ -45,7 +45,7 @@ public class DefaultAttributeMap implements AttributeMap { AtomicReferenceArray> attributes = this.attributes; if (attributes == null) { // Not using ConcurrentHashMap due to high memory consumption. - attributes = new AtomicReferenceArray>(BUCKET_SIZE); + attributes = new AtomicReferenceArray<>(BUCKET_SIZE); if (!updater.compareAndSet(this, null, attributes)) { attributes = this.attributes; @@ -58,7 +58,7 @@ public class DefaultAttributeMap implements AttributeMap { // No head exists yet which means we may be able to add the attribute without synchronization and just // use compare and set. At worst we need to fallback to synchronization and waste two allocations. head = new DefaultAttribute(); - DefaultAttribute attr = new DefaultAttribute(head, key); + DefaultAttribute attr = new DefaultAttribute<>(head, key); head.next = attr; attr.prev = head; if (attributes.compareAndSet(i, null, head)) { @@ -74,7 +74,7 @@ public class DefaultAttributeMap implements AttributeMap { for (;;) { DefaultAttribute next = curr.next; if (next == null) { - DefaultAttribute attr = new DefaultAttribute(head, key); + DefaultAttribute attr = new DefaultAttribute<>(head, key); curr.next = attr; attr.prev = curr; return attr; diff --git a/common/src/main/java/io/netty/util/DomainMappingBuilder.java b/common/src/main/java/io/netty/util/DomainMappingBuilder.java index e0dcf7dafb..1c1220a033 100644 --- a/common/src/main/java/io/netty/util/DomainMappingBuilder.java +++ b/common/src/main/java/io/netty/util/DomainMappingBuilder.java @@ -34,7 +34,7 @@ public final class DomainMappingBuilder { * when nothing matches the input */ public DomainMappingBuilder(V defaultValue) { - builder = new DomainNameMappingBuilder(defaultValue); + builder = new DomainNameMappingBuilder<>(defaultValue); } /** @@ -45,7 +45,7 @@ public final class DomainMappingBuilder { * when nothing matches the input */ public DomainMappingBuilder(int initialCapacity, V defaultValue) { - builder = new DomainNameMappingBuilder(initialCapacity, defaultValue); + builder = new DomainNameMappingBuilder<>(initialCapacity, defaultValue); } /** diff --git a/common/src/main/java/io/netty/util/DomainNameMapping.java b/common/src/main/java/io/netty/util/DomainNameMapping.java index d1734aa712..562acea602 100644 --- a/common/src/main/java/io/netty/util/DomainNameMapping.java +++ b/common/src/main/java/io/netty/util/DomainNameMapping.java @@ -62,7 +62,7 @@ public class DomainNameMapping implements Mapping { */ @Deprecated public DomainNameMapping(int initialCapacity, V defaultValue) { - this(new LinkedHashMap(initialCapacity), defaultValue); + this(new LinkedHashMap<>(initialCapacity), defaultValue); } DomainNameMapping(Map map, V defaultValue) { diff --git a/common/src/main/java/io/netty/util/DomainNameMappingBuilder.java b/common/src/main/java/io/netty/util/DomainNameMappingBuilder.java index 4bf360c5fa..bcd64b78fd 100644 --- a/common/src/main/java/io/netty/util/DomainNameMappingBuilder.java +++ b/common/src/main/java/io/netty/util/DomainNameMappingBuilder.java @@ -52,7 +52,7 @@ public final class DomainNameMappingBuilder { */ public DomainNameMappingBuilder(int initialCapacity, V defaultValue) { this.defaultValue = checkNotNull(defaultValue, "defaultValue"); - map = new LinkedHashMap(initialCapacity); + map = new LinkedHashMap<>(initialCapacity); } /** @@ -79,7 +79,7 @@ public final class DomainNameMappingBuilder { * @return new {@link DomainNameMapping} instance */ public DomainNameMapping build() { - return new ImmutableDomainNameMapping(defaultValue, map); + return new ImmutableDomainNameMapping<>(defaultValue, map); } /** @@ -108,7 +108,7 @@ public final class DomainNameMappingBuilder { domainNamePatterns = new String[numberOfMappings]; values = (V[]) new Object[numberOfMappings]; - final Map mapCopy = new LinkedHashMap(map.size()); + final Map mapCopy = new LinkedHashMap<>(map.size()); int index = 0; for (Map.Entry mapping : mappings) { final String hostname = normalizeHostname(mapping.getKey()); diff --git a/common/src/main/java/io/netty/util/HashedWheelTimer.java b/common/src/main/java/io/netty/util/HashedWheelTimer.java index e8e72b6387..324c1d1670 100644 --- a/common/src/main/java/io/netty/util/HashedWheelTimer.java +++ b/common/src/main/java/io/netty/util/HashedWheelTimer.java @@ -458,7 +458,7 @@ public class HashedWheelTimer implements Timer { } private final class Worker implements Runnable { - private final Set unprocessedTimeouts = new HashSet(); + private final Set unprocessedTimeouts = new HashSet<>(); private long tick; diff --git a/common/src/main/java/io/netty/util/NetUtil.java b/common/src/main/java/io/netty/util/NetUtil.java index 7da245b48c..35b60fbfac 100644 --- a/common/src/main/java/io/netty/util/NetUtil.java +++ b/common/src/main/java/io/netty/util/NetUtil.java @@ -163,7 +163,7 @@ public final class NetUtil { LOCALHOST6 = localhost6; // Retrieve the list of available network interfaces. - List ifaces = new ArrayList(); + List ifaces = new ArrayList<>(); try { Enumeration interfaces = NetworkInterface.getNetworkInterfaces(); if (interfaces != null) { diff --git a/common/src/main/java/io/netty/util/Recycler.java b/common/src/main/java/io/netty/util/Recycler.java index 87b182e6be..2bf8642502 100644 --- a/common/src/main/java/io/netty/util/Recycler.java +++ b/common/src/main/java/io/netty/util/Recycler.java @@ -111,7 +111,7 @@ public abstract class Recycler { private final FastThreadLocal> threadLocal = new FastThreadLocal>() { @Override protected Stack initialValue() { - return new Stack(Recycler.this, Thread.currentThread(), maxCapacityPerThread, maxSharedCapacityFactor, + return new Stack<>(Recycler.this, Thread.currentThread(), maxCapacityPerThread, maxSharedCapacityFactor, ratioMask, maxDelayedQueuesPerThread); } @@ -230,7 +230,7 @@ public abstract class Recycler { new FastThreadLocal, WeakOrderQueue>>() { @Override protected Map, WeakOrderQueue> initialValue() { - return new WeakHashMap, WeakOrderQueue>(); + return new WeakHashMap<>(); } }; @@ -322,7 +322,7 @@ public abstract class Recycler { // Stack itself GCed. head = new Head(stack.availableSharedCapacity); head.link = tail; - owner = new WeakReference(thread); + owner = new WeakReference<>(thread); } static WeakOrderQueue newQueue(Stack stack, Thread thread) { @@ -473,7 +473,7 @@ public abstract class Recycler { Stack(Recycler parent, Thread thread, int maxCapacity, int maxSharedCapacityFactor, int ratioMask, int maxDelayedQueues) { this.parent = parent; - threadRef = new WeakReference(thread); + threadRef = new WeakReference<>(thread); this.maxCapacity = maxCapacity; availableSharedCapacity = new AtomicInteger(max(maxCapacity / maxSharedCapacityFactor, LINK_CAPACITY)); elements = new DefaultHandle[min(INITIAL_CAPACITY, maxCapacity)]; @@ -655,7 +655,7 @@ public abstract class Recycler { } DefaultHandle newHandle() { - return new DefaultHandle(this); + return new DefaultHandle<>(this); } } } diff --git a/common/src/main/java/io/netty/util/ResourceLeakDetector.java b/common/src/main/java/io/netty/util/ResourceLeakDetector.java index 436d793669..5dfc799d32 100644 --- a/common/src/main/java/io/netty/util/ResourceLeakDetector.java +++ b/common/src/main/java/io/netty/util/ResourceLeakDetector.java @@ -165,9 +165,9 @@ public class ResourceLeakDetector { /** the collection of active resources */ private final Set> allLeaks = - Collections.newSetFromMap(new ConcurrentHashMap, Boolean>()); + Collections.newSetFromMap(new ConcurrentHashMap<>()); - private final ReferenceQueue refQueue = new ReferenceQueue(); + private final ReferenceQueue refQueue = new ReferenceQueue<>(); private final ConcurrentMap reportedLeaks = PlatformDependent.newConcurrentHashMap(); private final String resourceType; @@ -520,7 +520,7 @@ public class ResourceLeakDetector { buf.append("Recent access records: ").append(NEWLINE); int i = 1; - Set seen = new HashSet(present); + Set seen = new HashSet<>(present); for (; oldHead != Record.BOTTOM; oldHead = oldHead.next) { String s = oldHead.toString(); if (seen.add(s)) { @@ -558,10 +558,10 @@ public class ResourceLeakDetector { } private static final AtomicReference excludedMethods = - new AtomicReference(EmptyArrays.EMPTY_STRINGS); + new AtomicReference<>(EmptyArrays.EMPTY_STRINGS); public static void addExclusions(Class clz, String ... methodNames) { - Set nameSet = new HashSet(Arrays.asList(methodNames)); + Set nameSet = new HashSet<>(Arrays.asList(methodNames)); // Use loop rather than lookup. This avoids knowing the parameters, and doesn't have to handle // NoSuchMethodException. for (Method method : clz.getDeclaredMethods()) { diff --git a/common/src/main/java/io/netty/util/ResourceLeakDetectorFactory.java b/common/src/main/java/io/netty/util/ResourceLeakDetectorFactory.java index 65f1fc8c65..2290477bdb 100644 --- a/common/src/main/java/io/netty/util/ResourceLeakDetectorFactory.java +++ b/common/src/main/java/io/netty/util/ResourceLeakDetectorFactory.java @@ -175,8 +175,8 @@ public abstract class ResourceLeakDetectorFactory { } } - ResourceLeakDetector resourceLeakDetector = new ResourceLeakDetector(resource, samplingInterval, - maxActive); + ResourceLeakDetector resourceLeakDetector = new ResourceLeakDetector<>(resource, samplingInterval, + maxActive); logger.debug("Loaded default ResourceLeakDetector: {}", resourceLeakDetector); return resourceLeakDetector; } @@ -198,7 +198,7 @@ public abstract class ResourceLeakDetectorFactory { } } - ResourceLeakDetector resourceLeakDetector = new ResourceLeakDetector(resource, samplingInterval); + ResourceLeakDetector resourceLeakDetector = new ResourceLeakDetector<>(resource, samplingInterval); logger.debug("Loaded default ResourceLeakDetector: {}", resourceLeakDetector); return resourceLeakDetector; } diff --git a/common/src/main/java/io/netty/util/ThreadDeathWatcher.java b/common/src/main/java/io/netty/util/ThreadDeathWatcher.java index 8e755edae6..d0579715c0 100644 --- a/common/src/main/java/io/netty/util/ThreadDeathWatcher.java +++ b/common/src/main/java/io/netty/util/ThreadDeathWatcher.java @@ -51,7 +51,7 @@ public final class ThreadDeathWatcher { // Use a MPMC queue as we may end up checking isEmpty() from multiple threads which may not be allowed to do // concurrently depending on the implementation of it in a MPSC queue. - private static final Queue pendingEntries = new ConcurrentLinkedQueue(); + private static final Queue pendingEntries = new ConcurrentLinkedQueue<>(); private static final Watcher watcher = new Watcher(); private static final AtomicBoolean started = new AtomicBoolean(); private static volatile Thread watcherThread; @@ -154,7 +154,7 @@ public final class ThreadDeathWatcher { private static final class Watcher implements Runnable { - private final List watchees = new ArrayList(); + private final List watchees = new ArrayList<>(); @Override public void run() { diff --git a/common/src/main/java/io/netty/util/Version.java b/common/src/main/java/io/netty/util/Version.java index a0a07545ed..c722b5962d 100644 --- a/common/src/main/java/io/netty/util/Version.java +++ b/common/src/main/java/io/netty/util/Version.java @@ -82,7 +82,7 @@ public final class Version { } // Collect all artifactIds. - Set artifactIds = new HashSet(); + Set artifactIds = new HashSet<>(); for (Object o: props.keySet()) { String k = (String) o; @@ -106,7 +106,7 @@ public final class Version { artifactIds.add(artifactId); } - Map versions = new TreeMap(); + Map versions = new TreeMap<>(); for (String artifactId: artifactIds) { versions.put( artifactId, diff --git a/common/src/main/java/io/netty/util/concurrent/AbstractEventExecutor.java b/common/src/main/java/io/netty/util/concurrent/AbstractEventExecutor.java index 6cfccbd3ae..a4f8247afd 100644 --- a/common/src/main/java/io/netty/util/concurrent/AbstractEventExecutor.java +++ b/common/src/main/java/io/netty/util/concurrent/AbstractEventExecutor.java @@ -91,22 +91,22 @@ public abstract class AbstractEventExecutor extends AbstractExecutorService impl @Override public Promise newPromise() { - return new DefaultPromise(this); + return new DefaultPromise<>(this); } @Override public ProgressivePromise newProgressivePromise() { - return new DefaultProgressivePromise(this); + return new DefaultProgressivePromise<>(this); } @Override public Future newSucceededFuture(V result) { - return new SucceededFuture(this, result); + return new SucceededFuture<>(this, result); } @Override public Future newFailedFuture(Throwable cause) { - return new FailedFuture(this, cause); + return new FailedFuture<>(this, cause); } @Override @@ -126,12 +126,12 @@ public abstract class AbstractEventExecutor extends AbstractExecutorService impl @Override protected final RunnableFuture newTaskFor(Runnable runnable, T value) { - return new PromiseTask(this, runnable, value); + return new PromiseTask<>(this, runnable, value); } @Override protected final RunnableFuture newTaskFor(Callable callable) { - return new PromiseTask(this, callable); + return new PromiseTask<>(this, callable); } @Override diff --git a/common/src/main/java/io/netty/util/concurrent/AbstractScheduledEventExecutor.java b/common/src/main/java/io/netty/util/concurrent/AbstractScheduledEventExecutor.java index 41430c708c..252f885174 100644 --- a/common/src/main/java/io/netty/util/concurrent/AbstractScheduledEventExecutor.java +++ b/common/src/main/java/io/netty/util/concurrent/AbstractScheduledEventExecutor.java @@ -53,7 +53,7 @@ public abstract class AbstractScheduledEventExecutor extends AbstractEventExecut PriorityQueue> scheduledTaskQueue() { if (scheduledTaskQueue == null) { - scheduledTaskQueue = new DefaultPriorityQueue>( + scheduledTaskQueue = new DefaultPriorityQueue<>( SCHEDULED_FUTURE_TASK_COMPARATOR, // Use same initial capacity as java.util.PriorityQueue 11); @@ -165,7 +165,7 @@ public abstract class AbstractScheduledEventExecutor extends AbstractEventExecut } validateScheduled0(delay, unit); - return schedule(new ScheduledFutureTask( + return schedule(new ScheduledFutureTask<>( this, callable, ScheduledFutureTask.deadlineNanos(unit.toNanos(delay)))); } @@ -184,7 +184,7 @@ public abstract class AbstractScheduledEventExecutor extends AbstractEventExecut validateScheduled0(initialDelay, unit); validateScheduled0(period, unit); - return schedule(new ScheduledFutureTask( + return schedule(new ScheduledFutureTask<>( this, Executors.callable(command, null), ScheduledFutureTask.deadlineNanos(unit.toNanos(initialDelay)), unit.toNanos(period))); } @@ -205,7 +205,7 @@ public abstract class AbstractScheduledEventExecutor extends AbstractEventExecut validateScheduled0(initialDelay, unit); validateScheduled0(delay, unit); - return schedule(new ScheduledFutureTask( + return schedule(new ScheduledFutureTask<>( this, Executors.callable(command, null), ScheduledFutureTask.deadlineNanos(unit.toNanos(initialDelay)), -unit.toNanos(delay))); } diff --git a/common/src/main/java/io/netty/util/concurrent/FastThreadLocal.java b/common/src/main/java/io/netty/util/concurrent/FastThreadLocal.java index 9d808c7f45..16205f7d68 100644 --- a/common/src/main/java/io/netty/util/concurrent/FastThreadLocal.java +++ b/common/src/main/java/io/netty/util/concurrent/FastThreadLocal.java @@ -99,7 +99,7 @@ public class FastThreadLocal { Object v = threadLocalMap.indexedVariable(variablesToRemoveIndex); Set> variablesToRemove; if (v == InternalThreadLocalMap.UNSET || v == null) { - variablesToRemove = Collections.newSetFromMap(new IdentityHashMap, Boolean>()); + variablesToRemove = Collections.newSetFromMap(new IdentityHashMap<>()); threadLocalMap.setIndexedVariable(variablesToRemoveIndex, variablesToRemove); } else { variablesToRemove = (Set>) v; diff --git a/common/src/main/java/io/netty/util/concurrent/GlobalEventExecutor.java b/common/src/main/java/io/netty/util/concurrent/GlobalEventExecutor.java index 7e2527d981..f049bd7d10 100644 --- a/common/src/main/java/io/netty/util/concurrent/GlobalEventExecutor.java +++ b/common/src/main/java/io/netty/util/concurrent/GlobalEventExecutor.java @@ -42,8 +42,8 @@ public final class GlobalEventExecutor extends AbstractScheduledEventExecutor { public static final GlobalEventExecutor INSTANCE = new GlobalEventExecutor(); - final BlockingQueue taskQueue = new LinkedBlockingQueue(); - final ScheduledFutureTask quietPeriodTask = new ScheduledFutureTask( + final BlockingQueue taskQueue = new LinkedBlockingQueue<>(); + final ScheduledFutureTask quietPeriodTask = new ScheduledFutureTask<>( this, Executors.callable(new Runnable() { @Override public void run() { @@ -61,7 +61,7 @@ public final class GlobalEventExecutor extends AbstractScheduledEventExecutor { private final AtomicBoolean started = new AtomicBoolean(); volatile Thread thread; - private final Future terminationFuture = new FailedFuture(this, new UnsupportedOperationException()); + private final Future terminationFuture = new FailedFuture<>(this, new UnsupportedOperationException()); private GlobalEventExecutor() { scheduledTaskQueue().add(quietPeriodTask); diff --git a/common/src/main/java/io/netty/util/concurrent/ImmediateEventExecutor.java b/common/src/main/java/io/netty/util/concurrent/ImmediateEventExecutor.java index f952cf21c8..8f81e29865 100644 --- a/common/src/main/java/io/netty/util/concurrent/ImmediateEventExecutor.java +++ b/common/src/main/java/io/netty/util/concurrent/ImmediateEventExecutor.java @@ -38,7 +38,7 @@ public final class ImmediateEventExecutor extends AbstractEventExecutor { private static final FastThreadLocal> DELAYED_RUNNABLES = new FastThreadLocal>() { @Override protected Queue initialValue() throws Exception { - return new ArrayDeque(); + return new ArrayDeque<>(); } }; /** @@ -51,7 +51,7 @@ public final class ImmediateEventExecutor extends AbstractEventExecutor { } }; - private final Future terminationFuture = new FailedFuture( + private final Future terminationFuture = new FailedFuture<>( GlobalEventExecutor.INSTANCE, new UnsupportedOperationException()); private ImmediateEventExecutor() { } @@ -130,12 +130,12 @@ public final class ImmediateEventExecutor extends AbstractEventExecutor { @Override public Promise newPromise() { - return new ImmediatePromise(this); + return new ImmediatePromise<>(this); } @Override public ProgressivePromise newProgressivePromise() { - return new ImmediateProgressivePromise(this); + return new ImmediateProgressivePromise<>(this); } static class ImmediatePromise extends DefaultPromise { diff --git a/common/src/main/java/io/netty/util/concurrent/MultithreadEventExecutorGroup.java b/common/src/main/java/io/netty/util/concurrent/MultithreadEventExecutorGroup.java index 1665638cc0..d300108eba 100644 --- a/common/src/main/java/io/netty/util/concurrent/MultithreadEventExecutorGroup.java +++ b/common/src/main/java/io/netty/util/concurrent/MultithreadEventExecutorGroup.java @@ -123,7 +123,7 @@ public abstract class MultithreadEventExecutorGroup extends AbstractEventExecuto e.terminationFuture().addListener(terminationListener); } - Set childrenSet = new LinkedHashSet(children.length); + Set childrenSet = new LinkedHashSet<>(children.length); Collections.addAll(childrenSet, children); readonlyChildren = Collections.unmodifiableSet(childrenSet); } diff --git a/common/src/main/java/io/netty/util/concurrent/PromiseAggregator.java b/common/src/main/java/io/netty/util/concurrent/PromiseAggregator.java index 7d908c0379..0788b73532 100644 --- a/common/src/main/java/io/netty/util/concurrent/PromiseAggregator.java +++ b/common/src/main/java/io/netty/util/concurrent/PromiseAggregator.java @@ -77,7 +77,7 @@ public class PromiseAggregator> implements GenericFutureL } else { size = 2; } - pendingPromises = new LinkedHashSet>(size); + pendingPromises = new LinkedHashSet<>(size); } for (Promise p : promises) { if (p == null) { diff --git a/common/src/main/java/io/netty/util/concurrent/PromiseTask.java b/common/src/main/java/io/netty/util/concurrent/PromiseTask.java index 8cb23c7861..c9c054125f 100644 --- a/common/src/main/java/io/netty/util/concurrent/PromiseTask.java +++ b/common/src/main/java/io/netty/util/concurrent/PromiseTask.java @@ -21,7 +21,7 @@ import java.util.concurrent.RunnableFuture; class PromiseTask extends DefaultPromise implements RunnableFuture { static Callable toCallable(Runnable runnable, T result) { - return new RunnableAdapter(runnable, result); + return new RunnableAdapter<>(runnable, result); } private static final class RunnableAdapter implements Callable { diff --git a/common/src/main/java/io/netty/util/concurrent/SingleThreadEventExecutor.java b/common/src/main/java/io/netty/util/concurrent/SingleThreadEventExecutor.java index 24e8f17c95..5896576ce5 100644 --- a/common/src/main/java/io/netty/util/concurrent/SingleThreadEventExecutor.java +++ b/common/src/main/java/io/netty/util/concurrent/SingleThreadEventExecutor.java @@ -88,7 +88,7 @@ public abstract class SingleThreadEventExecutor extends AbstractScheduledEventEx private volatile boolean interrupted; private final Semaphore threadLock = new Semaphore(0); - private final Set shutdownHooks = new LinkedHashSet(); + private final Set shutdownHooks = new LinkedHashSet<>(); private final boolean addTaskWakesUp; private final int maxPendingTasks; private final RejectedExecutionHandler rejectedExecutionHandler; @@ -181,7 +181,7 @@ public abstract class SingleThreadEventExecutor extends AbstractScheduledEventEx * implementation that does not support blocking operations at all. */ protected Queue newTaskQueue(int maxPendingTasks) { - return new LinkedBlockingQueue(maxPendingTasks); + return new LinkedBlockingQueue<>(maxPendingTasks); } /** @@ -509,7 +509,7 @@ public abstract class SingleThreadEventExecutor extends AbstractScheduledEventEx boolean ran = false; // Note shutdown hooks can add / remove shutdown hooks. while (!shutdownHooks.isEmpty()) { - List copy = new ArrayList(shutdownHooks); + List copy = new ArrayList<>(shutdownHooks); shutdownHooks.clear(); for (Runnable task: copy) { try { diff --git a/common/src/main/java/io/netty/util/concurrent/UnorderedThreadPoolEventExecutor.java b/common/src/main/java/io/netty/util/concurrent/UnorderedThreadPoolEventExecutor.java index 4ed94da537..463bc657c5 100644 --- a/common/src/main/java/io/netty/util/concurrent/UnorderedThreadPoolEventExecutor.java +++ b/common/src/main/java/io/netty/util/concurrent/UnorderedThreadPoolEventExecutor.java @@ -99,22 +99,22 @@ public final class UnorderedThreadPoolEventExecutor extends ScheduledThreadPoolE @Override public Promise newPromise() { - return new DefaultPromise(this); + return new DefaultPromise<>(this); } @Override public ProgressivePromise newProgressivePromise() { - return new DefaultProgressivePromise(this); + return new DefaultProgressivePromise<>(this); } @Override public Future newSucceededFuture(V result) { - return new SucceededFuture(this, result); + return new SucceededFuture<>(this, result); } @Override public Future newFailedFuture(Throwable cause) { - return new FailedFuture(this, cause); + return new FailedFuture<>(this, cause); } @Override @@ -161,12 +161,12 @@ public final class UnorderedThreadPoolEventExecutor extends ScheduledThreadPoolE @Override protected RunnableScheduledFuture decorateTask(Runnable runnable, RunnableScheduledFuture task) { return runnable instanceof NonNotifyRunnable ? - task : new RunnableScheduledFutureTask(this, runnable, task); + task : new RunnableScheduledFutureTask<>(this, runnable, task); } @Override protected RunnableScheduledFuture decorateTask(Callable callable, RunnableScheduledFuture task) { - return new RunnableScheduledFutureTask(this, callable, task); + return new RunnableScheduledFutureTask<>(this, callable, task); } @Override diff --git a/common/src/main/java/io/netty/util/internal/EmptyPriorityQueue.java b/common/src/main/java/io/netty/util/internal/EmptyPriorityQueue.java index 983cb1fcda..6ae9955ea0 100644 --- a/common/src/main/java/io/netty/util/internal/EmptyPriorityQueue.java +++ b/common/src/main/java/io/netty/util/internal/EmptyPriorityQueue.java @@ -21,7 +21,7 @@ import java.util.Iterator; import java.util.NoSuchElementException; public final class EmptyPriorityQueue implements PriorityQueue { - private static final PriorityQueue INSTANCE = new EmptyPriorityQueue(); + private static final PriorityQueue INSTANCE = new EmptyPriorityQueue<>(); private EmptyPriorityQueue() { } diff --git a/common/src/main/java/io/netty/util/internal/MacAddressUtil.java b/common/src/main/java/io/netty/util/internal/MacAddressUtil.java index fbb8dfbda8..363c55f010 100644 --- a/common/src/main/java/io/netty/util/internal/MacAddressUtil.java +++ b/common/src/main/java/io/netty/util/internal/MacAddressUtil.java @@ -50,7 +50,7 @@ public final class MacAddressUtil { InetAddress bestInetAddr = NetUtil.LOCALHOST4; // Retrieve the list of available network interfaces. - Map ifaces = new LinkedHashMap(); + Map ifaces = new LinkedHashMap<>(); try { Enumeration interfaces = NetworkInterface.getNetworkInterfaces(); if (interfaces != null) { diff --git a/common/src/main/java/io/netty/util/internal/NativeLibraryLoader.java b/common/src/main/java/io/netty/util/internal/NativeLibraryLoader.java index 31b4a465fa..71c2438930 100644 --- a/common/src/main/java/io/netty/util/internal/NativeLibraryLoader.java +++ b/common/src/main/java/io/netty/util/internal/NativeLibraryLoader.java @@ -90,7 +90,7 @@ public final class NativeLibraryLoader { * if none of the given libraries load successfully. */ public static void loadFirstAvailable(ClassLoader loader, String... names) { - List suppressed = new ArrayList(); + List suppressed = new ArrayList<>(); for (String name : names) { try { load(name, loader); @@ -130,7 +130,7 @@ public final class NativeLibraryLoader { // Adjust expected name to support shading of native libraries. String packagePrefix = calculatePackagePrefix().replace('.', '_'); String name = packagePrefix + originalName; - List suppressed = new ArrayList(); + List suppressed = new ArrayList<>(); try { // first try to load from java.library.path loadLibrary(loader, name, false); diff --git a/common/src/main/java/io/netty/util/internal/StringUtil.java b/common/src/main/java/io/netty/util/internal/StringUtil.java index e81a024ddc..e033137b1b 100644 --- a/common/src/main/java/io/netty/util/internal/StringUtil.java +++ b/common/src/main/java/io/netty/util/internal/StringUtil.java @@ -435,7 +435,7 @@ public final class StringUtil { * @return {@link List} the list of unescaped fields */ public static List unescapeCsvFields(CharSequence value) { - List unescaped = new ArrayList(2); + List unescaped = new ArrayList<>(2); StringBuilder current = InternalThreadLocalMap.get().stringBuilder(); boolean quoted = false; int last = value.length() - 1; diff --git a/common/src/main/java/io/netty/util/internal/TypeParameterMatcher.java b/common/src/main/java/io/netty/util/internal/TypeParameterMatcher.java index 87481586a6..93af19f4a6 100644 --- a/common/src/main/java/io/netty/util/internal/TypeParameterMatcher.java +++ b/common/src/main/java/io/netty/util/internal/TypeParameterMatcher.java @@ -59,7 +59,7 @@ public abstract class TypeParameterMatcher { Map map = findCache.get(thisClass); if (map == null) { - map = new HashMap(); + map = new HashMap<>(); findCache.put(thisClass, map); } diff --git a/common/src/main/java/io/netty/util/internal/logging/MessageFormatter.java b/common/src/main/java/io/netty/util/internal/logging/MessageFormatter.java index fed8cd0106..b6bfea4ba9 100644 --- a/common/src/main/java/io/netty/util/internal/logging/MessageFormatter.java +++ b/common/src/main/java/io/netty/util/internal/logging/MessageFormatter.java @@ -289,7 +289,7 @@ final class MessageFormatter { return; } if (seenSet == null) { - seenSet = new HashSet(a.length); + seenSet = new HashSet<>(a.length); } if (seenSet.add(a)) { deeplyAppendParameter(sbuf, a[0], seenSet); diff --git a/common/src/test/java/io/netty/util/AbstractReferenceCountedTest.java b/common/src/test/java/io/netty/util/AbstractReferenceCountedTest.java index 26762355fe..7eb5f1bc40 100644 --- a/common/src/test/java/io/netty/util/AbstractReferenceCountedTest.java +++ b/common/src/test/java/io/netty/util/AbstractReferenceCountedTest.java @@ -86,7 +86,7 @@ public class AbstractReferenceCountedTest { @Test(timeout = 30000) public void testRetainFromMultipleThreadsThrowsReferenceCountException() throws Exception { int threads = 4; - Queue> futures = new ArrayDeque>(threads); + Queue> futures = new ArrayDeque<>(threads); ExecutorService service = Executors.newFixedThreadPool(threads); final AtomicInteger refCountExceptions = new AtomicInteger(); @@ -134,7 +134,7 @@ public class AbstractReferenceCountedTest { @Test(timeout = 30000) public void testReleaseFromMultipleThreadsThrowsReferenceCountException() throws Exception { int threads = 4; - Queue> futures = new ArrayDeque>(threads); + Queue> futures = new ArrayDeque<>(threads); ExecutorService service = Executors.newFixedThreadPool(threads); final AtomicInteger refCountExceptions = new AtomicInteger(); diff --git a/common/src/test/java/io/netty/util/AsciiStringMemoryTest.java b/common/src/test/java/io/netty/util/AsciiStringMemoryTest.java index 0f2468aed6..be1bea8d62 100644 --- a/common/src/test/java/io/netty/util/AsciiStringMemoryTest.java +++ b/common/src/test/java/io/netty/util/AsciiStringMemoryTest.java @@ -79,8 +79,8 @@ public class AsciiStringMemoryTest { @Test public void forEachTest() throws Exception { - final AtomicReference aCount = new AtomicReference(0); - final AtomicReference bCount = new AtomicReference(0); + final AtomicReference aCount = new AtomicReference<>(0); + final AtomicReference bCount = new AtomicReference<>(0); aAsciiString.forEachByte(new ByteProcessor() { int i; @Override @@ -117,8 +117,8 @@ public class AsciiStringMemoryTest { @Test public void forEachDescTest() throws Exception { - final AtomicReference aCount = new AtomicReference(0); - final AtomicReference bCount = new AtomicReference(0); + final AtomicReference aCount = new AtomicReference<>(0); + final AtomicReference bCount = new AtomicReference<>(0); aAsciiString.forEachByteDesc(new ByteProcessor() { int i = 1; @Override diff --git a/common/src/test/java/io/netty/util/ConstantPoolTest.java b/common/src/test/java/io/netty/util/ConstantPoolTest.java index a3fc4e7c1f..41c9cb8f0e 100644 --- a/common/src/test/java/io/netty/util/ConstantPoolTest.java +++ b/common/src/test/java/io/netty/util/ConstantPoolTest.java @@ -68,7 +68,7 @@ public class ConstantPoolTest { TestConstant d = pool.valueOf("d_delta"); TestConstant e = pool.valueOf("e_epsilon"); - Set set = new TreeSet(); + Set set = new TreeSet<>(); set.add(b); set.add(c); set.add(e); diff --git a/common/src/test/java/io/netty/util/DomainNameMappingTest.java b/common/src/test/java/io/netty/util/DomainNameMappingTest.java index b8447964cd..a2b7023c67 100644 --- a/common/src/test/java/io/netty/util/DomainNameMappingTest.java +++ b/common/src/test/java/io/netty/util/DomainNameMappingTest.java @@ -34,17 +34,17 @@ public class DomainNameMappingTest { @Test(expected = NullPointerException.class) public void testNullDomainNamePatternsAreForbiddenInDeprecatedApi() { - new DomainNameMapping("NotFound").add(null, "Some value"); + new DomainNameMapping<>("NotFound").add(null, "Some value"); } @Test(expected = NullPointerException.class) public void testNullValuesAreForbiddenInDeprecatedApi() { - new DomainNameMapping("NotFound").add("Some key", null); + new DomainNameMapping<>("NotFound").add("Some key", null); } @Test public void testDefaultValueInDeprecatedApi() { - DomainNameMapping mapping = new DomainNameMapping("NotFound"); + DomainNameMapping mapping = new DomainNameMapping<>("NotFound"); assertEquals("NotFound", mapping.map("not-existing")); @@ -55,7 +55,7 @@ public class DomainNameMappingTest { @Test public void testStrictEqualityInDeprecatedApi() { - DomainNameMapping mapping = new DomainNameMapping("NotFound") + DomainNameMapping mapping = new DomainNameMapping<>("NotFound") .add("netty.io", "Netty") .add("downloads.netty.io", "Netty-Downloads"); @@ -67,7 +67,7 @@ public class DomainNameMappingTest { @Test public void testWildcardMatchesAnyPrefixInDeprecatedApi() { - DomainNameMapping mapping = new DomainNameMapping("NotFound") + DomainNameMapping mapping = new DomainNameMapping<>("NotFound") .add("*.netty.io", "Netty"); assertEquals("Netty", mapping.map("netty.io")); @@ -80,13 +80,13 @@ public class DomainNameMappingTest { @Test public void testFirstMatchWinsInDeprecatedApi() { assertEquals("Netty", - new DomainNameMapping("NotFound") + new DomainNameMapping<>("NotFound") .add("*.netty.io", "Netty") .add("downloads.netty.io", "Netty-Downloads") .map("downloads.netty.io")); assertEquals("Netty-Downloads", - new DomainNameMapping("NotFound") + new DomainNameMapping<>("NotFound") .add("downloads.netty.io", "Netty-Downloads") .add("*.netty.io", "Netty") .map("downloads.netty.io")); @@ -94,7 +94,7 @@ public class DomainNameMappingTest { @Test public void testToStringInDeprecatedApi() { - DomainNameMapping mapping = new DomainNameMapping("NotFound") + DomainNameMapping mapping = new DomainNameMapping<>("NotFound") .add("*.netty.io", "Netty") .add("downloads.netty.io", "Netty-Downloads"); @@ -112,17 +112,17 @@ public class DomainNameMappingTest { @Test(expected = NullPointerException.class) public void testNullDomainNamePatternsAreForbidden() { - new DomainNameMappingBuilder("NotFound").add(null, "Some value"); + new DomainNameMappingBuilder<>("NotFound").add(null, "Some value"); } @Test(expected = NullPointerException.class) public void testNullValuesAreForbidden() { - new DomainNameMappingBuilder("NotFound").add("Some key", null); + new DomainNameMappingBuilder<>("NotFound").add("Some key", null); } @Test public void testDefaultValue() { - DomainNameMapping mapping = new DomainNameMappingBuilder("NotFound") + DomainNameMapping mapping = new DomainNameMappingBuilder<>("NotFound") .add("*.netty.io", "Netty") .build(); @@ -131,7 +131,7 @@ public class DomainNameMappingTest { @Test public void testStrictEquality() { - DomainNameMapping mapping = new DomainNameMappingBuilder("NotFound") + DomainNameMapping mapping = new DomainNameMappingBuilder<>("NotFound") .add("netty.io", "Netty") .add("downloads.netty.io", "Netty-Downloads") .build(); @@ -144,7 +144,7 @@ public class DomainNameMappingTest { @Test public void testWildcardMatchesAnyPrefix() { - DomainNameMapping mapping = new DomainNameMappingBuilder("NotFound") + DomainNameMapping mapping = new DomainNameMappingBuilder<>("NotFound") .add("*.netty.io", "Netty") .build(); @@ -158,14 +158,14 @@ public class DomainNameMappingTest { @Test public void testFirstMatchWins() { assertEquals("Netty", - new DomainNameMappingBuilder("NotFound") + new DomainNameMappingBuilder<>("NotFound") .add("*.netty.io", "Netty") .add("downloads.netty.io", "Netty-Downloads") .build() .map("downloads.netty.io")); assertEquals("Netty-Downloads", - new DomainNameMappingBuilder("NotFound") + new DomainNameMappingBuilder<>("NotFound") .add("downloads.netty.io", "Netty-Downloads") .add("*.netty.io", "Netty") .build() @@ -174,7 +174,7 @@ public class DomainNameMappingTest { @Test public void testToString() { - DomainNameMapping mapping = new DomainNameMappingBuilder("NotFound") + DomainNameMapping mapping = new DomainNameMappingBuilder<>("NotFound") .add("*.netty.io", "Netty") .add("downloads.netty.io", "Netty-Download") .build(); @@ -186,7 +186,7 @@ public class DomainNameMappingTest { @Test public void testAsMap() { - DomainNameMapping mapping = new DomainNameMapping("NotFound") + DomainNameMapping mapping = new DomainNameMapping<>("NotFound") .add("netty.io", "Netty") .add("downloads.netty.io", "Netty-Downloads"); @@ -199,7 +199,7 @@ public class DomainNameMappingTest { @Test public void testAsMapWithImmutableDomainNameMapping() { - DomainNameMapping mapping = new DomainNameMappingBuilder("NotFound") + DomainNameMapping mapping = new DomainNameMappingBuilder<>("NotFound") .add("netty.io", "Netty") .add("downloads.netty.io", "Netty-Downloads") .build(); diff --git a/common/src/test/java/io/netty/util/HashedWheelTimerTest.java b/common/src/test/java/io/netty/util/HashedWheelTimerTest.java index 2bf1c34819..76340a277f 100644 --- a/common/src/test/java/io/netty/util/HashedWheelTimerTest.java +++ b/common/src/test/java/io/netty/util/HashedWheelTimerTest.java @@ -138,7 +138,7 @@ public class HashedWheelTimerTest { int timeout = 125; int maxTimeout = 2 * (tickDuration + timeout); final HashedWheelTimer timer = new HashedWheelTimer(tickDuration, TimeUnit.MILLISECONDS); - final BlockingQueue queue = new LinkedBlockingQueue(); + final BlockingQueue queue = new LinkedBlockingQueue<>(); int scheduledTasks = 100000; for (int i = 0; i < scheduledTasks; i++) { diff --git a/common/src/test/java/io/netty/util/NettyRuntimeTests.java b/common/src/test/java/io/netty/util/NettyRuntimeTests.java index e66c6cc6ee..b69c85bff7 100644 --- a/common/src/test/java/io/netty/util/NettyRuntimeTests.java +++ b/common/src/test/java/io/netty/util/NettyRuntimeTests.java @@ -75,12 +75,12 @@ public class NettyRuntimeTests { final NettyRuntime.AvailableProcessorsHolder holder = new NettyRuntime.AvailableProcessorsHolder(); final CyclicBarrier barrier = new CyclicBarrier(3); - final AtomicReference firstReference = new AtomicReference(); + final AtomicReference firstReference = new AtomicReference<>(); final Runnable firstTarget = getRunnable(holder, barrier, firstReference); final Thread firstGet = new Thread(firstTarget); firstGet.start(); - final AtomicReference secondRefernce = new AtomicReference(); + final AtomicReference secondRefernce = new AtomicReference<>(); final Runnable secondTarget = getRunnable(holder, barrier, secondRefernce); final Thread secondGet = new Thread(secondTarget); secondGet.start(); @@ -130,7 +130,7 @@ public class NettyRuntimeTests { }); get.start(); - final AtomicReference setException = new AtomicReference(); + final AtomicReference setException = new AtomicReference<>(); final Thread set = new Thread(new Runnable() { @Override public void run() { diff --git a/common/src/test/java/io/netty/util/RecyclerTest.java b/common/src/test/java/io/netty/util/RecyclerTest.java index e4bcbf1da4..c54c8a7b76 100644 --- a/common/src/test/java/io/netty/util/RecyclerTest.java +++ b/common/src/test/java/io/netty/util/RecyclerTest.java @@ -40,7 +40,7 @@ public class RecyclerTest { public void testThreadCanBeCollectedEvenIfHandledObjectIsReferenced() throws Exception { final Recycler recycler = newRecycler(1024); final AtomicBoolean collected = new AtomicBoolean(); - final AtomicReference reference = new AtomicReference(); + final AtomicReference reference = new AtomicReference<>(); Thread thread = new Thread(new Runnable() { @Override public void run() { @@ -85,7 +85,7 @@ public class RecyclerTest { public void testMultipleRecycleAtDifferentThread() throws InterruptedException { Recycler recycler = newRecycler(1024); final HandledObject object = recycler.get(); - final AtomicReference exceptionStore = new AtomicReference(); + final AtomicReference exceptionStore = new AtomicReference<>(); final Thread thread1 = new Thread(new Runnable() { @Override public void run() { diff --git a/common/src/test/java/io/netty/util/ResourceLeakDetectorTest.java b/common/src/test/java/io/netty/util/ResourceLeakDetectorTest.java index 9f947a6680..301d2ee39c 100644 --- a/common/src/test/java/io/netty/util/ResourceLeakDetectorTest.java +++ b/common/src/test/java/io/netty/util/ResourceLeakDetectorTest.java @@ -28,13 +28,13 @@ public class ResourceLeakDetectorTest { @Test(timeout = 60000) public void testConcurrentUsage() throws Throwable { final AtomicBoolean finished = new AtomicBoolean(); - final AtomicReference error = new AtomicReference(); + final AtomicReference error = new AtomicReference<>(); // With 50 threads issue #6087 is reproducible on every run. Thread[] threads = new Thread[50]; final CyclicBarrier barrier = new CyclicBarrier(threads.length); for (int i = 0; i < threads.length; i++) { Thread t = new Thread(new Runnable() { - Queue resources = new ArrayDeque(100); + Queue resources = new ArrayDeque<>(100); @Override public void run() { @@ -118,7 +118,7 @@ public class ResourceLeakDetectorTest { private static final class DefaultResource implements Resource { // Sample every allocation - static final TestResourceLeakDetector detector = new TestResourceLeakDetector( + static final TestResourceLeakDetector detector = new TestResourceLeakDetector<>( Resource.class, 1, Integer.MAX_VALUE); @Override @@ -140,7 +140,7 @@ public class ResourceLeakDetectorTest { private static final class TestResourceLeakDetector extends ResourceLeakDetector { - private final AtomicReference error = new AtomicReference(); + private final AtomicReference error = new AtomicReference<>(); TestResourceLeakDetector(Class resourceType, int samplingInterval, long maxActive) { super(resourceType, samplingInterval, maxActive); diff --git a/common/src/test/java/io/netty/util/ThreadDeathWatcherTest.java b/common/src/test/java/io/netty/util/ThreadDeathWatcherTest.java index 7574274f64..ba9c218eb4 100644 --- a/common/src/test/java/io/netty/util/ThreadDeathWatcherTest.java +++ b/common/src/test/java/io/netty/util/ThreadDeathWatcherTest.java @@ -120,7 +120,7 @@ public class ThreadDeathWatcherTest { @Test(timeout = 2000) public void testThreadGroup() throws InterruptedException { final ThreadGroup group = new ThreadGroup("group"); - final AtomicReference capturedGroup = new AtomicReference(); + final AtomicReference capturedGroup = new AtomicReference<>(); final Thread thread = new Thread(group, new Runnable() { @Override public void run() { diff --git a/common/src/test/java/io/netty/util/concurrent/DefaultPromiseTest.java b/common/src/test/java/io/netty/util/concurrent/DefaultPromiseTest.java index fd9a3e95d6..4cf11b0144 100644 --- a/common/src/test/java/io/netty/util/concurrent/DefaultPromiseTest.java +++ b/common/src/test/java/io/netty/util/concurrent/DefaultPromiseTest.java @@ -65,7 +65,7 @@ public class DefaultPromiseTest { @Test(expected = CancellationException.class) public void testCancellationExceptionIsThrownWhenBlockingGet() throws InterruptedException, ExecutionException { - final Promise promise = new DefaultPromise(ImmediateEventExecutor.INSTANCE); + final Promise promise = new DefaultPromise<>(ImmediateEventExecutor.INSTANCE); promise.cancel(false); promise.get(); } @@ -73,7 +73,7 @@ public class DefaultPromiseTest { @Test(expected = CancellationException.class) public void testCancellationExceptionIsThrownWhenBlockingGetWithTimeout() throws InterruptedException, ExecutionException, TimeoutException { - final Promise promise = new DefaultPromise(ImmediateEventExecutor.INSTANCE); + final Promise promise = new DefaultPromise<>(ImmediateEventExecutor.INSTANCE); promise.cancel(false); promise.get(1, TimeUnit.SECONDS); } @@ -126,11 +126,11 @@ public class DefaultPromiseTest { public void testListenerNotifyOrder() throws Exception { EventExecutor executor = new TestEventExecutor(); try { - final BlockingQueue> listeners = new LinkedBlockingQueue>(); + final BlockingQueue> listeners = new LinkedBlockingQueue<>(); int runs = 100000; for (int i = 0; i < runs; i++) { - final Promise promise = new DefaultPromise(executor); + final Promise promise = new DefaultPromise<>(executor); final FutureListener listener1 = new FutureListener() { @Override public void operationComplete(Future future) throws Exception { @@ -214,9 +214,9 @@ public class DefaultPromiseTest { executor = new TestEventExecutor(); final int numberOfAttempts = 4096; - final Map> promises = new HashMap>(); + final Map> promises = new HashMap<>(); for (int i = 0; i < numberOfAttempts; i++) { - final DefaultPromise promise = new DefaultPromise(executor); + final DefaultPromise promise = new DefaultPromise<>(executor); final Thread thread = new Thread(new Runnable() { @Override public void run() { @@ -241,7 +241,7 @@ public class DefaultPromiseTest { @Test public void signalUncancellableCompletionValue() { - final Promise promise = new DefaultPromise(ImmediateEventExecutor.INSTANCE); + final Promise promise = new DefaultPromise<>(ImmediateEventExecutor.INSTANCE); promise.setSuccess(Signal.valueOf(DefaultPromise.class, "UNCANCELLABLE")); assertTrue(promise.isDone()); assertTrue(promise.isSuccess()); @@ -249,7 +249,7 @@ public class DefaultPromiseTest { @Test public void signalSuccessCompletionValue() { - final Promise promise = new DefaultPromise(ImmediateEventExecutor.INSTANCE); + final Promise promise = new DefaultPromise<>(ImmediateEventExecutor.INSTANCE); promise.setSuccess(Signal.valueOf(DefaultPromise.class, "SUCCESS")); assertTrue(promise.isDone()); assertTrue(promise.isSuccess()); @@ -257,7 +257,7 @@ public class DefaultPromiseTest { @Test public void setUncancellableGetNow() { - final Promise promise = new DefaultPromise(ImmediateEventExecutor.INSTANCE); + final Promise promise = new DefaultPromise<>(ImmediateEventExecutor.INSTANCE); assertNull(promise.getNow()); assertTrue(promise.setUncancellable()); assertNull(promise.getNow()); @@ -298,7 +298,7 @@ public class DefaultPromiseTest { final CountDownLatch latch) { for (int i = 0; i < p.length; i ++) { final int finalI = i; - p[i] = new DefaultPromise(executor); + p[i] = new DefaultPromise<>(executor); p[i].addListener(new FutureListener() { @Override public void operationComplete(Future future) throws Exception { @@ -340,7 +340,7 @@ public class DefaultPromiseTest { final CountDownLatch latch) { for (int i = 0; i < p.length; i ++) { final int finalI = i; - p[i] = new DefaultPromise(executor); + p[i] = new DefaultPromise<>(executor); p[i].addListener(new FutureListener() { @Override public void operationComplete(Future future) throws Exception { @@ -376,7 +376,7 @@ public class DefaultPromiseTest { final AtomicInteger state = new AtomicInteger(); final CountDownLatch latch1 = new CountDownLatch(1); final CountDownLatch latch2 = new CountDownLatch(2); - final Promise promise = new DefaultPromise(executor); + final Promise promise = new DefaultPromise<>(executor); // Add a listener before completion so "lateListener" is used next time we add a listener. promise.addListener(new FutureListener() { @@ -439,7 +439,7 @@ public class DefaultPromiseTest { private static void testPromiseListenerAddWhenComplete(Throwable cause) throws InterruptedException { final CountDownLatch latch = new CountDownLatch(1); - final Promise promise = new DefaultPromise(ImmediateEventExecutor.INSTANCE); + final Promise promise = new DefaultPromise<>(ImmediateEventExecutor.INSTANCE); promise.addListener(new FutureListener() { @Override public void operationComplete(Future future) throws Exception { @@ -469,7 +469,7 @@ public class DefaultPromiseTest { latch.countDown(); } }; - final Promise promise = new DefaultPromise(executor); + final Promise promise = new DefaultPromise<>(executor); executor.execute(new Runnable() { @Override public void run() { diff --git a/common/src/test/java/io/netty/util/concurrent/DefaultThreadFactoryTest.java b/common/src/test/java/io/netty/util/concurrent/DefaultThreadFactoryTest.java index 8d788a2103..85d12d17cd 100644 --- a/common/src/test/java/io/netty/util/concurrent/DefaultThreadFactoryTest.java +++ b/common/src/test/java/io/netty/util/concurrent/DefaultThreadFactoryTest.java @@ -53,7 +53,7 @@ public class DefaultThreadFactoryTest { }); // holder for the thread factory, plays the role of a global singleton - final AtomicReference factory = new AtomicReference(); + final AtomicReference factory = new AtomicReference<>(); final AtomicInteger counter = new AtomicInteger(); final Runnable task = new Runnable() { @Override @@ -62,7 +62,7 @@ public class DefaultThreadFactoryTest { } }; - final AtomicReference interrupted = new AtomicReference(); + final AtomicReference interrupted = new AtomicReference<>(); // create the thread factory, since we are running the thread group brother, the thread // factory will now forever be tied to that group @@ -139,7 +139,7 @@ public class DefaultThreadFactoryTest { @Override public DefaultThreadFactory call() throws Exception { final AtomicReference factory = - new AtomicReference(); + new AtomicReference<>(); final Thread thread = new Thread(sticky, new Runnable() { @Override public void run() { @@ -189,8 +189,8 @@ public class DefaultThreadFactoryTest { private static void runStickyThreadGroupTest( final Callable callable, final ThreadGroup expected) throws InterruptedException { - final AtomicReference captured = new AtomicReference(); - final AtomicReference exception = new AtomicReference(); + final AtomicReference captured = new AtomicReference<>(); + final AtomicReference exception = new AtomicReference<>(); final Thread first = new Thread(new ThreadGroup("wrong"), new Runnable() { @Override @@ -223,8 +223,8 @@ public class DefaultThreadFactoryTest { @Test(timeout = 2000) public void testDefaultThreadFactoryNonStickyThreadGroupConstructor() throws InterruptedException { - final AtomicReference factory = new AtomicReference(); - final AtomicReference firstCaptured = new AtomicReference(); + final AtomicReference factory = new AtomicReference<>(); + final AtomicReference firstCaptured = new AtomicReference<>(); final ThreadGroup firstGroup = new ThreadGroup("first"); final Thread first = new Thread(firstGroup, new Runnable() { @@ -244,7 +244,7 @@ public class DefaultThreadFactoryTest { assertEquals(firstGroup, firstCaptured.get()); - final AtomicReference secondCaptured = new AtomicReference(); + final AtomicReference secondCaptured = new AtomicReference<>(); final ThreadGroup secondGroup = new ThreadGroup("second"); final Thread second = new Thread(secondGroup, new Runnable() { diff --git a/common/src/test/java/io/netty/util/concurrent/FastThreadLocalTest.java b/common/src/test/java/io/netty/util/concurrent/FastThreadLocalTest.java index 6457de297a..270d7624c4 100644 --- a/common/src/test/java/io/netty/util/concurrent/FastThreadLocalTest.java +++ b/common/src/test/java/io/netty/util/concurrent/FastThreadLocalTest.java @@ -58,7 +58,7 @@ public class FastThreadLocalTest { @Test(timeout = 10000) public void testRemoveAllFromFTLThread() throws Throwable { - final AtomicReference throwable = new AtomicReference(); + final AtomicReference throwable = new AtomicReference<>(); final Thread thread = new FastThreadLocalThread() { @Override public void run() { @@ -81,7 +81,7 @@ public class FastThreadLocalTest { @Test public void testMultipleSetRemove() throws Exception { - final FastThreadLocal threadLocal = new FastThreadLocal(); + final FastThreadLocal threadLocal = new FastThreadLocal<>(); final Runnable runnable = new Runnable() { @Override public void run() { @@ -108,8 +108,8 @@ public class FastThreadLocalTest { @Test public void testMultipleSetRemove_multipleThreadLocal() throws Exception { - final FastThreadLocal threadLocal = new FastThreadLocal(); - final FastThreadLocal threadLocal2 = new FastThreadLocal(); + final FastThreadLocal threadLocal = new FastThreadLocal<>(); + final FastThreadLocal threadLocal2 = new FastThreadLocal<>(); final Runnable runnable = new Runnable() { @Override public void run() { @@ -199,7 +199,7 @@ public class FastThreadLocalTest { private static final class TestFastThreadLocal extends FastThreadLocal { - final AtomicReference onRemovalCalled = new AtomicReference(); + final AtomicReference onRemovalCalled = new AtomicReference<>(); @Override protected String initialValue() throws Exception { diff --git a/common/src/test/java/io/netty/util/concurrent/GlobalEventExecutorTest.java b/common/src/test/java/io/netty/util/concurrent/GlobalEventExecutorTest.java index 35c2a59cd4..14eba7bcde 100644 --- a/common/src/test/java/io/netty/util/concurrent/GlobalEventExecutorTest.java +++ b/common/src/test/java/io/netty/util/concurrent/GlobalEventExecutorTest.java @@ -98,7 +98,7 @@ public class GlobalEventExecutorTest { @Test(timeout = 2000) public void testThreadGroup() throws InterruptedException { final ThreadGroup group = new ThreadGroup("group"); - final AtomicReference capturedGroup = new AtomicReference(); + final AtomicReference capturedGroup = new AtomicReference<>(); final Thread thread = new Thread(group, new Runnable() { @Override public void run() { diff --git a/common/src/test/java/io/netty/util/concurrent/NonStickyEventExecutorGroupTest.java b/common/src/test/java/io/netty/util/concurrent/NonStickyEventExecutorGroupTest.java index b32df7eb4f..d72a698166 100644 --- a/common/src/test/java/io/netty/util/concurrent/NonStickyEventExecutorGroupTest.java +++ b/common/src/test/java/io/netty/util/concurrent/NonStickyEventExecutorGroupTest.java @@ -46,7 +46,7 @@ public class NonStickyEventExecutorGroupTest { @Parameterized.Parameters(name = "{index}: maxTaskExecutePerRun = {0}") public static Collection data() throws Exception { - List params = new ArrayList(); + List params = new ArrayList<>(); params.add(new Object[] {64}); params.add(new Object[] {256}); params.add(new Object[] {1024}); @@ -65,8 +65,8 @@ public class NonStickyEventExecutorGroupTest { final NonStickyEventExecutorGroup nonStickyGroup = new NonStickyEventExecutorGroup(group, maxTaskExecutePerRun); try { final CountDownLatch startLatch = new CountDownLatch(1); - final AtomicReference error = new AtomicReference(); - List threadList = new ArrayList(threads); + final AtomicReference error = new AtomicReference<>(); + List threadList = new ArrayList<>(threads); for (int i = 0 ; i < threads; i++) { Thread thread = new Thread(new Runnable() { @Override @@ -126,10 +126,10 @@ public class NonStickyEventExecutorGroupTest { private static void execute(EventExecutorGroup group, CountDownLatch startLatch) throws Throwable { EventExecutor executor = group.next(); Assert.assertTrue(executor instanceof OrderedEventExecutor); - final AtomicReference cause = new AtomicReference(); + final AtomicReference cause = new AtomicReference<>(); final AtomicInteger last = new AtomicInteger(); int tasks = 10000; - List> futures = new ArrayList>(tasks); + List> futures = new ArrayList<>(tasks); final CountDownLatch latch = new CountDownLatch(tasks); startLatch.await(); diff --git a/common/src/test/java/io/netty/util/concurrent/PromiseAggregatorTest.java b/common/src/test/java/io/netty/util/concurrent/PromiseAggregatorTest.java index 06e3a017bf..38b7feb911 100644 --- a/common/src/test/java/io/netty/util/concurrent/PromiseAggregatorTest.java +++ b/common/src/test/java/io/netty/util/concurrent/PromiseAggregatorTest.java @@ -40,7 +40,7 @@ public class PromiseAggregatorTest { @SuppressWarnings("unchecked") Promise p = mock(Promise.class); PromiseAggregator> a = - new PromiseAggregator>(p); + new PromiseAggregator<>(p); expectedException.expect(NullPointerException.class); a.add((Promise[]) null); } @@ -50,7 +50,7 @@ public class PromiseAggregatorTest { public void testSuccessfulNoPending() throws Exception { Promise p = mock(Promise.class); PromiseAggregator> a = - new PromiseAggregator>(p); + new PromiseAggregator<>(p); Future future = mock(Future.class); when(p.setSuccess(null)).thenReturn(p); @@ -66,7 +66,7 @@ public class PromiseAggregatorTest { public void testSuccessfulPending() throws Exception { Promise p = mock(Promise.class); PromiseAggregator> a = - new PromiseAggregator>(p); + new PromiseAggregator<>(p); Promise p1 = mock(Promise.class); Promise p2 = mock(Promise.class); @@ -92,7 +92,7 @@ public class PromiseAggregatorTest { public void testFailedFutureFailPending() throws Exception { Promise p = mock(Promise.class); PromiseAggregator> a = - new PromiseAggregator>(p); + new PromiseAggregator<>(p); Promise p1 = mock(Promise.class); Promise p2 = mock(Promise.class); Throwable t = mock(Throwable.class); @@ -119,7 +119,7 @@ public class PromiseAggregatorTest { public void testFailedFutureNoFailPending() throws Exception { Promise p = mock(Promise.class); PromiseAggregator> a = - new PromiseAggregator>(p, false); + new PromiseAggregator<>(p, false); Promise p1 = mock(Promise.class); Promise p2 = mock(Promise.class); Throwable t = mock(Throwable.class); diff --git a/common/src/test/java/io/netty/util/concurrent/PromiseNotifierTest.java b/common/src/test/java/io/netty/util/concurrent/PromiseNotifierTest.java index 600e868c69..29930cad5f 100644 --- a/common/src/test/java/io/netty/util/concurrent/PromiseNotifierTest.java +++ b/common/src/test/java/io/netty/util/concurrent/PromiseNotifierTest.java @@ -30,14 +30,14 @@ public class PromiseNotifierTest { @Test public void testNullPromisesArray() { expectedException.expect(NullPointerException.class); - new PromiseNotifier>((Promise[]) null); + new PromiseNotifier<>((Promise[]) null); } @SuppressWarnings("unchecked") @Test public void testNullPromiseInArray() { expectedException.expect(IllegalArgumentException.class); - new PromiseNotifier>((Promise) null); + new PromiseNotifier<>((Promise) null); } @Test @@ -49,7 +49,7 @@ public class PromiseNotifierTest { @SuppressWarnings("unchecked") PromiseNotifier> notifier = - new PromiseNotifier>(p1, p2); + new PromiseNotifier<>(p1, p2); @SuppressWarnings("unchecked") Future future = mock(Future.class); @@ -72,7 +72,7 @@ public class PromiseNotifierTest { @SuppressWarnings("unchecked") PromiseNotifier> notifier = - new PromiseNotifier>(p1, p2); + new PromiseNotifier<>(p1, p2); @SuppressWarnings("unchecked") Future future = mock(Future.class); diff --git a/common/src/test/java/io/netty/util/concurrent/SingleThreadEventExecutorTest.java b/common/src/test/java/io/netty/util/concurrent/SingleThreadEventExecutorTest.java index efb0eb015e..80e610ea00 100644 --- a/common/src/test/java/io/netty/util/concurrent/SingleThreadEventExecutorTest.java +++ b/common/src/test/java/io/netty/util/concurrent/SingleThreadEventExecutorTest.java @@ -74,7 +74,7 @@ public class SingleThreadEventExecutorTest { @Test public void testThreadProperties() { - final AtomicReference threadRef = new AtomicReference(); + final AtomicReference threadRef = new AtomicReference<>(); SingleThreadEventExecutor executor = new SingleThreadEventExecutor( null, new DefaultThreadFactory("test"), false) { @Override diff --git a/common/src/test/java/io/netty/util/internal/DefaultPriorityQueueTest.java b/common/src/test/java/io/netty/util/internal/DefaultPriorityQueueTest.java index b4adc8e99b..8ac391b0ed 100644 --- a/common/src/test/java/io/netty/util/internal/DefaultPriorityQueueTest.java +++ b/common/src/test/java/io/netty/util/internal/DefaultPriorityQueueTest.java @@ -37,7 +37,7 @@ import static org.junit.Assert.fail; public class DefaultPriorityQueueTest { @Test public void testPoll() { - PriorityQueue queue = new DefaultPriorityQueue(TestElementComparator.INSTANCE, 0); + PriorityQueue queue = new DefaultPriorityQueue<>(TestElementComparator.INSTANCE, 0); assertEmptyQueue(queue); TestElement a = new TestElement(5); @@ -79,7 +79,7 @@ public class DefaultPriorityQueueTest { @Test public void testClear() { - PriorityQueue queue = new DefaultPriorityQueue(TestElementComparator.INSTANCE, 0); + PriorityQueue queue = new DefaultPriorityQueue<>(TestElementComparator.INSTANCE, 0); assertEmptyQueue(queue); TestElement a = new TestElement(5); @@ -111,7 +111,7 @@ public class DefaultPriorityQueueTest { @Test public void testClearIgnoringIndexes() { - PriorityQueue queue = new DefaultPriorityQueue(TestElementComparator.INSTANCE, 0); + PriorityQueue queue = new DefaultPriorityQueue<>(TestElementComparator.INSTANCE, 0); assertEmptyQueue(queue); TestElement a = new TestElement(5); @@ -151,7 +151,7 @@ public class DefaultPriorityQueueTest { } private static void testRemoval(boolean typed) { - PriorityQueue queue = new DefaultPriorityQueue(TestElementComparator.INSTANCE, 4); + PriorityQueue queue = new DefaultPriorityQueue<>(TestElementComparator.INSTANCE, 4); assertEmptyQueue(queue); TestElement a = new TestElement(5); @@ -200,7 +200,7 @@ public class DefaultPriorityQueueTest { @Test public void testZeroInitialSize() { - PriorityQueue queue = new DefaultPriorityQueue(TestElementComparator.INSTANCE, 0); + PriorityQueue queue = new DefaultPriorityQueue<>(TestElementComparator.INSTANCE, 0); assertEmptyQueue(queue); TestElement e = new TestElement(1); assertOffer(queue, e); @@ -213,7 +213,7 @@ public class DefaultPriorityQueueTest { @Test public void testPriorityChange() { - PriorityQueue queue = new DefaultPriorityQueue(TestElementComparator.INSTANCE, 0); + PriorityQueue queue = new DefaultPriorityQueue<>(TestElementComparator.INSTANCE, 0); assertEmptyQueue(queue); TestElement a = new TestElement(10); TestElement b = new TestElement(20); @@ -243,7 +243,7 @@ public class DefaultPriorityQueueTest { f.value = 5; queue.priorityChanged(f); - List expectedOrderList = new ArrayList(queue.size()); + List expectedOrderList = new ArrayList<>(queue.size()); expectedOrderList.addAll(Arrays.asList(a, b, c, d, e, f)); Collections.sort(expectedOrderList, TestElementComparator.INSTANCE); diff --git a/common/src/test/java/io/netty/util/internal/logging/AbstractInternalLoggerTest.java b/common/src/test/java/io/netty/util/internal/logging/AbstractInternalLoggerTest.java index 9a395eab25..aee49f99bb 100644 --- a/common/src/test/java/io/netty/util/internal/logging/AbstractInternalLoggerTest.java +++ b/common/src/test/java/io/netty/util/internal/logging/AbstractInternalLoggerTest.java @@ -32,7 +32,7 @@ public abstract class AbstractInternalLoggerTest { protected String loggerName = "foo"; protected T mockLog; protected InternalLogger logger; - protected final Map result = new HashMap(); + protected final Map result = new HashMap<>(); @SuppressWarnings("unchecked") protected V getResult(String key) { diff --git a/example/src/main/java/io/netty/example/factorial/FactorialClientHandler.java b/example/src/main/java/io/netty/example/factorial/FactorialClientHandler.java index 257eba81ae..e7037b3d68 100644 --- a/example/src/main/java/io/netty/example/factorial/FactorialClientHandler.java +++ b/example/src/main/java/io/netty/example/factorial/FactorialClientHandler.java @@ -36,7 +36,7 @@ public class FactorialClientHandler extends SimpleChannelInboundHandler answer = new LinkedBlockingQueue(); + final BlockingQueue answer = new LinkedBlockingQueue<>(); public BigInteger getFactorial() { boolean interrupted = false; diff --git a/example/src/main/java/io/netty/example/http2/helloworld/client/HttpResponseHandler.java b/example/src/main/java/io/netty/example/http2/helloworld/client/HttpResponseHandler.java index 5ba8c9ebf2..1451e7348b 100644 --- a/example/src/main/java/io/netty/example/http2/helloworld/client/HttpResponseHandler.java +++ b/example/src/main/java/io/netty/example/http2/helloworld/client/HttpResponseHandler.java @@ -53,7 +53,7 @@ public class HttpResponseHandler extends SimpleChannelInboundHandler put(int streamId, ChannelFuture writeFuture, ChannelPromise promise) { - return streamidPromiseMap.put(streamId, new SimpleEntry(writeFuture, promise)); + return streamidPromiseMap.put(streamId, new SimpleEntry<>(writeFuture, promise)); } /** diff --git a/example/src/main/java/io/netty/example/http2/tiles/ImageCache.java b/example/src/main/java/io/netty/example/http2/tiles/ImageCache.java index ad50d9f2e6..d9c0e451d5 100644 --- a/example/src/main/java/io/netty/example/http2/tiles/ImageCache.java +++ b/example/src/main/java/io/netty/example/http2/tiles/ImageCache.java @@ -31,7 +31,7 @@ public final class ImageCache { public static ImageCache INSTANCE = new ImageCache(); - private final Map imageBank = new HashMap(200); + private final Map imageBank = new HashMap<>(200); private ImageCache() { init(); diff --git a/example/src/main/java/io/netty/example/objectecho/ObjectEchoClientHandler.java b/example/src/main/java/io/netty/example/objectecho/ObjectEchoClientHandler.java index 2f6580cb37..43d4db7ce2 100644 --- a/example/src/main/java/io/netty/example/objectecho/ObjectEchoClientHandler.java +++ b/example/src/main/java/io/netty/example/objectecho/ObjectEchoClientHandler.java @@ -34,7 +34,7 @@ public class ObjectEchoClientHandler extends ChannelInboundHandlerAdapter { * Creates a client-side handler. */ public ObjectEchoClientHandler() { - firstMessage = new ArrayList(ObjectEchoClient.SIZE); + firstMessage = new ArrayList<>(ObjectEchoClient.SIZE); for (int i = 0; i < ObjectEchoClient.SIZE; i ++) { firstMessage.add(Integer.valueOf(i)); } diff --git a/example/src/main/java/io/netty/example/ocsp/OcspServerExample.java b/example/src/main/java/io/netty/example/ocsp/OcspServerExample.java index 805126dc52..e28578dac1 100644 --- a/example/src/main/java/io/netty/example/ocsp/OcspServerExample.java +++ b/example/src/main/java/io/netty/example/ocsp/OcspServerExample.java @@ -183,7 +183,7 @@ public class OcspServerExample { JcaX509CertificateConverter converter = new JcaX509CertificateConverter() .setProvider(new BouncyCastleProvider()); - List dst = new ArrayList(); + List dst = new ArrayList<>(); PEMParser parser = new PEMParser(reader); try { diff --git a/example/src/main/java/io/netty/example/redis/RedisClientHandler.java b/example/src/main/java/io/netty/example/redis/RedisClientHandler.java index 89fb99c44d..b54bfee9ae 100644 --- a/example/src/main/java/io/netty/example/redis/RedisClientHandler.java +++ b/example/src/main/java/io/netty/example/redis/RedisClientHandler.java @@ -41,7 +41,7 @@ public class RedisClientHandler extends ChannelDuplexHandler { @Override public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) { String[] commands = ((String) msg).split("\\s+"); - List children = new ArrayList(commands.length); + List children = new ArrayList<>(commands.length); for (String cmdString : commands) { children.add(new FullBulkStringRedisMessage(ByteBufUtil.writeUtf8(ctx.alloc(), cmdString))); } diff --git a/example/src/main/java/io/netty/example/spdy/client/HttpResponseClientHandler.java b/example/src/main/java/io/netty/example/spdy/client/HttpResponseClientHandler.java index 1b2c70e832..ac01cb1cd2 100644 --- a/example/src/main/java/io/netty/example/spdy/client/HttpResponseClientHandler.java +++ b/example/src/main/java/io/netty/example/spdy/client/HttpResponseClientHandler.java @@ -35,7 +35,7 @@ import java.util.concurrent.LinkedBlockingQueue; */ public class HttpResponseClientHandler extends SimpleChannelInboundHandler { - private final BlockingQueue queue = new LinkedBlockingQueue(); + private final BlockingQueue queue = new LinkedBlockingQueue<>(); @Override public void channelRead0(ChannelHandlerContext ctx, HttpObject msg) throws Exception { diff --git a/example/src/main/java/io/netty/example/worldclock/WorldClockClientHandler.java b/example/src/main/java/io/netty/example/worldclock/WorldClockClientHandler.java index 3909624980..93574d7bf1 100644 --- a/example/src/main/java/io/netty/example/worldclock/WorldClockClientHandler.java +++ b/example/src/main/java/io/netty/example/worldclock/WorldClockClientHandler.java @@ -38,7 +38,7 @@ public class WorldClockClientHandler extends SimpleChannelInboundHandler answer = new LinkedBlockingQueue(); + private final BlockingQueue answer = new LinkedBlockingQueue<>(); public WorldClockClientHandler() { super(false); @@ -71,7 +71,7 @@ public class WorldClockClientHandler extends SimpleChannelInboundHandler result = new ArrayList(); + List result = new ArrayList<>(); for (LocalTime lt: localTimes.getLocalTimeList()) { result.add( new Formatter().format( diff --git a/handler-proxy/src/test/java/io/netty/handler/proxy/ProxyHandlerTest.java b/handler-proxy/src/test/java/io/netty/handler/proxy/ProxyHandlerTest.java index 6f0f325d64..465eb4c310 100644 --- a/handler-proxy/src/test/java/io/netty/handler/proxy/ProxyHandlerTest.java +++ b/handler-proxy/src/test/java/io/netty/handler/proxy/ProxyHandlerTest.java @@ -409,7 +409,7 @@ public class ProxyHandlerTest { ); // Convert the test items to the list of constructor parameters. - List params = new ArrayList(items.size()); + List params = new ArrayList<>(items.size()); for (Object i: items) { params.add(new Object[] { i }); } @@ -454,8 +454,8 @@ public class ProxyHandlerTest { private static final class SuccessTestHandler extends SimpleChannelInboundHandler { - final Queue received = new LinkedBlockingQueue(); - final Queue exceptions = new LinkedBlockingQueue(); + final Queue received = new LinkedBlockingQueue<>(); + final Queue exceptions = new LinkedBlockingQueue<>(); volatile int eventCount; private static void readIfNeeded(ChannelHandlerContext ctx) { @@ -503,7 +503,7 @@ public class ProxyHandlerTest { private static final class FailureTestHandler extends SimpleChannelInboundHandler { - final Queue exceptions = new LinkedBlockingQueue(); + final Queue exceptions = new LinkedBlockingQueue<>(); /** * A latch that counts down when: diff --git a/handler-proxy/src/test/java/io/netty/handler/proxy/ProxyServer.java b/handler-proxy/src/test/java/io/netty/handler/proxy/ProxyServer.java index b2a726d394..e305b9d0f3 100644 --- a/handler-proxy/src/test/java/io/netty/handler/proxy/ProxyServer.java +++ b/handler-proxy/src/test/java/io/netty/handler/proxy/ProxyServer.java @@ -52,7 +52,7 @@ abstract class ProxyServer { protected final InternalLogger logger = InternalLoggerFactory.getInstance(getClass()); private final ServerSocketChannel ch; - private final Queue recordedExceptions = new LinkedBlockingQueue(); + private final Queue recordedExceptions = new LinkedBlockingQueue<>(); protected final TestMode testMode; protected final String username; protected final String password; @@ -152,7 +152,7 @@ abstract class ProxyServer { protected abstract class IntermediaryHandler extends SimpleChannelInboundHandler { - private final Queue received = new ArrayDeque(); + private final Queue received = new ArrayDeque<>(); private boolean finished; private Channel backend; diff --git a/handler/src/main/java/io/netty/handler/ssl/ApplicationProtocolUtil.java b/handler/src/main/java/io/netty/handler/ssl/ApplicationProtocolUtil.java index 0581e9b2c2..edd2527c51 100644 --- a/handler/src/main/java/io/netty/handler/ssl/ApplicationProtocolUtil.java +++ b/handler/src/main/java/io/netty/handler/ssl/ApplicationProtocolUtil.java @@ -36,7 +36,7 @@ final class ApplicationProtocolUtil { return null; } - List result = new ArrayList(initialListSize); + List result = new ArrayList<>(initialListSize); for (String p : protocols) { if (p == null || p.isEmpty()) { throw new IllegalArgumentException("protocol cannot be null or empty"); @@ -60,7 +60,7 @@ final class ApplicationProtocolUtil { return null; } - List result = new ArrayList(initialListSize); + List result = new ArrayList<>(initialListSize); for (String p : protocols) { if (p == null || p.isEmpty()) { throw new IllegalArgumentException("protocol cannot be null or empty"); diff --git a/handler/src/main/java/io/netty/handler/ssl/CipherSuiteConverter.java b/handler/src/main/java/io/netty/handler/ssl/CipherSuiteConverter.java index 94e951f7f5..616b0dbd80 100644 --- a/handler/src/main/java/io/netty/handler/ssl/CipherSuiteConverter.java +++ b/handler/src/main/java/io/netty/handler/ssl/CipherSuiteConverter.java @@ -102,13 +102,13 @@ final class CipherSuiteConverter { private static final Map> o2jTls13; static { - Map j2oTls13Map = new HashMap(); + Map j2oTls13Map = new HashMap<>(); j2oTls13Map.put("TLS_AES_128_GCM_SHA256", "AEAD-AES128-GCM-SHA256"); j2oTls13Map.put("TLS_AES_256_GCM_SHA384", "AEAD-AES256-GCM-SHA384"); j2oTls13Map.put("TLS_CHACHA20_POLY1305_SHA256", "AEAD-CHACHA20-POLY1305-SHA256"); j2oTls13 = Collections.unmodifiableMap(j2oTls13Map); - Map> o2jTls13Map = new HashMap>(); + Map> o2jTls13Map = new HashMap<>(); o2jTls13Map.put("TLS_AES_128_GCM_SHA256", singletonMap("TLS", "TLS_AES_128_GCM_SHA256")); o2jTls13Map.put("TLS_AES_256_GCM_SHA384", singletonMap("TLS", "TLS_AES_256_GCM_SHA384")); o2jTls13Map.put("TLS_CHACHA20_POLY1305_SHA256", singletonMap("TLS", "TLS_CHACHA20_POLY1305_SHA256")); @@ -174,7 +174,7 @@ final class CipherSuiteConverter { // Cache the reverse mapping after stripping the protocol prefix (TLS_ or SSL_) final String javaCipherSuiteSuffix = javaCipherSuite.substring(4); - Map p2j = new HashMap(4); + Map p2j = new HashMap<>(4); p2j.put("", javaCipherSuiteSuffix); p2j.put("SSL", "SSL_" + javaCipherSuiteSuffix); p2j.put("TLS", "TLS_" + javaCipherSuiteSuffix); @@ -317,7 +317,7 @@ final class CipherSuiteConverter { final String javaCipherSuiteTls = "TLS_" + javaCipherSuiteSuffix; // Cache the mapping. - final Map p2j = new HashMap(4); + final Map p2j = new HashMap<>(4); p2j.put("", javaCipherSuiteSuffix); p2j.put("SSL", javaCipherSuiteSsl); p2j.put("TLS", javaCipherSuiteTls); diff --git a/handler/src/main/java/io/netty/handler/ssl/ConscryptAlpnSslEngine.java b/handler/src/main/java/io/netty/handler/ssl/ConscryptAlpnSslEngine.java index d9767a7106..16b564b7dc 100644 --- a/handler/src/main/java/io/netty/handler/ssl/ConscryptAlpnSslEngine.java +++ b/handler/src/main/java/io/netty/handler/ssl/ConscryptAlpnSslEngine.java @@ -139,7 +139,7 @@ abstract class ConscryptAlpnSslEngine extends JdkSslEngine { protocolSelector = checkNotNull(applicationNegotiator.protocolSelectorFactory() .newSelector(this, - new LinkedHashSet(applicationNegotiator.protocols())), + new LinkedHashSet<>(applicationNegotiator.protocols())), "protocolSelector"); } diff --git a/handler/src/main/java/io/netty/handler/ssl/IdentityCipherSuiteFilter.java b/handler/src/main/java/io/netty/handler/ssl/IdentityCipherSuiteFilter.java index 9f21981034..44ace74357 100644 --- a/handler/src/main/java/io/netty/handler/ssl/IdentityCipherSuiteFilter.java +++ b/handler/src/main/java/io/netty/handler/ssl/IdentityCipherSuiteFilter.java @@ -49,7 +49,7 @@ public final class IdentityCipherSuiteFilter implements CipherSuiteFilter { defaultCiphers.toArray(new String[0]) : supportedCiphers.toArray(new String[0]); } else { - List newCiphers = new ArrayList(supportedCiphers.size()); + List newCiphers = new ArrayList<>(supportedCiphers.size()); for (String c : ciphers) { if (c == null) { break; diff --git a/handler/src/main/java/io/netty/handler/ssl/Java8SslUtils.java b/handler/src/main/java/io/netty/handler/ssl/Java8SslUtils.java index c47d965712..523ccacdcf 100644 --- a/handler/src/main/java/io/netty/handler/ssl/Java8SslUtils.java +++ b/handler/src/main/java/io/netty/handler/ssl/Java8SslUtils.java @@ -34,7 +34,7 @@ final class Java8SslUtils { if (names == null || names.isEmpty()) { return Collections.emptyList(); } - List strings = new ArrayList(names.size()); + List strings = new ArrayList<>(names.size()); for (SNIServerName serverName : names) { if (serverName instanceof SNIHostName) { @@ -55,7 +55,7 @@ final class Java8SslUtils { if (names == null || names.isEmpty()) { return Collections.emptyList(); } - List sniServerNames = new ArrayList(names.size()); + List sniServerNames = new ArrayList<>(names.size()); for (String name: names) { sniServerNames.add(new SNIHostName(name)); } diff --git a/handler/src/main/java/io/netty/handler/ssl/Java9SslEngine.java b/handler/src/main/java/io/netty/handler/ssl/Java9SslEngine.java index 5910855b41..546868bff0 100644 --- a/handler/src/main/java/io/netty/handler/ssl/Java9SslEngine.java +++ b/handler/src/main/java/io/netty/handler/ssl/Java9SslEngine.java @@ -82,7 +82,7 @@ final class Java9SslEngine extends JdkSslEngine { if (isServer) { selectionListener = null; alpnSelector = new AlpnSelector(applicationNegotiator.protocolSelectorFactory(). - newSelector(this, new LinkedHashSet(applicationNegotiator.protocols()))); + newSelector(this, new LinkedHashSet<>(applicationNegotiator.protocols()))); Java9SslUtils.setHandshakeApplicationProtocolSelector(engine, alpnSelector); } else { selectionListener = applicationNegotiator.protocolListenerFactory() diff --git a/handler/src/main/java/io/netty/handler/ssl/JdkSslContext.java b/handler/src/main/java/io/netty/handler/ssl/JdkSslContext.java index d74bbdec98..00e3e2fba8 100644 --- a/handler/src/main/java/io/netty/handler/ssl/JdkSslContext.java +++ b/handler/src/main/java/io/netty/handler/ssl/JdkSslContext.java @@ -83,11 +83,11 @@ public class JdkSslContext extends SslContext { SUPPORTED_CIPHERS = Collections.unmodifiableSet(supportedCiphers(engine)); DEFAULT_CIPHERS = Collections.unmodifiableList(defaultCiphers(engine, SUPPORTED_CIPHERS)); - List ciphersNonTLSv13 = new ArrayList(DEFAULT_CIPHERS); + List ciphersNonTLSv13 = new ArrayList<>(DEFAULT_CIPHERS); ciphersNonTLSv13.removeAll(Arrays.asList(SslUtils.DEFAULT_TLSV13_CIPHER_SUITES)); DEFAULT_CIPHERS_NON_TLSV13 = Collections.unmodifiableList(ciphersNonTLSv13); - Set suppertedCiphersNonTLSv13 = new LinkedHashSet(SUPPORTED_CIPHERS); + Set suppertedCiphersNonTLSv13 = new LinkedHashSet<>(SUPPORTED_CIPHERS); suppertedCiphersNonTLSv13.removeAll(Arrays.asList(SslUtils.DEFAULT_TLSV13_CIPHER_SUITES)); SUPPORTED_CIPHERS_NON_TLSV13 = Collections.unmodifiableSet(suppertedCiphersNonTLSv13); @@ -100,11 +100,11 @@ public class JdkSslContext extends SslContext { private static String[] defaultProtocols(SSLEngine engine) { // Choose the sensible default list of protocols. final String[] supportedProtocols = engine.getSupportedProtocols(); - Set supportedProtocolsSet = new HashSet(supportedProtocols.length); + Set supportedProtocolsSet = new HashSet<>(supportedProtocols.length); for (int i = 0; i < supportedProtocols.length; ++i) { supportedProtocolsSet.add(supportedProtocols[i]); } - List protocols = new ArrayList(); + List protocols = new ArrayList<>(); addIfSupported( supportedProtocolsSet, protocols, // Do not include TLSv1.3 for now by default. @@ -119,7 +119,7 @@ public class JdkSslContext extends SslContext { private static Set supportedCiphers(SSLEngine engine) { // Choose the sensible default list of cipher suites. final String[] supportedCiphers = engine.getSupportedCipherSuites(); - Set supportedCiphersSet = new LinkedHashSet(supportedCiphers.length); + Set supportedCiphersSet = new LinkedHashSet<>(supportedCiphers.length); for (int i = 0; i < supportedCiphers.length; ++i) { String supportedCipher = supportedCiphers[i]; supportedCiphersSet.add(supportedCipher); @@ -146,7 +146,7 @@ public class JdkSslContext extends SslContext { } private static List defaultCiphers(SSLEngine engine, Set supportedCiphers) { - List ciphers = new ArrayList(); + List ciphers = new ArrayList<>(); addIfSupported(supportedCiphers, ciphers, DEFAULT_CIPHER_SUITES); useFallbackCiphersIfDefaultIsEmpty(ciphers, engine.getEnabledCipherSuites()); return ciphers; diff --git a/handler/src/main/java/io/netty/handler/ssl/JettyAlpnSslEngine.java b/handler/src/main/java/io/netty/handler/ssl/JettyAlpnSslEngine.java index ce9f14a57e..342b49b6e4 100644 --- a/handler/src/main/java/io/netty/handler/ssl/JettyAlpnSslEngine.java +++ b/handler/src/main/java/io/netty/handler/ssl/JettyAlpnSslEngine.java @@ -117,7 +117,7 @@ abstract class JettyAlpnSslEngine extends JdkSslEngine { super(engine); checkNotNull(applicationNegotiator, "applicationNegotiator"); final ProtocolSelector protocolSelector = checkNotNull(applicationNegotiator.protocolSelectorFactory() - .newSelector(this, new LinkedHashSet(applicationNegotiator.protocols())), + .newSelector(this, new LinkedHashSet<>(applicationNegotiator.protocols())), "protocolSelector"); ALPN.put(engine, new ALPN.ServerProvider() { @Override diff --git a/handler/src/main/java/io/netty/handler/ssl/JettyNpnSslEngine.java b/handler/src/main/java/io/netty/handler/ssl/JettyNpnSslEngine.java index 77e7366e53..9e10465817 100644 --- a/handler/src/main/java/io/netty/handler/ssl/JettyNpnSslEngine.java +++ b/handler/src/main/java/io/netty/handler/ssl/JettyNpnSslEngine.java @@ -82,7 +82,7 @@ final class JettyNpnSslEngine extends JdkSslEngine { }); } else { final ProtocolSelector protocolSelector = checkNotNull(applicationNegotiator.protocolSelectorFactory() - .newSelector(this, new LinkedHashSet(applicationNegotiator.protocols())), + .newSelector(this, new LinkedHashSet<>(applicationNegotiator.protocols())), "protocolSelector"); NextProtoNego.put(engine, new ClientProvider() { @Override diff --git a/handler/src/main/java/io/netty/handler/ssl/OpenSsl.java b/handler/src/main/java/io/netty/handler/ssl/OpenSsl.java index 78a528ff98..fa7f33a4b8 100644 --- a/handler/src/main/java/io/netty/handler/ssl/OpenSsl.java +++ b/handler/src/main/java/io/netty/handler/ssl/OpenSsl.java @@ -130,8 +130,8 @@ public final class OpenSsl { if (cause == null) { logger.debug("netty-tcnative using native library: {}", SSL.versionString()); - final List defaultCiphers = new ArrayList(); - final Set availableOpenSslCipherSuites = new LinkedHashSet(128); + final List defaultCiphers = new ArrayList<>(); + final Set availableOpenSslCipherSuites = new LinkedHashSet<>(128); boolean supportsKeyManagerFactory = false; boolean useKeyManagerFactory = false; boolean supportsHostNameValidation = false; @@ -226,7 +226,7 @@ public final class OpenSsl { logger.warn("Failed to get the list of available OpenSSL cipher suites.", e); } AVAILABLE_OPENSSL_CIPHER_SUITES = Collections.unmodifiableSet(availableOpenSslCipherSuites); - final Set availableJavaCipherSuites = new LinkedHashSet( + final Set availableJavaCipherSuites = new LinkedHashSet<>( AVAILABLE_OPENSSL_CIPHER_SUITES.size() * 2); for (String cipher: AVAILABLE_OPENSSL_CIPHER_SUITES) { // Included converted but also openssl cipher name @@ -247,7 +247,7 @@ public final class OpenSsl { AVAILABLE_JAVA_CIPHER_SUITES = Collections.unmodifiableSet(availableJavaCipherSuites); - final Set availableCipherSuites = new LinkedHashSet( + final Set availableCipherSuites = new LinkedHashSet<>( AVAILABLE_OPENSSL_CIPHER_SUITES.size() + AVAILABLE_JAVA_CIPHER_SUITES.size()); availableCipherSuites.addAll(AVAILABLE_OPENSSL_CIPHER_SUITES); availableCipherSuites.addAll(AVAILABLE_JAVA_CIPHER_SUITES); @@ -257,7 +257,7 @@ public final class OpenSsl { SUPPORTS_HOSTNAME_VALIDATION = supportsHostNameValidation; USE_KEYMANAGER_FACTORY = useKeyManagerFactory; - Set protocols = new LinkedHashSet(6); + Set protocols = new LinkedHashSet<>(6); // Seems like there is no way to explicitly disable SSLv2Hello in openssl so it is always enabled protocols.add(PROTOCOL_SSL_V2_HELLO); if (doesSupportProtocol(SSL.SSL_PROTOCOL_SSLV2, SSL.SSL_OP_NO_SSLv2)) { @@ -510,7 +510,7 @@ public final class OpenSsl { String os = PlatformDependent.normalizedOs(); String arch = PlatformDependent.normalizedArch(); - Set libNames = new LinkedHashSet(4); + Set libNames = new LinkedHashSet<>(4); String staticLibName = "netty_tcnative"; // First, try loading the platform-specific library. Platform-specific diff --git a/handler/src/main/java/io/netty/handler/ssl/OpenSslCachingKeyMaterialProvider.java b/handler/src/main/java/io/netty/handler/ssl/OpenSslCachingKeyMaterialProvider.java index db8779bdbd..92a496cc1d 100644 --- a/handler/src/main/java/io/netty/handler/ssl/OpenSslCachingKeyMaterialProvider.java +++ b/handler/src/main/java/io/netty/handler/ssl/OpenSslCachingKeyMaterialProvider.java @@ -28,7 +28,7 @@ import java.util.concurrent.ConcurrentMap; */ final class OpenSslCachingKeyMaterialProvider extends OpenSslKeyMaterialProvider { - private final ConcurrentMap cache = new ConcurrentHashMap(); + private final ConcurrentMap cache = new ConcurrentHashMap<>(); OpenSslCachingKeyMaterialProvider(X509KeyManager keyManager, String password) { super(keyManager, password); diff --git a/handler/src/main/java/io/netty/handler/ssl/OpenSslKeyMaterialManager.java b/handler/src/main/java/io/netty/handler/ssl/OpenSslKeyMaterialManager.java index 9f0e0199ef..0e2e2c3fd2 100644 --- a/handler/src/main/java/io/netty/handler/ssl/OpenSslKeyMaterialManager.java +++ b/handler/src/main/java/io/netty/handler/ssl/OpenSslKeyMaterialManager.java @@ -48,7 +48,7 @@ final class OpenSslKeyMaterialManager { static final String KEY_TYPE_EC_RSA = "EC_RSA"; // key type mappings for types. - private static final Map KEY_TYPES = new HashMap(); + private static final Map KEY_TYPES = new HashMap<>(); static { KEY_TYPES.put("RSA", KEY_TYPE_RSA); KEY_TYPES.put("DHE_RSA", KEY_TYPE_RSA); @@ -68,7 +68,7 @@ final class OpenSslKeyMaterialManager { void setKeyMaterialServerSide(ReferenceCountedOpenSslEngine engine) throws SSLException { long ssl = engine.sslPointer(); String[] authMethods = SSL.authenticationMethods(ssl); - Set aliases = new HashSet(authMethods.length); + Set aliases = new HashSet<>(authMethods.length); for (String authMethod : authMethods) { String type = KEY_TYPES.get(authMethod); if (type != null) { diff --git a/handler/src/main/java/io/netty/handler/ssl/OpenSslX509KeyManagerFactory.java b/handler/src/main/java/io/netty/handler/ssl/OpenSslX509KeyManagerFactory.java index 90d94cb656..4ae7557b86 100644 --- a/handler/src/main/java/io/netty/handler/ssl/OpenSslX509KeyManagerFactory.java +++ b/handler/src/main/java/io/netty/handler/ssl/OpenSslX509KeyManagerFactory.java @@ -181,7 +181,7 @@ public final class OpenSslX509KeyManagerFactory extends KeyManagerFactory { OpenSslPopulatedKeyMaterialProvider( X509KeyManager keyManager, String password, Iterable aliases) { super(keyManager, password); - materialMap = new HashMap(); + materialMap = new HashMap<>(); boolean initComplete = false; try { for (String alias: aliases) { diff --git a/handler/src/main/java/io/netty/handler/ssl/PemReader.java b/handler/src/main/java/io/netty/handler/ssl/PemReader.java index 4cddad9c91..091d859816 100644 --- a/handler/src/main/java/io/netty/handler/ssl/PemReader.java +++ b/handler/src/main/java/io/netty/handler/ssl/PemReader.java @@ -78,7 +78,7 @@ final class PemReader { throw new CertificateException("failed to read certificate input stream", e); } - List certs = new ArrayList(); + List certs = new ArrayList<>(); Matcher m = CERT_PATTERN.matcher(content); int start = 0; for (;;) { diff --git a/handler/src/main/java/io/netty/handler/ssl/ReferenceCountedOpenSslClientContext.java b/handler/src/main/java/io/netty/handler/ssl/ReferenceCountedOpenSslClientContext.java index f508971f01..b562885e5e 100644 --- a/handler/src/main/java/io/netty/handler/ssl/ReferenceCountedOpenSslClientContext.java +++ b/handler/src/main/java/io/netty/handler/ssl/ReferenceCountedOpenSslClientContext.java @@ -50,12 +50,12 @@ import javax.security.auth.x500.X500Principal; public final class ReferenceCountedOpenSslClientContext extends ReferenceCountedOpenSslContext { private static final InternalLogger logger = InternalLoggerFactory.getInstance(ReferenceCountedOpenSslClientContext.class); - private static final Set SUPPORTED_KEY_TYPES = Collections.unmodifiableSet(new LinkedHashSet( + private static final Set SUPPORTED_KEY_TYPES = Collections.unmodifiableSet(new LinkedHashSet<>( Arrays.asList(OpenSslKeyMaterialManager.KEY_TYPE_RSA, - OpenSslKeyMaterialManager.KEY_TYPE_DH_RSA, - OpenSslKeyMaterialManager.KEY_TYPE_EC, - OpenSslKeyMaterialManager.KEY_TYPE_EC_RSA, - OpenSslKeyMaterialManager.KEY_TYPE_EC_EC))); + OpenSslKeyMaterialManager.KEY_TYPE_DH_RSA, + OpenSslKeyMaterialManager.KEY_TYPE_EC, + OpenSslKeyMaterialManager.KEY_TYPE_EC_RSA, + OpenSslKeyMaterialManager.KEY_TYPE_EC_EC))); private final OpenSslSessionContext sessionContext; ReferenceCountedOpenSslClientContext(X509Certificate[] trustCertCollection, TrustManagerFactory trustManagerFactory, @@ -289,7 +289,7 @@ public final class ReferenceCountedOpenSslClientContext extends ReferenceCounted // Try all of the supported key types. return SUPPORTED_KEY_TYPES; } - Set result = new HashSet(clientCertificateTypes.length); + Set result = new HashSet<>(clientCertificateTypes.length); for (byte keyTypeCode : clientCertificateTypes) { String keyType = clientKeyType(keyTypeCode); if (keyType == null) { diff --git a/handler/src/main/java/io/netty/handler/ssl/ReferenceCountedOpenSslEngine.java b/handler/src/main/java/io/netty/handler/ssl/ReferenceCountedOpenSslEngine.java index 4dba2ec522..9c1254c8f7 100644 --- a/handler/src/main/java/io/netty/handler/ssl/ReferenceCountedOpenSslEngine.java +++ b/handler/src/main/java/io/netty/handler/ssl/ReferenceCountedOpenSslEngine.java @@ -289,7 +289,7 @@ public class ReferenceCountedOpenSslEngine extends SSLEngine implements Referenc if (algs == null) { peerSupportedSignatureAlgorithms = EmptyArrays.EMPTY_STRINGS; } else { - Set algorithmList = new LinkedHashSet(algs.length); + Set algorithmList = new LinkedHashSet<>(algs.length); for (String alg: algs) { String converted = SignatureAlgorithmConverter.toJavaName(alg); @@ -1397,7 +1397,7 @@ public class ReferenceCountedOpenSslEngine extends SSLEngine implements Referenc if (enabled == null) { return EmptyArrays.EMPTY_STRINGS; } else { - List enabledList = new ArrayList(); + List enabledList = new ArrayList<>(); synchronized (this) { for (int i = 0; i < enabled.length; i++) { String mapped = toJavaCipherSuite(enabled[i]); @@ -1455,7 +1455,7 @@ public class ReferenceCountedOpenSslEngine extends SSLEngine implements Referenc @Override public final String[] getEnabledProtocols() { - List enabled = new ArrayList(6); + List enabled = new ArrayList<>(6); // Seems like there is no way to explicit disable SSLv2Hello in openssl so it is always enabled enabled.add(PROTOCOL_SSL_V2_HELLO); @@ -2028,7 +2028,7 @@ public class ReferenceCountedOpenSslEngine extends SSLEngine implements Referenc Map values = this.values; if (values == null) { // Use size of 2 to keep the memory overhead small - values = this.values = new HashMap(2); + values = this.values = new HashMap<>(2); } old = values.put(name, value); } diff --git a/handler/src/main/java/io/netty/handler/ssl/SslHandler.java b/handler/src/main/java/io/netty/handler/ssl/SslHandler.java index 1cb479533d..430364e1d1 100644 --- a/handler/src/main/java/io/netty/handler/ssl/SslHandler.java +++ b/handler/src/main/java/io/netty/handler/ssl/SslHandler.java @@ -1469,7 +1469,7 @@ public class SslHandler extends ByteToMessageDecoder implements ChannelOutboundH task.run(); } } else { - final List tasks = new ArrayList(2); + final List tasks = new ArrayList<>(2); for (;;) { final Runnable task = engine.getDelegatedTask(); if (task == null) { @@ -1728,7 +1728,7 @@ public class SslHandler extends ByteToMessageDecoder implements ChannelOutboundH if (!oldHandshakePromise.isDone()) { // There's no need to handshake because handshake is in progress already. // Merge the new promise into the old one. - oldHandshakePromise.addListener(new PromiseNotifier>(newHandshakePromise)); + oldHandshakePromise.addListener(new PromiseNotifier<>(newHandshakePromise)); } else { handshakePromise = newHandshakePromise; handshake(); diff --git a/handler/src/main/java/io/netty/handler/ssl/SslUtils.java b/handler/src/main/java/io/netty/handler/ssl/SslUtils.java index e7640365ad..7f2204d9d4 100644 --- a/handler/src/main/java/io/netty/handler/ssl/SslUtils.java +++ b/handler/src/main/java/io/netty/handler/ssl/SslUtils.java @@ -42,10 +42,10 @@ import static java.util.Arrays.asList; */ final class SslUtils { // See https://tools.ietf.org/html/rfc8446#appendix-B.4 - static final Set TLSV13_CIPHERS = Collections.unmodifiableSet(new LinkedHashSet( + static final Set TLSV13_CIPHERS = Collections.unmodifiableSet(new LinkedHashSet<>( asList("TLS_AES_256_GCM_SHA384", "TLS_CHACHA20_POLY1305_SHA256", - "TLS_AES_128_GCM_SHA256", "TLS_AES_128_CCM_8_SHA256", - "TLS_AES_128_CCM_SHA256"))); + "TLS_AES_128_GCM_SHA256", "TLS_AES_128_CCM_8_SHA256", + "TLS_AES_128_CCM_SHA256"))); // Protocols static final String PROTOCOL_SSL_V2_HELLO = "SSLv2Hello"; static final String PROTOCOL_SSL_V2 = "SSLv2"; @@ -108,7 +108,7 @@ final class SslUtils { DEFAULT_TLSV13_CIPHER_SUITES = EmptyArrays.EMPTY_STRINGS; } - List defaultCiphers = new ArrayList(); + List defaultCiphers = new ArrayList<>(); // GCM (Galois/Counter Mode) requires JDK 8. defaultCiphers.add("TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384"); defaultCiphers.add("TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256"); diff --git a/handler/src/main/java/io/netty/handler/ssl/SupportedCipherSuiteFilter.java b/handler/src/main/java/io/netty/handler/ssl/SupportedCipherSuiteFilter.java index 265672309f..d4baea85a8 100644 --- a/handler/src/main/java/io/netty/handler/ssl/SupportedCipherSuiteFilter.java +++ b/handler/src/main/java/io/netty/handler/ssl/SupportedCipherSuiteFilter.java @@ -40,10 +40,10 @@ public final class SupportedCipherSuiteFilter implements CipherSuiteFilter { final List newCiphers; if (ciphers == null) { - newCiphers = new ArrayList(defaultCiphers.size()); + newCiphers = new ArrayList<>(defaultCiphers.size()); ciphers = defaultCiphers; } else { - newCiphers = new ArrayList(supportedCiphers.size()); + newCiphers = new ArrayList<>(supportedCiphers.size()); } for (String c : ciphers) { if (c == null) { diff --git a/handler/src/main/java/io/netty/handler/ssl/util/FingerprintTrustManagerFactory.java b/handler/src/main/java/io/netty/handler/ssl/util/FingerprintTrustManagerFactory.java index 454334501e..94590ad3b7 100644 --- a/handler/src/main/java/io/netty/handler/ssl/util/FingerprintTrustManagerFactory.java +++ b/handler/src/main/java/io/netty/handler/ssl/util/FingerprintTrustManagerFactory.java @@ -160,7 +160,7 @@ public final class FingerprintTrustManagerFactory extends SimpleTrustManagerFact throw new NullPointerException("fingerprints"); } - List list = new ArrayList(fingerprints.length); + List list = new ArrayList<>(fingerprints.length); for (byte[] f: fingerprints) { if (f == null) { break; @@ -180,7 +180,7 @@ public final class FingerprintTrustManagerFactory extends SimpleTrustManagerFact throw new NullPointerException("fingerprints"); } - List list = new ArrayList(); + List list = new ArrayList<>(); for (String f: fingerprints) { if (f == null) { break; diff --git a/handler/src/main/java/io/netty/handler/stream/ChunkedWriteHandler.java b/handler/src/main/java/io/netty/handler/stream/ChunkedWriteHandler.java index f39328dff7..47569e1b14 100644 --- a/handler/src/main/java/io/netty/handler/stream/ChunkedWriteHandler.java +++ b/handler/src/main/java/io/netty/handler/stream/ChunkedWriteHandler.java @@ -70,7 +70,7 @@ public class ChunkedWriteHandler extends ChannelDuplexHandler { private static final InternalLogger logger = InternalLoggerFactory.getInstance(ChunkedWriteHandler.class); - private final Queue queue = new ArrayDeque(); + private final Queue queue = new ArrayDeque<>(); private volatile ChannelHandlerContext ctx; private PendingWrite currentWrite; diff --git a/handler/src/main/java/io/netty/handler/traffic/ChannelTrafficShapingHandler.java b/handler/src/main/java/io/netty/handler/traffic/ChannelTrafficShapingHandler.java index 8074a6a344..bdf7aee9a2 100644 --- a/handler/src/main/java/io/netty/handler/traffic/ChannelTrafficShapingHandler.java +++ b/handler/src/main/java/io/netty/handler/traffic/ChannelTrafficShapingHandler.java @@ -63,7 +63,7 @@ import java.util.concurrent.TimeUnit; * */ public class ChannelTrafficShapingHandler extends AbstractTrafficShapingHandler { - private final ArrayDeque messagesQueue = new ArrayDeque(); + private final ArrayDeque messagesQueue = new ArrayDeque<>(); private long queueSize; /** diff --git a/handler/src/main/java/io/netty/handler/traffic/GlobalChannelTrafficShapingHandler.java b/handler/src/main/java/io/netty/handler/traffic/GlobalChannelTrafficShapingHandler.java index 02b1697d86..a850b8ac00 100644 --- a/handler/src/main/java/io/netty/handler/traffic/GlobalChannelTrafficShapingHandler.java +++ b/handler/src/main/java/io/netty/handler/traffic/GlobalChannelTrafficShapingHandler.java @@ -461,7 +461,7 @@ public class GlobalChannelTrafficShapingHandler extends AbstractTrafficShapingHa PerChannel perChannel = channelQueues.get(key); if (perChannel == null) { perChannel = new PerChannel(); - perChannel.messagesQueue = new ArrayDeque(); + perChannel.messagesQueue = new ArrayDeque<>(); // Don't start it since managed through the Global one perChannel.channelTrafficCounter = new TrafficCounter(this, null, "ChannelTC" + ctx.channel().hashCode(), checkInterval); diff --git a/handler/src/main/java/io/netty/handler/traffic/GlobalTrafficShapingHandler.java b/handler/src/main/java/io/netty/handler/traffic/GlobalTrafficShapingHandler.java index ad624f85b8..9a516a670d 100644 --- a/handler/src/main/java/io/netty/handler/traffic/GlobalTrafficShapingHandler.java +++ b/handler/src/main/java/io/netty/handler/traffic/GlobalTrafficShapingHandler.java @@ -243,7 +243,7 @@ public class GlobalTrafficShapingHandler extends AbstractTrafficShapingHandler { PerChannel perChannel = channelQueues.get(key); if (perChannel == null) { perChannel = new PerChannel(); - perChannel.messagesQueue = new ArrayDeque(); + perChannel.messagesQueue = new ArrayDeque<>(); perChannel.queueSize = 0L; perChannel.lastReadTimestamp = TrafficCounter.milliSecondFromNano(); perChannel.lastWriteTimestamp = perChannel.lastReadTimestamp; diff --git a/handler/src/test/java/io/netty/handler/flow/FlowControlHandlerTest.java b/handler/src/test/java/io/netty/handler/flow/FlowControlHandlerTest.java index a4effb1f01..57e3edeef2 100644 --- a/handler/src/test/java/io/netty/handler/flow/FlowControlHandlerTest.java +++ b/handler/src/test/java/io/netty/handler/flow/FlowControlHandlerTest.java @@ -158,7 +158,7 @@ public class FlowControlHandlerTest { */ @Test public void testAutoReadingOff() throws Exception { - final Exchanger peerRef = new Exchanger(); + final Exchanger peerRef = new Exchanger<>(); final CountDownLatch latch = new CountDownLatch(3); ChannelInboundHandlerAdapter handler = new ChannelInboundHandlerAdapter() { @@ -237,7 +237,7 @@ public class FlowControlHandlerTest { */ @Test public void testFlowToggleAutoRead() throws Exception { - final Exchanger peerRef = new Exchanger(); + final Exchanger peerRef = new Exchanger<>(); final CountDownLatch msgRcvLatch1 = new CountDownLatch(1); final CountDownLatch msgRcvLatch2 = new CountDownLatch(1); final CountDownLatch msgRcvLatch3 = new CountDownLatch(1); @@ -319,7 +319,7 @@ public class FlowControlHandlerTest { */ @Test public void testFlowAutoReadOff() throws Exception { - final Exchanger peerRef = new Exchanger(); + final Exchanger peerRef = new Exchanger<>(); final CountDownLatch msgRcvLatch1 = new CountDownLatch(1); final CountDownLatch msgRcvLatch2 = new CountDownLatch(2); final CountDownLatch msgRcvLatch3 = new CountDownLatch(3); diff --git a/handler/src/test/java/io/netty/handler/logging/LoggingHandlerTest.java b/handler/src/test/java/io/netty/handler/logging/LoggingHandlerTest.java index 28416888ba..1c25338490 100644 --- a/handler/src/test/java/io/netty/handler/logging/LoggingHandlerTest.java +++ b/handler/src/test/java/io/netty/handler/logging/LoggingHandlerTest.java @@ -57,7 +57,7 @@ public class LoggingHandlerTest { private static final Logger rootLogger = (Logger) LoggerFactory.getLogger(ROOT_LOGGER_NAME); private static final Logger logger = (Logger) LoggerFactory.getLogger(LOGGER_NAME); - private static final List> oldAppenders = new ArrayList>(); + private static final List> oldAppenders = new ArrayList<>(); /** * Custom logback appender which gets used to match on log messages. */ diff --git a/handler/src/test/java/io/netty/handler/ssl/CipherSuiteCanaryTest.java b/handler/src/test/java/io/netty/handler/ssl/CipherSuiteCanaryTest.java index 2b4323bc16..26998b68de 100644 --- a/handler/src/test/java/io/netty/handler/ssl/CipherSuiteCanaryTest.java +++ b/handler/src/test/java/io/netty/handler/ssl/CipherSuiteCanaryTest.java @@ -68,7 +68,7 @@ public class CipherSuiteCanaryTest { @Parameters(name = "{index}: serverSslProvider = {0}, clientSslProvider = {1}, rfcCipherName = {2}") public static Collection parameters() { - List dst = new ArrayList(); + List dst = new ArrayList<>(); dst.addAll(expand("TLS_DHE_RSA_WITH_AES_128_GCM_SHA256")); // DHE-RSA-AES128-GCM-SHA256 return dst; } @@ -253,7 +253,7 @@ public class CipherSuiteCanaryTest { } private static List expand(String rfcCipherName) { - List dst = new ArrayList(); + List dst = new ArrayList<>(); SslProvider[] sslProviders = SslProvider.values(); for (int i = 0; i < sslProviders.length; i++) { diff --git a/handler/src/test/java/io/netty/handler/ssl/ConscryptJdkSslEngineInteropTest.java b/handler/src/test/java/io/netty/handler/ssl/ConscryptJdkSslEngineInteropTest.java index 0976264d7a..17daeb203f 100644 --- a/handler/src/test/java/io/netty/handler/ssl/ConscryptJdkSslEngineInteropTest.java +++ b/handler/src/test/java/io/netty/handler/ssl/ConscryptJdkSslEngineInteropTest.java @@ -33,7 +33,7 @@ public class ConscryptJdkSslEngineInteropTest extends SSLEngineTest { @Parameterized.Parameters(name = "{index}: bufferType = {0}, combo = {1}") public static Collection data() { - List params = new ArrayList(); + List params = new ArrayList<>(); for (BufferType type: BufferType.values()) { params.add(new Object[] { type, ProtocolCipherCombo.tlsv12()}); } diff --git a/handler/src/test/java/io/netty/handler/ssl/ConscryptSslEngineTest.java b/handler/src/test/java/io/netty/handler/ssl/ConscryptSslEngineTest.java index 7d06840990..2003d40c7a 100644 --- a/handler/src/test/java/io/netty/handler/ssl/ConscryptSslEngineTest.java +++ b/handler/src/test/java/io/netty/handler/ssl/ConscryptSslEngineTest.java @@ -32,7 +32,7 @@ public class ConscryptSslEngineTest extends SSLEngineTest { @Parameterized.Parameters(name = "{index}: bufferType = {0}, combo = {1}") public static Collection data() { - List params = new ArrayList(); + List params = new ArrayList<>(); for (BufferType type: BufferType.values()) { params.add(new Object[] { type, ProtocolCipherCombo.tlsv12()}); } diff --git a/handler/src/test/java/io/netty/handler/ssl/IdentityCipherSuiteFilterTest.java b/handler/src/test/java/io/netty/handler/ssl/IdentityCipherSuiteFilterTest.java index fd2dad8dc8..730dc20b91 100644 --- a/handler/src/test/java/io/netty/handler/ssl/IdentityCipherSuiteFilterTest.java +++ b/handler/src/test/java/io/netty/handler/ssl/IdentityCipherSuiteFilterTest.java @@ -29,7 +29,7 @@ public class IdentityCipherSuiteFilterTest { @Test public void regularInstanceDefaultsToDefaultCiphers() { List defaultCiphers = Arrays.asList("FOO", "BAR"); - Set supportedCiphers = new HashSet(Arrays.asList("BAZ", "QIX")); + Set supportedCiphers = new HashSet<>(Arrays.asList("BAZ", "QIX")); String[] filtered = IdentityCipherSuiteFilter.INSTANCE .filterCipherSuites(null, defaultCiphers, supportedCiphers); assertArrayEquals(defaultCiphers.toArray(), filtered); @@ -38,7 +38,7 @@ public class IdentityCipherSuiteFilterTest { @Test public void alternativeInstanceDefaultsToSupportedCiphers() { List defaultCiphers = Arrays.asList("FOO", "BAR"); - Set supportedCiphers = new HashSet(Arrays.asList("BAZ", "QIX")); + Set supportedCiphers = new HashSet<>(Arrays.asList("BAZ", "QIX")); String[] filtered = IdentityCipherSuiteFilter.INSTANCE_DEFAULTING_TO_SUPPORTED_CIPHERS .filterCipherSuites(null, defaultCiphers, supportedCiphers); assertArrayEquals(supportedCiphers.toArray(), filtered); diff --git a/handler/src/test/java/io/netty/handler/ssl/JdkConscryptSslEngineInteropTest.java b/handler/src/test/java/io/netty/handler/ssl/JdkConscryptSslEngineInteropTest.java index 309490af59..82d94363f3 100644 --- a/handler/src/test/java/io/netty/handler/ssl/JdkConscryptSslEngineInteropTest.java +++ b/handler/src/test/java/io/netty/handler/ssl/JdkConscryptSslEngineInteropTest.java @@ -34,7 +34,7 @@ public class JdkConscryptSslEngineInteropTest extends SSLEngineTest { @Parameterized.Parameters(name = "{index}: bufferType = {0}, combo = {1}") public static Collection data() { - List params = new ArrayList(); + List params = new ArrayList<>(); for (BufferType type: BufferType.values()) { params.add(new Object[] { type, ProtocolCipherCombo.tlsv12()}); } diff --git a/handler/src/test/java/io/netty/handler/ssl/JdkOpenSslEngineInteroptTest.java b/handler/src/test/java/io/netty/handler/ssl/JdkOpenSslEngineInteroptTest.java index 45b3c7e5e0..31e11c30b7 100644 --- a/handler/src/test/java/io/netty/handler/ssl/JdkOpenSslEngineInteroptTest.java +++ b/handler/src/test/java/io/netty/handler/ssl/JdkOpenSslEngineInteroptTest.java @@ -35,7 +35,7 @@ public class JdkOpenSslEngineInteroptTest extends SSLEngineTest { @Parameterized.Parameters(name = "{index}: bufferType = {0}, combo = {1}") public static Collection data() { - List params = new ArrayList(); + List params = new ArrayList<>(); for (BufferType type: BufferType.values()) { params.add(new Object[] { type, ProtocolCipherCombo.tlsv12()}); diff --git a/handler/src/test/java/io/netty/handler/ssl/JdkSslEngineTest.java b/handler/src/test/java/io/netty/handler/ssl/JdkSslEngineTest.java index 74f000fd01..58408650c6 100644 --- a/handler/src/test/java/io/netty/handler/ssl/JdkSslEngineTest.java +++ b/handler/src/test/java/io/netty/handler/ssl/JdkSslEngineTest.java @@ -144,7 +144,7 @@ public class JdkSslEngineTest extends SSLEngineTest { @Parameterized.Parameters(name = "{index}: providerType = {0}, bufferType = {1}, combo = {2}") public static Collection data() { - List params = new ArrayList(); + List params = new ArrayList<>(); for (ProviderType providerType : ProviderType.values()) { for (BufferType bufferType : BufferType.values()) { params.add(new Object[]{ providerType, bufferType, ProtocolCipherCombo.tlsv12()}); diff --git a/handler/src/test/java/io/netty/handler/ssl/OpenSslEngineTest.java b/handler/src/test/java/io/netty/handler/ssl/OpenSslEngineTest.java index 32be76781a..ea672a40a8 100644 --- a/handler/src/test/java/io/netty/handler/ssl/OpenSslEngineTest.java +++ b/handler/src/test/java/io/netty/handler/ssl/OpenSslEngineTest.java @@ -69,7 +69,7 @@ public class OpenSslEngineTest extends SSLEngineTest { @Parameterized.Parameters(name = "{index}: bufferType = {0}, combo = {1}") public static Collection data() { - List params = new ArrayList(); + List params = new ArrayList<>(); for (BufferType type: BufferType.values()) { params.add(new Object[] { type, ProtocolCipherCombo.tlsv12()}); @@ -376,7 +376,7 @@ public class OpenSslEngineTest extends SSLEngineTest { handshake(clientEngine, serverEngine); ByteBuffer src = allocateBuffer(1024); - List srcList = new ArrayList(); + List srcList = new ArrayList<>(); long srcsLen = 0; long maxLen = ((long) MAX_VALUE) * 2; diff --git a/handler/src/test/java/io/netty/handler/ssl/OpenSslJdkSslEngineInteroptTest.java b/handler/src/test/java/io/netty/handler/ssl/OpenSslJdkSslEngineInteroptTest.java index df4e757e50..f57722cc80 100644 --- a/handler/src/test/java/io/netty/handler/ssl/OpenSslJdkSslEngineInteroptTest.java +++ b/handler/src/test/java/io/netty/handler/ssl/OpenSslJdkSslEngineInteroptTest.java @@ -37,7 +37,7 @@ public class OpenSslJdkSslEngineInteroptTest extends SSLEngineTest { @Parameterized.Parameters(name = "{index}: bufferType = {0}, combo = {1}") public static Collection data() { - List params = new ArrayList(); + List params = new ArrayList<>(); for (BufferType type: BufferType.values()) { params.add(new Object[] { type, ProtocolCipherCombo.tlsv12()}); diff --git a/handler/src/test/java/io/netty/handler/ssl/ParameterizedSslHandlerTest.java b/handler/src/test/java/io/netty/handler/ssl/ParameterizedSslHandlerTest.java index 6d01a2673e..a647302a97 100644 --- a/handler/src/test/java/io/netty/handler/ssl/ParameterizedSslHandlerTest.java +++ b/handler/src/test/java/io/netty/handler/ssl/ParameterizedSslHandlerTest.java @@ -65,14 +65,14 @@ public class ParameterizedSslHandlerTest { @Parameterized.Parameters(name = "{index}: clientProvider={0}, {index}: serverProvider={1}") public static Collection data() { - List providers = new ArrayList(3); + List providers = new ArrayList<>(3); if (OpenSsl.isAvailable()) { providers.add(SslProvider.OPENSSL); providers.add(SslProvider.OPENSSL_REFCNT); } providers.add(SslProvider.JDK); - List params = new ArrayList(); + List params = new ArrayList<>(); for (SslProvider cp: providers) { for (SslProvider sp: providers) { @@ -413,7 +413,7 @@ public class ParameterizedSslHandlerTest { SslHandler handler = sslServerCtx.newHandler(ch.alloc()); handler.setCloseNotifyReadTimeoutMillis(closeNotifyReadTimeout); handler.sslCloseFuture().addListener( - new PromiseNotifier>(serverPromise)); + new PromiseNotifier<>(serverPromise)); handler.handshakeFuture().addListener(new FutureListener() { @Override public void operationComplete(Future future) { @@ -452,7 +452,7 @@ public class ParameterizedSslHandlerTest { SslHandler handler = sslClientCtx.newHandler(ch.alloc()); handler.setCloseNotifyReadTimeoutMillis(closeNotifyReadTimeout); handler.sslCloseFuture().addListener( - new PromiseNotifier>(clientPromise)); + new PromiseNotifier<>(clientPromise)); handler.handshakeFuture().addListener(new FutureListener() { @Override public void operationComplete(Future future) { diff --git a/handler/src/test/java/io/netty/handler/ssl/RenegotiateTest.java b/handler/src/test/java/io/netty/handler/ssl/RenegotiateTest.java index a3a851cfcb..f62766e4ba 100644 --- a/handler/src/test/java/io/netty/handler/ssl/RenegotiateTest.java +++ b/handler/src/test/java/io/netty/handler/ssl/RenegotiateTest.java @@ -40,7 +40,7 @@ public abstract class RenegotiateTest { @Test(timeout = 30000) public void testRenegotiateServer() throws Throwable { - final AtomicReference error = new AtomicReference(); + final AtomicReference error = new AtomicReference<>(); final CountDownLatch latch = new CountDownLatch(2); SelfSignedCertificate cert = new SelfSignedCertificate(); EventLoopGroup group = new LocalEventLoopGroup(); diff --git a/handler/src/test/java/io/netty/handler/ssl/SSLEngineTest.java b/handler/src/test/java/io/netty/handler/ssl/SSLEngineTest.java index 4104fbe294..a30897446c 100644 --- a/handler/src/test/java/io/netty/handler/ssl/SSLEngineTest.java +++ b/handler/src/test/java/io/netty/handler/ssl/SSLEngineTest.java @@ -2580,10 +2580,10 @@ public abstract class SSLEngineTest { SSLEngine server = wrapEngine(ctx.newEngine(UnpooledByteBufAllocator.DEFAULT)); try { - Set supported = new HashSet(Arrays.asList(server.getSupportedProtocols())); + Set supported = new HashSet<>(Arrays.asList(server.getSupportedProtocols())); if (supported.contains(protocol)) { server.setEnabledProtocols(server.getSupportedProtocols()); - assertEquals(supported, new HashSet(Arrays.asList(server.getSupportedProtocols()))); + assertEquals(supported, new HashSet<>(Arrays.asList(server.getSupportedProtocols()))); for (String disabled : disabledProtocols) { supported.remove(disabled); @@ -2593,7 +2593,7 @@ public abstract class SSLEngineTest { return; } server.setEnabledProtocols(supported.toArray(new String[0])); - assertEquals(supported, new HashSet(Arrays.asList(server.getEnabledProtocols()))); + assertEquals(supported, new HashSet<>(Arrays.asList(server.getEnabledProtocols()))); server.setEnabledProtocols(server.getSupportedProtocols()); } } finally { @@ -2678,7 +2678,7 @@ public abstract class SSLEngineTest { @Test public void testInvalidCipher() throws Exception { SelfSignedCertificate cert = new SelfSignedCertificate(); - List cipherList = new ArrayList(); + List cipherList = new ArrayList<>(); Collections.addAll(cipherList, ((SSLSocketFactory) SSLSocketFactory.getDefault()).getDefaultCipherSuites()); cipherList.add("InvalidCipher"); SSLEngine server = null; diff --git a/handler/src/test/java/io/netty/handler/ssl/SniClientJava8TestUtil.java b/handler/src/test/java/io/netty/handler/ssl/SniClientJava8TestUtil.java index a44878868b..9f0beed452 100644 --- a/handler/src/test/java/io/netty/handler/ssl/SniClientJava8TestUtil.java +++ b/handler/src/test/java/io/netty/handler/ssl/SniClientJava8TestUtil.java @@ -281,7 +281,7 @@ final class SniClientJava8TestUtil { @Override protected KeyManager[] engineGetKeyManagers() { - List managers = new ArrayList(); + List managers = new ArrayList<>(); for (final KeyManager km: factory.getKeyManagers()) { if (km instanceof X509ExtendedKeyManager) { managers.add(new X509ExtendedKeyManager() { diff --git a/handler/src/test/java/io/netty/handler/ssl/SniClientTest.java b/handler/src/test/java/io/netty/handler/ssl/SniClientTest.java index 19298affd9..4aa23d2c58 100644 --- a/handler/src/test/java/io/netty/handler/ssl/SniClientTest.java +++ b/handler/src/test/java/io/netty/handler/ssl/SniClientTest.java @@ -52,13 +52,13 @@ public class SniClientTest { @Parameters(name = "{index}: serverSslProvider = {0}, clientSslProvider = {1}") public static Collection parameters() { - List providers = new ArrayList(Arrays.asList(SslProvider.values())); + List providers = new ArrayList<>(Arrays.asList(SslProvider.values())); if (!OpenSsl.isAvailable()) { providers.remove(SslProvider.OPENSSL); providers.remove(SslProvider.OPENSSL_REFCNT); } - List params = new ArrayList(); + List params = new ArrayList<>(); for (SslProvider sp: providers) { for (SslProvider cp: providers) { params.add(new Object[] { sp, cp }); diff --git a/handler/src/test/java/io/netty/handler/ssl/SniHandlerTest.java b/handler/src/test/java/io/netty/handler/ssl/SniHandlerTest.java index 976821b936..87dbaaba3d 100644 --- a/handler/src/test/java/io/netty/handler/ssl/SniHandlerTest.java +++ b/handler/src/test/java/io/netty/handler/ssl/SniHandlerTest.java @@ -126,7 +126,7 @@ public class SniHandlerTest { @Parameterized.Parameters(name = "{index}: sslProvider={0}") public static Iterable data() { - List params = new ArrayList(3); + List params = new ArrayList<>(3); if (OpenSsl.isAvailable()) { params.add(SslProvider.OPENSSL); params.add(SslProvider.OPENSSL_REFCNT); @@ -146,8 +146,8 @@ public class SniHandlerTest { SslContext nettyContext = makeSslContext(provider, false); try { final AtomicReference evtRef = - new AtomicReference(); - SniHandler handler = new SniHandler(new DomainNameMappingBuilder(nettyContext).build()); + new AtomicReference<>(); + SniHandler handler = new SniHandler(new DomainNameMappingBuilder<>(nettyContext).build()); EmbeddedChannel ch = new EmbeddedChannel(handler, new ChannelInboundHandlerAdapter() { @Override public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception { @@ -184,7 +184,7 @@ public class SniHandlerTest { SslContext leanContext2 = makeSslContext(provider, false); try { - DomainNameMapping mapping = new DomainNameMappingBuilder(nettyContext) + DomainNameMapping mapping = new DomainNameMappingBuilder<>(nettyContext) .add("*.netty.io", nettyContext) // input with custom cases .add("*.LEANCLOUD.CN", leanContext) @@ -193,7 +193,7 @@ public class SniHandlerTest { .add("chat4.leancloud.cn", leanContext2) .build(); - final AtomicReference evtRef = new AtomicReference(); + final AtomicReference evtRef = new AtomicReference<>(); SniHandler handler = new SniHandler(mapping); EmbeddedChannel ch = new EmbeddedChannel(handler, new ChannelInboundHandlerAdapter() { @Override @@ -247,7 +247,7 @@ public class SniHandlerTest { SslContext leanContext2 = makeSslContext(provider, false); try { - DomainNameMapping mapping = new DomainNameMappingBuilder(nettyContext) + DomainNameMapping mapping = new DomainNameMappingBuilder<>(nettyContext) .add("*.netty.io", nettyContext) // input with custom cases .add("*.LEANCLOUD.CN", leanContext) @@ -290,7 +290,7 @@ public class SniHandlerTest { SslContext leanContext2 = makeSslContext(provider, false); try { - DomainNameMapping mapping = new DomainNameMappingBuilder(nettyContext) + DomainNameMapping mapping = new DomainNameMappingBuilder<>(nettyContext) .add("*.netty.io", nettyContext) // input with custom cases .add("*.LEANCLOUD.CN", leanContext) @@ -342,7 +342,7 @@ public class SniHandlerTest { final CountDownLatch serverApnDoneLatch = new CountDownLatch(1); final CountDownLatch clientApnDoneLatch = new CountDownLatch(1); - final DomainNameMapping mapping = new DomainNameMappingBuilder(nettyContext) + final DomainNameMapping mapping = new DomainNameMappingBuilder<>(nettyContext) .add("*.netty.io", nettyContext) .add("sni.fake.site", sniContext).build(); final SniHandler handler = new SniHandler(mapping); diff --git a/handler/src/test/java/io/netty/handler/ssl/SslErrorTest.java b/handler/src/test/java/io/netty/handler/ssl/SslErrorTest.java index 9f205825e5..f32243e85c 100644 --- a/handler/src/test/java/io/netty/handler/ssl/SslErrorTest.java +++ b/handler/src/test/java/io/netty/handler/ssl/SslErrorTest.java @@ -66,8 +66,8 @@ public class SslErrorTest { @Parameterized.Parameters(name = "{index}: serverProvider = {0}, clientProvider = {1}, exception = {2}") public static Collection data() { - List serverProviders = new ArrayList(2); - List clientProviders = new ArrayList(3); + List serverProviders = new ArrayList<>(2); + List clientProviders = new ArrayList<>(3); if (OpenSsl.isAvailable()) { serverProviders.add(SslProvider.OPENSSL); @@ -79,7 +79,7 @@ public class SslErrorTest { // alert all the time, sigh..... clientProviders.add(SslProvider.JDK); - List exceptions = new ArrayList(6); + List exceptions = new ArrayList<>(6); exceptions.add(new CertificateExpiredException()); exceptions.add(new CertificateNotYetValidException()); exceptions.add(new CertificateRevokedException( @@ -91,7 +91,7 @@ public class SslErrorTest { exceptions.add(newCertificateException(CertPathValidatorException.BasicReason.NOT_YET_VALID)); exceptions.add(newCertificateException(CertPathValidatorException.BasicReason.REVOKED)); - List params = new ArrayList(); + List params = new ArrayList<>(); for (SslProvider serverProvider: serverProviders) { for (SslProvider clientProvider: clientProviders) { for (CertificateException exception: exceptions) { diff --git a/handler/src/test/java/io/netty/handler/ssl/SslHandlerTest.java b/handler/src/test/java/io/netty/handler/ssl/SslHandlerTest.java index 19f4728ff1..78da18e717 100644 --- a/handler/src/test/java/io/netty/handler/ssl/SslHandlerTest.java +++ b/handler/src/test/java/io/netty/handler/ssl/SslHandlerTest.java @@ -420,7 +420,7 @@ public class SslHandlerTest { @Test(timeout = 5000) public void testEventsFired() throws Exception { SSLEngine engine = newServerModeSSLEngine(); - final BlockingQueue events = new LinkedBlockingQueue(); + final BlockingQueue events = new LinkedBlockingQueue<>(); EmbeddedChannel channel = new EmbeddedChannel(new SslHandler(engine), new ChannelInboundHandlerAdapter() { @Override public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception { @@ -448,7 +448,7 @@ public class SslHandlerTest { final SslContext sslServerCtx = SslContextBuilder.forServer(ssc.certificate(), ssc.privateKey()).build(); final CountDownLatch latch = new CountDownLatch(2); final CountDownLatch latch2 = new CountDownLatch(2); - final BlockingQueue events = new LinkedBlockingQueue(); + final BlockingQueue events = new LinkedBlockingQueue<>(); Channel serverChannel = null; Channel clientChannel = null; EventLoopGroup group = new LocalEventLoopGroup(); @@ -630,7 +630,7 @@ public class SslHandlerTest { }); sc = sb.bind(address).syncUninterruptibly().channel(); - final AtomicReference sslHandlerRef = new AtomicReference(); + final AtomicReference sslHandlerRef = new AtomicReference<>(); Bootstrap b = new Bootstrap() .group(group) .channel(LocalChannel.class) @@ -691,7 +691,7 @@ public class SslHandlerTest { Channel sc = null; Channel cc = null; final CountDownLatch activeLatch = new CountDownLatch(1); - final AtomicReference errorRef = new AtomicReference(); + final AtomicReference errorRef = new AtomicReference<>(); final SslHandler sslHandler = sslClientCtx.newHandler(UnpooledByteBufAllocator.DEFAULT); try { sc = new ServerBootstrap() diff --git a/handler/src/test/java/io/netty/handler/ssl/ocsp/OcspTest.java b/handler/src/test/java/io/netty/handler/ssl/ocsp/OcspTest.java index 329218de7b..ddb6a5f0d9 100644 --- a/handler/src/test/java/io/netty/handler/ssl/ocsp/OcspTest.java +++ b/handler/src/test/java/io/netty/handler/ssl/ocsp/OcspTest.java @@ -208,7 +208,7 @@ public class OcspTest { * The Server provides an OCSP staple and the Client rejects it. */ private static void testClientRejectingOcspStaple(SslProvider sslProvider) throws Exception { - final AtomicReference causeRef = new AtomicReference(); + final AtomicReference causeRef = new AtomicReference<>(); final CountDownLatch latch = new CountDownLatch(1); ChannelInboundHandlerAdapter clientHandler = new ChannelInboundHandlerAdapter() { @@ -298,7 +298,7 @@ public class OcspTest { * The exception should bubble up on the client side and the connection should get closed. */ private static void testClientException(SslProvider sslProvider) throws Exception { - final AtomicReference causeRef = new AtomicReference(); + final AtomicReference causeRef = new AtomicReference<>(); final CountDownLatch latch = new CountDownLatch(1); ChannelInboundHandlerAdapter clientHandler = new ChannelInboundHandlerAdapter() { diff --git a/handler/src/test/java/io/netty/handler/timeout/IdleStateHandlerTest.java b/handler/src/test/java/io/netty/handler/timeout/IdleStateHandlerTest.java index 0a5b627822..56891f6848 100644 --- a/handler/src/test/java/io/netty/handler/timeout/IdleStateHandlerTest.java +++ b/handler/src/test/java/io/netty/handler/timeout/IdleStateHandlerTest.java @@ -71,7 +71,7 @@ public class IdleStateHandlerTest { assertTrue("The number of expected events must be >= 1", expected.length >= 1); - final List events = new ArrayList(); + final List events = new ArrayList<>(); ChannelInboundHandlerAdapter handler = new ChannelInboundHandlerAdapter() { @Override public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception { @@ -162,7 +162,7 @@ public class IdleStateHandlerTest { private static void anyNotIdle(TestableIdleStateHandler idleStateHandler, Action action, Object expected) throws Exception { - final List events = new ArrayList(); + final List events = new ArrayList<>(); ChannelInboundHandlerAdapter handler = new ChannelInboundHandlerAdapter() { @Override public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception { @@ -222,7 +222,7 @@ public class IdleStateHandlerTest { TestableIdleStateHandler idleStateHandler = new TestableIdleStateHandler( true, 0L, writerIdleTime, allIdleTime, TimeUnit.SECONDS); - final List events = new ArrayList(); + final List events = new ArrayList<>(); ChannelInboundHandlerAdapter handler = new ChannelInboundHandlerAdapter() { @Override public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception { diff --git a/microbench/src/main/java/io/netty/buffer/CompositeByteBufRandomAccessBenchmark.java b/microbench/src/main/java/io/netty/buffer/CompositeByteBufRandomAccessBenchmark.java index bb2d9283f0..fb40b17216 100644 --- a/microbench/src/main/java/io/netty/buffer/CompositeByteBufRandomAccessBenchmark.java +++ b/microbench/src/main/java/io/netty/buffer/CompositeByteBufRandomAccessBenchmark.java @@ -86,7 +86,7 @@ public class CompositeByteBufRandomAccessBenchmark extends AbstractMicrobenchmar private static ByteBuf newBufferSmallChunks(int length) { - List buffers = new ArrayList(((length + 1) / 45) * 19); + List buffers = new ArrayList<>(((length + 1) / 45) * 19); for (int i = 0; i < length + 45; i += 45) { for (int j = 1; j <= 9; j++) { buffers.add(EMPTY_BUFFER); @@ -103,7 +103,7 @@ public class CompositeByteBufRandomAccessBenchmark extends AbstractMicrobenchmar private static ByteBuf newBufferLargeChunks(int length) { - List buffers = new ArrayList((length + 1) / 512); + List buffers = new ArrayList<>((length + 1) / 512); for (int i = 0; i < length + 1536; i += 1536) { buffers.add(wrappedBuffer(new byte[512])); buffers.add(EMPTY_BUFFER); diff --git a/microbench/src/main/java/io/netty/buffer/CompositeByteBufSequentialBenchmark.java b/microbench/src/main/java/io/netty/buffer/CompositeByteBufSequentialBenchmark.java index 9ba6f19aa8..d8c009c00b 100644 --- a/microbench/src/main/java/io/netty/buffer/CompositeByteBufSequentialBenchmark.java +++ b/microbench/src/main/java/io/netty/buffer/CompositeByteBufSequentialBenchmark.java @@ -100,7 +100,7 @@ public class CompositeByteBufSequentialBenchmark extends AbstractMicrobenchmark private static ByteBuf newBufferSmallChunks(int length) { - List buffers = new ArrayList(((length + 1) / 45) * 19); + List buffers = new ArrayList<>(((length + 1) / 45) * 19); for (int i = 0; i < length + 45; i += 45) { for (int j = 1; j <= 9; j++) { buffers.add(EMPTY_BUFFER); @@ -117,7 +117,7 @@ public class CompositeByteBufSequentialBenchmark extends AbstractMicrobenchmark private static ByteBuf newBufferLargeChunks(int length) { - List buffers = new ArrayList((length + 1) / 512); + List buffers = new ArrayList<>((length + 1) / 512); for (int i = 0; i < length + 1536; i += 1536) { buffers.add(wrappedBuffer(new byte[512])); buffers.add(EMPTY_BUFFER); diff --git a/microbench/src/main/java/io/netty/buffer/CompositeByteBufWriteOutBenchmark.java b/microbench/src/main/java/io/netty/buffer/CompositeByteBufWriteOutBenchmark.java index e525c8cd0a..50b1fece8a 100644 --- a/microbench/src/main/java/io/netty/buffer/CompositeByteBufWriteOutBenchmark.java +++ b/microbench/src/main/java/io/netty/buffer/CompositeByteBufWriteOutBenchmark.java @@ -91,7 +91,7 @@ public class CompositeByteBufWriteOutBenchmark extends AbstractMicrobenchmark { private static ByteBuf[] makeSmallChunks(int length) { - List buffers = new ArrayList(((length + 1) / 48) * 9); + List buffers = new ArrayList<>(((length + 1) / 48) * 9); for (int i = 0; i < length + 48; i += 48) { for (int j = 4; j <= 12; j++) { buffers.add(wrappedBuffer(new byte[j])); @@ -103,7 +103,7 @@ public class CompositeByteBufWriteOutBenchmark extends AbstractMicrobenchmark { private static ByteBuf[] makeLargeChunks(int length) { - List buffers = new ArrayList((length + 1) / 768); + List buffers = new ArrayList<>((length + 1) / 768); for (int i = 0; i < length + 1536; i += 1536) { buffers.add(wrappedBuffer(new byte[512])); buffers.add(wrappedBuffer(new byte[1024])); diff --git a/microbench/src/main/java/io/netty/handler/codec/CodecOutputListBenchmark.java b/microbench/src/main/java/io/netty/handler/codec/CodecOutputListBenchmark.java index d7d40307a5..326610b628 100644 --- a/microbench/src/main/java/io/netty/handler/codec/CodecOutputListBenchmark.java +++ b/microbench/src/main/java/io/netty/handler/codec/CodecOutputListBenchmark.java @@ -57,7 +57,7 @@ public class CodecOutputListBenchmark extends AbstractMicrobenchmark { @Benchmark public void arrayList() { - arrayList = new ArrayList(16); + arrayList = new ArrayList<>(16); benchmarkAddAndClear(arrayList, elements); } diff --git a/microbench/src/main/java/io/netty/handler/codec/http/HttpMethodMapBenchmark.java b/microbench/src/main/java/io/netty/handler/codec/http/HttpMethodMapBenchmark.java index 69dae0f4c9..ab2217d293 100644 --- a/microbench/src/main/java/io/netty/handler/codec/http/HttpMethodMapBenchmark.java +++ b/microbench/src/main/java/io/netty/handler/codec/http/HttpMethodMapBenchmark.java @@ -43,7 +43,7 @@ import static io.netty.util.internal.MathUtil.findNextPositivePowerOfTwo; @Measurement(iterations = 8) @OutputTimeUnit(TimeUnit.MICROSECONDS) public class HttpMethodMapBenchmark extends AbstractMicrobenchmark { - private static final Map OLD_MAP = new HashMap(); + private static final Map OLD_MAP = new HashMap<>(); private static final SimpleStringMap NEW_MAP; private static final String[] KNOWN_METHODS; private static final String[] MIXED_METHODS; @@ -98,16 +98,16 @@ public class HttpMethodMapBenchmark extends AbstractMicrobenchmark { OLD_MAP.put(TRACE.toString(), TRACE); OLD_MAP.put(CONNECT.toString(), CONNECT); - NEW_MAP = new SimpleStringMap( - new SimpleStringMap.Node(OPTIONS.toString(), OPTIONS), - new SimpleStringMap.Node(GET.toString(), GET), - new SimpleStringMap.Node(HEAD.toString(), HEAD), - new SimpleStringMap.Node(POST.toString(), POST), - new SimpleStringMap.Node(PUT.toString(), PUT), - new SimpleStringMap.Node(PATCH.toString(), PATCH), - new SimpleStringMap.Node(DELETE.toString(), DELETE), - new SimpleStringMap.Node(TRACE.toString(), TRACE), - new SimpleStringMap.Node(CONNECT.toString(), CONNECT)); + NEW_MAP = new SimpleStringMap<>( + new SimpleStringMap.Node<>(OPTIONS.toString(), OPTIONS), + new SimpleStringMap.Node<>(GET.toString(), GET), + new SimpleStringMap.Node<>(HEAD.toString(), HEAD), + new SimpleStringMap.Node<>(POST.toString(), POST), + new SimpleStringMap.Node<>(PUT.toString(), PUT), + new SimpleStringMap.Node<>(PATCH.toString(), PATCH), + new SimpleStringMap.Node<>(DELETE.toString(), DELETE), + new SimpleStringMap.Node<>(TRACE.toString(), TRACE), + new SimpleStringMap.Node<>(CONNECT.toString(), CONNECT)); } private static final class SimpleStringMap { diff --git a/microbench/src/main/java/io/netty/handler/codec/http2/HpackBenchmarkUtil.java b/microbench/src/main/java/io/netty/handler/codec/http2/HpackBenchmarkUtil.java index c94bc59a8c..d815cb5dd3 100644 --- a/microbench/src/main/java/io/netty/handler/codec/http2/HpackBenchmarkUtil.java +++ b/microbench/src/main/java/io/netty/handler/codec/http2/HpackBenchmarkUtil.java @@ -87,7 +87,7 @@ public final class HpackBenchmarkUtil { static { HpackHeadersSize[] sizes = HpackHeadersSize.values(); - headersMap = new HashMap>(sizes.length * 2); + headersMap = new HashMap<>(sizes.length * 2); for (HpackHeadersSize size : sizes) { HeadersKey key = new HeadersKey(size, true); headersMap.put(key, key.newHeaders()); diff --git a/microbench/src/main/java/io/netty/handler/codec/http2/HpackHeader.java b/microbench/src/main/java/io/netty/handler/codec/http2/HpackHeader.java index c0b63590d4..dede5f9a87 100644 --- a/microbench/src/main/java/io/netty/handler/codec/http2/HpackHeader.java +++ b/microbench/src/main/java/io/netty/handler/codec/http2/HpackHeader.java @@ -57,7 +57,7 @@ class HpackHeader { */ static List createHeaders(int numHeaders, int nameLength, int valueLength, boolean limitToAscii) { - List hpackHeaders = new ArrayList(numHeaders); + List hpackHeaders = new ArrayList<>(numHeaders); for (int i = 0; i < numHeaders; ++i) { byte[] name = randomBytes(new byte[nameLength], limitToAscii); byte[] value = randomBytes(new byte[valueLength], limitToAscii); diff --git a/microbench/src/main/java/io/netty/microbench/concurrent/ScheduledFutureTaskBenchmark.java b/microbench/src/main/java/io/netty/microbench/concurrent/ScheduledFutureTaskBenchmark.java index ecb438fad6..02e9922ee9 100644 --- a/microbench/src/main/java/io/netty/microbench/concurrent/ScheduledFutureTaskBenchmark.java +++ b/microbench/src/main/java/io/netty/microbench/concurrent/ScheduledFutureTaskBenchmark.java @@ -51,7 +51,7 @@ public class ScheduledFutureTaskBenchmark extends AbstractMicrobenchmark { @Param({ "100", "1000", "10000", "100000" }) int num; - final List> futures = new ArrayList>(); + final List> futures = new ArrayList<>(); @Setup(Level.Invocation) public void reset() { diff --git a/microbench/src/main/java/io/netty/microbench/headers/ExampleHeaders.java b/microbench/src/main/java/io/netty/microbench/headers/ExampleHeaders.java index abfd9814bd..617cfa0fe7 100644 --- a/microbench/src/main/java/io/netty/microbench/headers/ExampleHeaders.java +++ b/microbench/src/main/java/io/netty/microbench/headers/ExampleHeaders.java @@ -32,17 +32,17 @@ public final class ExampleHeaders { } public static final Map> EXAMPLES = - new EnumMap>(HeaderExample.class); + new EnumMap<>(HeaderExample.class); static { - Map header = new HashMap(); + Map header = new HashMap<>(); header.put(":method", "GET"); header.put(":scheme", "https"); header.put(":path", "/index.html"); EXAMPLES.put(HeaderExample.THREE, header); // Headers used by Norman's HTTP benchmarks with wrk - header = new HashMap(); + header = new HashMap<>(); header.put("Method", "GET"); header.put("Path", "/plaintext"); header.put("Host", "localhost"); @@ -50,7 +50,7 @@ public final class ExampleHeaders { header.put("Connection", "keep-alive"); EXAMPLES.put(HeaderExample.FIVE, header); - header = new HashMap(); + header = new HashMap<>(); header.put(":authority", "127.0.0.1:33333"); header.put(":method", "POST"); header.put(":path", "/grpc.testing.TestService/UnaryCall"); @@ -59,7 +59,7 @@ public final class ExampleHeaders { header.put("te", "trailers"); EXAMPLES.put(HeaderExample.SIX, header); - header = new HashMap(); + header = new HashMap<>(); header.put(":method", "POST"); header.put(":scheme", "http"); header.put(":path", "/google.pubsub.v2.PublisherService/CreateTopic"); @@ -70,7 +70,7 @@ public final class ExampleHeaders { header.put("authorization", "Bearer y235.wef315yfh138vh31hv93hv8h3v"); EXAMPLES.put(HeaderExample.EIGHT, header); - header = new HashMap(); + header = new HashMap<>(); header.put(":host", "twitter.com"); header.put(":method", "GET"); header.put(":path", "/"); @@ -84,7 +84,7 @@ public final class ExampleHeaders { header.put("user-agent", "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko)"); EXAMPLES.put(HeaderExample.ELEVEN, header); - header = new HashMap(); + header = new HashMap<>(); header.put("cache-control", "no-cache, no-store, must-revalidate, pre-check=0, post-check=0"); header.put("content-encoding", "gzip"); header.put("content-security-policy", "default-src https:; connect-src https:;"); @@ -109,7 +109,7 @@ public final class ExampleHeaders { header.put("x-xss-protection", "1; mode=block"); EXAMPLES.put(HeaderExample.TWENTYTWO, header); - header = new HashMap(); + header = new HashMap<>(); header.put("Cache-Control", "no-cache"); header.put("Content-Encoding", "gzip"); header.put("Content-Security-Policy", "default-src *; script-src assets-cdn.github.com ..."); diff --git a/microbench/src/main/java/io/netty/microbench/redis/RedisEncoderBenchmark.java b/microbench/src/main/java/io/netty/microbench/redis/RedisEncoderBenchmark.java index 69e7ee505c..a4dab42951 100644 --- a/microbench/src/main/java/io/netty/microbench/redis/RedisEncoderBenchmark.java +++ b/microbench/src/main/java/io/netty/microbench/redis/RedisEncoderBenchmark.java @@ -69,7 +69,7 @@ public class RedisEncoderBenchmark extends AbstractMicrobenchmark { content.writeBytes(bytes); ByteBuf testContent = Unpooled.unreleasableBuffer(content.asReadOnly()); - List rList = new ArrayList(arraySize); + List rList = new ArrayList<>(arraySize); for (int i = 0; i < arraySize; ++i) { rList.add(new FullBulkStringRedisMessage(testContent)); } diff --git a/microbench/src/main/java/io/netty/microbench/util/AbstractMicrobenchmark.java b/microbench/src/main/java/io/netty/microbench/util/AbstractMicrobenchmark.java index 64ec3e2303..b5a9f99679 100644 --- a/microbench/src/main/java/io/netty/microbench/util/AbstractMicrobenchmark.java +++ b/microbench/src/main/java/io/netty/microbench/util/AbstractMicrobenchmark.java @@ -40,7 +40,7 @@ public class AbstractMicrobenchmark extends AbstractMicrobenchmarkBase { public HarnessExecutor(int maxThreads, String prefix) { super(maxThreads, maxThreads, 0, TimeUnit.MILLISECONDS, - new LinkedBlockingQueue(), new DefaultThreadFactory(prefix)); + new LinkedBlockingQueue<>(), new DefaultThreadFactory(prefix)); logger.debug("Using harness executor"); } } diff --git a/microbench/src/main/java/io/netty/microbench/util/AbstractMicrobenchmarkBase.java b/microbench/src/main/java/io/netty/microbench/util/AbstractMicrobenchmarkBase.java index a623cc89ea..0cec4cf45c 100644 --- a/microbench/src/main/java/io/netty/microbench/util/AbstractMicrobenchmarkBase.java +++ b/microbench/src/main/java/io/netty/microbench/util/AbstractMicrobenchmarkBase.java @@ -85,7 +85,7 @@ public abstract class AbstractMicrobenchmarkBase { protected abstract String[] jvmArgs(); protected static String[] removeAssertions(String[] jvmArgs) { - List customArgs = new ArrayList(jvmArgs.length); + List customArgs = new ArrayList<>(jvmArgs.length); for (String arg : jvmArgs) { if (!arg.startsWith("-ea")) { customArgs.add(arg); diff --git a/microbench/src/main/java/io/netty/microbench/util/ResourceLeakDetectorBenchmark.java b/microbench/src/main/java/io/netty/microbench/util/ResourceLeakDetectorBenchmark.java index be6414a9e1..503d1a29ed 100644 --- a/microbench/src/main/java/io/netty/microbench/util/ResourceLeakDetectorBenchmark.java +++ b/microbench/src/main/java/io/netty/microbench/util/ResourceLeakDetectorBenchmark.java @@ -26,7 +26,7 @@ public class ResourceLeakDetectorBenchmark extends AbstractMicrobenchmark { @Setup public void setup() { - detector = new ResourceLeakDetector(getClass(), 128, Long.MAX_VALUE); + detector = new ResourceLeakDetector<>(getClass(), 128, Long.MAX_VALUE); } @Benchmark diff --git a/microbench/src/main/java/io/netty/microbenchmark/common/IntObjectHashMapBenchmark.java b/microbench/src/main/java/io/netty/microbenchmark/common/IntObjectHashMapBenchmark.java index 6787f9b791..73b31c17ad 100644 --- a/microbench/src/main/java/io/netty/microbenchmark/common/IntObjectHashMapBenchmark.java +++ b/microbench/src/main/java/io/netty/microbenchmark/common/IntObjectHashMapBenchmark.java @@ -101,7 +101,7 @@ public class IntObjectHashMapBenchmark extends AbstractMicrobenchmark { case RANDOM: { // Create a 'size' # of random integers. Random r = new Random(); - Set keySet = new HashSet(); + Set keySet = new HashSet<>(); while (keySet.size() < size) { keySet.add(r.nextInt()); } @@ -123,7 +123,7 @@ public class IntObjectHashMapBenchmark extends AbstractMicrobenchmark { } private class AgronaEnvironment extends Environment { - private final Int2ObjectHashMap map = new Int2ObjectHashMap(); + private final Int2ObjectHashMap map = new Int2ObjectHashMap<>(); AgronaEnvironment() { for (int key : keys) { @@ -133,7 +133,7 @@ public class IntObjectHashMapBenchmark extends AbstractMicrobenchmark { @Override void put(Blackhole bh) { - Int2ObjectHashMap map = new Int2ObjectHashMap(); + Int2ObjectHashMap map = new Int2ObjectHashMap<>(); for (int key : keys) { bh.consume(map.put(key, VALUE)); } @@ -148,7 +148,7 @@ public class IntObjectHashMapBenchmark extends AbstractMicrobenchmark { @Override void remove(Blackhole bh) { - Int2ObjectHashMap copy = new Int2ObjectHashMap(); + Int2ObjectHashMap copy = new Int2ObjectHashMap<>(); copy.putAll(map); for (int key : keys) { bh.consume(copy.remove(key)); diff --git a/resolver-dns/src/main/java/io/netty/resolver/dns/AuthoritativeDnsServerCacheAdapter.java b/resolver-dns/src/main/java/io/netty/resolver/dns/AuthoritativeDnsServerCacheAdapter.java index 470106e695..38f2c0a45e 100644 --- a/resolver-dns/src/main/java/io/netty/resolver/dns/AuthoritativeDnsServerCacheAdapter.java +++ b/resolver-dns/src/main/java/io/netty/resolver/dns/AuthoritativeDnsServerCacheAdapter.java @@ -50,7 +50,7 @@ final class AuthoritativeDnsServerCacheAdapter implements AuthoritativeDnsServer return null; } - List addresses = new ArrayList(entries.size()); + List addresses = new ArrayList<>(entries.size()); int i = 0; do { diff --git a/resolver-dns/src/main/java/io/netty/resolver/dns/Cache.java b/resolver-dns/src/main/java/io/netty/resolver/dns/Cache.java index cdd590e8fc..fffdec86f6 100644 --- a/resolver-dns/src/main/java/io/netty/resolver/dns/Cache.java +++ b/resolver-dns/src/main/java/io/netty/resolver/dns/Cache.java @@ -189,7 +189,7 @@ abstract class Cache { } // Create a new List for COW semantics - List newEntries = new ArrayList(entries.size() + 1); + List newEntries = new ArrayList<>(entries.size() + 1); int i = 0; E replacedEntry = null; do { diff --git a/resolver-dns/src/main/java/io/netty/resolver/dns/DefaultDnsServerAddressStreamProvider.java b/resolver-dns/src/main/java/io/netty/resolver/dns/DefaultDnsServerAddressStreamProvider.java index 00be072295..db3255b27e 100644 --- a/resolver-dns/src/main/java/io/netty/resolver/dns/DefaultDnsServerAddressStreamProvider.java +++ b/resolver-dns/src/main/java/io/netty/resolver/dns/DefaultDnsServerAddressStreamProvider.java @@ -48,7 +48,7 @@ public final class DefaultDnsServerAddressStreamProvider implements DnsServerAdd static final int DNS_PORT = 53; static { - final List defaultNameServers = new ArrayList(2); + final List defaultNameServers = new ArrayList<>(2); if (!PlatformDependent.isAndroid()) { // Only try to use when not on Android as the classes not exists there: // See https://github.com/netty/netty/issues/8654 diff --git a/resolver-dns/src/main/java/io/netty/resolver/dns/DirContextUtils.java b/resolver-dns/src/main/java/io/netty/resolver/dns/DirContextUtils.java index 45c1ac433f..b456449e8c 100644 --- a/resolver-dns/src/main/java/io/netty/resolver/dns/DirContextUtils.java +++ b/resolver-dns/src/main/java/io/netty/resolver/dns/DirContextUtils.java @@ -41,7 +41,7 @@ final class DirContextUtils { // See: // - http://docs.oracle.com/javase/8/docs/technotes/guides/jndi/jndi-dns.html // - http://mail.openjdk.java.net/pipermail/net-dev/2017-March/010695.html - Hashtable env = new Hashtable(); + Hashtable env = new Hashtable<>(); env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.dns.DnsContextFactory"); env.put("java.naming.provider.url", "dns://"); diff --git a/resolver-dns/src/main/java/io/netty/resolver/dns/DnsAddressResolveContext.java b/resolver-dns/src/main/java/io/netty/resolver/dns/DnsAddressResolveContext.java index 85078c6792..85c0cfec71 100644 --- a/resolver-dns/src/main/java/io/netty/resolver/dns/DnsAddressResolveContext.java +++ b/resolver-dns/src/main/java/io/netty/resolver/dns/DnsAddressResolveContext.java @@ -69,7 +69,7 @@ final class DnsAddressResolveContext extends DnsResolveContext { // If all the results are the preferred type, or none of them are, then we don't need to do any filtering. return unfiltered; } - List filtered = new ArrayList(numExpected); + List filtered = new ArrayList<>(numExpected); for (int i = 0; i < size; i++) { InetAddress address = unfiltered.get(i); if (inetAddressType.isInstance(address)) { diff --git a/resolver-dns/src/main/java/io/netty/resolver/dns/DnsAddressResolverGroup.java b/resolver-dns/src/main/java/io/netty/resolver/dns/DnsAddressResolverGroup.java index 303c42a098..f1171a436e 100644 --- a/resolver-dns/src/main/java/io/netty/resolver/dns/DnsAddressResolverGroup.java +++ b/resolver-dns/src/main/java/io/netty/resolver/dns/DnsAddressResolverGroup.java @@ -89,7 +89,7 @@ public class DnsAddressResolverGroup extends AddressResolverGroup channelFactory, DnsServerAddressStreamProvider nameServerProvider) throws Exception { - final NameResolver resolver = new InflightNameResolver( + final NameResolver resolver = new InflightNameResolver<>( eventLoop, newNameResolver(eventLoop, channelFactory, nameServerProvider), resolvesInProgress, diff --git a/resolver-dns/src/main/java/io/netty/resolver/dns/DnsNameResolver.java b/resolver-dns/src/main/java/io/netty/resolver/dns/DnsNameResolver.java index c8384fffe9..4a53cf7d79 100644 --- a/resolver-dns/src/main/java/io/netty/resolver/dns/DnsNameResolver.java +++ b/resolver-dns/src/main/java/io/netty/resolver/dns/DnsNameResolver.java @@ -776,7 +776,7 @@ public class DnsNameResolver extends InetNameResolver { if (!additionalsIt.hasNext()) { return EMPTY_ADDITIONALS; } - List records = new ArrayList(); + List records = new ArrayList<>(); do { DnsRecord r = additionalsIt.next(); validateAdditional(r, validateType); @@ -946,7 +946,7 @@ public class DnsNameResolver extends InetNameResolver { final DnsCacheEntry e = cachedEntries.get(i); if (f.addressType().isInstance(e.address())) { if (result == null) { - result = new ArrayList(numEntries); + result = new ArrayList<>(numEntries); } result.add(e.address()); } diff --git a/resolver-dns/src/main/java/io/netty/resolver/dns/DnsNameResolverBuilder.java b/resolver-dns/src/main/java/io/netty/resolver/dns/DnsNameResolverBuilder.java index 06266ccfd3..f9f561576f 100644 --- a/resolver-dns/src/main/java/io/netty/resolver/dns/DnsNameResolverBuilder.java +++ b/resolver-dns/src/main/java/io/netty/resolver/dns/DnsNameResolverBuilder.java @@ -345,7 +345,7 @@ public final class DnsNameResolverBuilder { public DnsNameResolverBuilder searchDomains(Iterable searchDomains) { checkNotNull(searchDomains, "searchDomains"); - final List list = new ArrayList(4); + final List list = new ArrayList<>(4); for (String f : searchDomains) { if (f == null) { diff --git a/resolver-dns/src/main/java/io/netty/resolver/dns/DnsResolveContext.java b/resolver-dns/src/main/java/io/netty/resolver/dns/DnsResolveContext.java index 9cf02d8221..c0bff657f9 100644 --- a/resolver-dns/src/main/java/io/netty/resolver/dns/DnsResolveContext.java +++ b/resolver-dns/src/main/java/io/netty/resolver/dns/DnsResolveContext.java @@ -102,7 +102,7 @@ abstract class DnsResolveContext { private final Set>> queriesInProgress = Collections.newSetFromMap( - new IdentityHashMap>, Boolean>()); + new IdentityHashMap<>()); private List finalResult; private int allowedQueries; @@ -587,7 +587,7 @@ abstract class DnsResolveContext { public InetSocketAddress get(int index) { if (addresses == null) { DnsServerAddressStream stream = duplicate.duplicate(); - addresses = new ArrayList(size()); + addresses = new ArrayList<>(size()); for (int i = 0; i < stream.size(); i++) { addresses.add(stream.next()); } @@ -675,7 +675,7 @@ abstract class DnsResolveContext { // Make sure the record is for the questioned domain. if (!recordName.equals(questionName)) { - Map cnamesCopy = new HashMap(cnames); + Map cnamesCopy = new HashMap<>(cnames); // Even if the record's name is not exactly same, it might be an alias defined in the CNAME records. String resolved = questionName; do { @@ -696,7 +696,7 @@ abstract class DnsResolveContext { } if (finalResult == null) { - finalResult = new ArrayList(8); + finalResult = new ArrayList<>(8); } finalResult.add(converted); @@ -767,7 +767,7 @@ abstract class DnsResolveContext { } if (cnames == null) { - cnames = new HashMap(min(8, answerCount)); + cnames = new HashMap<>(min(8, answerCount)); } String name = r.name().toLowerCase(Locale.US); @@ -913,7 +913,7 @@ abstract class DnsResolveContext { } if (cnames == null) { // Detect loops. - cnames = new HashSet(2); + cnames = new HashSet<>(2); } if (!cnames.add(cname)) { // Follow CNAME from cache would loop. Lets break here. @@ -1172,7 +1172,7 @@ abstract class DnsResolveContext { * Creates a new {@link List} which holds the {@link InetSocketAddress}es. */ List addressList() { - List addressList = new ArrayList(nameServerCount); + List addressList = new ArrayList<>(nameServerCount); AuthoritativeNameServer server = head; while (server != null) { diff --git a/resolver-dns/src/main/java/io/netty/resolver/dns/DnsServerAddresses.java b/resolver-dns/src/main/java/io/netty/resolver/dns/DnsServerAddresses.java index 72c0acd1b5..b7cbc1141a 100644 --- a/resolver-dns/src/main/java/io/netty/resolver/dns/DnsServerAddresses.java +++ b/resolver-dns/src/main/java/io/netty/resolver/dns/DnsServerAddresses.java @@ -166,9 +166,9 @@ public abstract class DnsServerAddresses { final List list; if (addresses instanceof Collection) { - list = new ArrayList(((Collection) addresses).size()); + list = new ArrayList<>(((Collection) addresses).size()); } else { - list = new ArrayList(4); + list = new ArrayList<>(4); } for (InetSocketAddress a : addresses) { @@ -193,7 +193,7 @@ public abstract class DnsServerAddresses { throw new NullPointerException("addresses"); } - List list = new ArrayList(addresses.length); + List list = new ArrayList<>(addresses.length); for (InetSocketAddress a: addresses) { if (a == null) { break; diff --git a/resolver-dns/src/main/java/io/netty/resolver/dns/UnixResolverDnsServerAddressStreamProvider.java b/resolver-dns/src/main/java/io/netty/resolver/dns/UnixResolverDnsServerAddressStreamProvider.java index afe29313c4..2e76abf13d 100644 --- a/resolver-dns/src/main/java/io/netty/resolver/dns/UnixResolverDnsServerAddressStreamProvider.java +++ b/resolver-dns/src/main/java/io/netty/resolver/dns/UnixResolverDnsServerAddressStreamProvider.java @@ -152,7 +152,7 @@ public final class UnixResolverDnsServerAddressStreamProvider implements DnsServ private static Map parse(File... etcResolverFiles) throws IOException { Map domainToNameServerStreamMap = - new HashMap(etcResolverFiles.length << 1); + new HashMap<>(etcResolverFiles.length << 1); for (File etcResolverFile : etcResolverFiles) { if (!etcResolverFile.isFile()) { continue; @@ -161,7 +161,7 @@ public final class UnixResolverDnsServerAddressStreamProvider implements DnsServ BufferedReader br = null; try { br = new BufferedReader(fr); - List addresses = new ArrayList(2); + List addresses = new ArrayList<>(2); String domainName = etcResolverFile.getName(); int port = DNS_PORT; String line; @@ -199,7 +199,7 @@ public final class UnixResolverDnsServerAddressStreamProvider implements DnsServ if (!addresses.isEmpty()) { putIfAbsent(domainToNameServerStreamMap, domainName, addresses); } - addresses = new ArrayList(2); + addresses = new ArrayList<>(2); } else if (line.startsWith(PORT_ROW_LABEL)) { int i = indexOfNonWhiteSpace(line, PORT_ROW_LABEL.length()); if (i < 0) { @@ -308,7 +308,7 @@ public final class UnixResolverDnsServerAddressStreamProvider implements DnsServ */ static List parseEtcResolverSearchDomains(File etcResolvConf) throws IOException { String localDomain = null; - List searchDomains = new ArrayList(); + List searchDomains = new ArrayList<>(); FileReader fr = new FileReader(etcResolvConf); BufferedReader br = null; diff --git a/resolver-dns/src/test/java/io/netty/resolver/dns/DnsNameResolverTest.java b/resolver-dns/src/test/java/io/netty/resolver/dns/DnsNameResolverTest.java index 4c2e4c46ba..88da131ec8 100644 --- a/resolver-dns/src/test/java/io/netty/resolver/dns/DnsNameResolverTest.java +++ b/resolver-dns/src/test/java/io/netty/resolver/dns/DnsNameResolverTest.java @@ -113,7 +113,7 @@ public class DnsNameResolverTest { // $ curl -O http://s3.amazonaws.com/alexa-static/top-1m.csv.zip // $ unzip -o top-1m.csv.zip top-1m.csv // $ head -100 top-1m.csv | cut -d, -f2 | cut -d/ -f1 | while read L; do echo '"'"$L"'",'; done > topsites.txt - private static final Set DOMAINS = Collections.unmodifiableSet(new HashSet(Arrays.asList( + private static final Set DOMAINS = Collections.unmodifiableSet(new HashSet<>(Arrays.asList( "google.com", "youtube.com", "facebook.com", @@ -216,7 +216,7 @@ public class DnsNameResolverTest { "pixnet.net", "localhost"))); - private static final Map DOMAINS_PUNYCODE = new HashMap(); + private static final Map DOMAINS_PUNYCODE = new HashMap<>(); static { DOMAINS_PUNYCODE.put("büchner.de", "xn--bchner-3ya.de"); @@ -226,7 +226,7 @@ public class DnsNameResolverTest { private static final Set DOMAINS_ALL; static { - Set all = new HashSet(DOMAINS.size() + DOMAINS_PUNYCODE.size()); + Set all = new HashSet<>(DOMAINS.size() + DOMAINS_PUNYCODE.size()); all.addAll(DOMAINS); all.addAll(DOMAINS_PUNYCODE.values()); DOMAINS_ALL = Collections.unmodifiableSet(all); @@ -235,7 +235,7 @@ public class DnsNameResolverTest { /** * The list of the domain names to exclude from {@link #testResolveAorAAAA()}. */ - private static final Set EXCLUSIONS_RESOLVE_A = new HashSet(); + private static final Set EXCLUSIONS_RESOLVE_A = new HashSet<>(); static { Collections.addAll( @@ -249,7 +249,7 @@ public class DnsNameResolverTest { * The list of the domain names to exclude from {@link #testResolveAAAA()}. * Unfortunately, there are only handful of domain names with IPv6 addresses. */ - private static final Set EXCLUSIONS_RESOLVE_AAAA = new HashSet(); + private static final Set EXCLUSIONS_RESOLVE_AAAA = new HashSet<>(); static { EXCLUSIONS_RESOLVE_AAAA.addAll(EXCLUSIONS_RESOLVE_A); @@ -287,7 +287,7 @@ public class DnsNameResolverTest { /** * The list of the domain names to exclude from {@link #testQueryMx()}. */ - private static final Set EXCLUSIONS_QUERY_MX = new HashSet(); + private static final Set EXCLUSIONS_QUERY_MX = new HashSet<>(); static { Collections.addAll( @@ -393,7 +393,7 @@ public class DnsNameResolverTest { public Set getRecords(QuestionRecord question) { switch (question.getRecordType()) { case A: - Map attr = new HashMap(); + Map attr = new HashMap<>(); attr.put(DnsAttribute.IP_ADDRESS.toLowerCase(Locale.US), overriddenIP); return Collections.singleton( new TestDnsServer.TestResourceRecord( @@ -405,7 +405,7 @@ public class DnsNameResolverTest { }); dnsServer2.start(); try { - final Set overriddenHostnames = new HashSet(); + final Set overriddenHostnames = new HashSet<>(); for (String name : DOMAINS) { if (EXCLUSIONS_RESOLVE_A.contains(name)) { continue; @@ -541,9 +541,9 @@ public class DnsNameResolverTest { assertThat(resolver.isRecursionDesired(), is(true)); - final Map results = new HashMap(); + final Map results = new HashMap<>(); final Map> futures = - new LinkedHashMap>(); + new LinkedHashMap<>(); for (String name : DOMAINS) { if (excludedDomains.contains(name)) { @@ -586,7 +586,7 @@ public class DnsNameResolverTest { assertThat(resolver.isRecursionDesired(), is(true)); Map>> futures = - new LinkedHashMap>>(); + new LinkedHashMap<>(); for (String name : DOMAINS) { if (EXCLUSIONS_QUERY_MX.contains(name)) { continue; @@ -603,7 +603,7 @@ public class DnsNameResolverTest { assertThat(response.code(), is(DnsResponseCode.NOERROR)); final int answerCount = response.count(DnsSection.ANSWER); - final List mxList = new ArrayList(answerCount); + final List mxList = new ArrayList<>(answerCount); for (int i = 0; i < answerCount; i++) { final DnsRecord r = response.recordAt(DnsSection.ANSWER, i); if (r.type() == DnsRecordType.MX) { @@ -646,7 +646,7 @@ public class DnsNameResolverTest { resolveNonExistentDomain(resolver); final int size = 10000; - final List exceptions = new ArrayList(); + final List exceptions = new ArrayList<>(); // If negative cache works, this thread should be done really quickly. final Thread negativeLookupThread = new Thread() { @@ -969,7 +969,7 @@ public class DnsNameResolverTest { try { assertThat(resolver.isRecursionDesired(), is(true)); - final Map>> futures = new LinkedHashMap>>(); + final Map>> futures = new LinkedHashMap<>(); for (String name : DOMAINS) { if (EXCLUSIONS_QUERY_MX.contains(name)) { continue; @@ -1201,7 +1201,7 @@ public class DnsNameResolverTest { // This store is non-compliant, returning records of the wrong type for a query. // It works since we don't verify the type of the result when resolving to deal with // non-compliant servers in the wild. - List> records = new ArrayList>(); + List> records = new ArrayList<>(); final String ipv6Address = "0:0:0:0:0:0:1:1"; final String ipv4Address = "1.1.1.1"; if (types == ResolvedAddressTypes.IPV4_PREFERRED) { @@ -1242,7 +1242,7 @@ public class DnsNameResolverTest { final String hostname = "some.record.netty.io"; final String hostname2 = "some2.record.netty.io"; - final TestDnsServer dnsServerAuthority = new TestDnsServer(new HashSet( + final TestDnsServer dnsServerAuthority = new TestDnsServer(new HashSet<>( Arrays.asList(hostname, hostname2))); dnsServerAuthority.start(); @@ -1393,7 +1393,7 @@ public class DnsNameResolverTest { }); dnsServerAuthority.start(); - TestDnsServer redirectServer = new TestDnsServer(new HashSet( + TestDnsServer redirectServer = new TestDnsServer(new HashSet<>( Arrays.asList(expected.getHostName(), ns1Name, ns2Name))) { @Override protected DnsMessage filterMessage(DnsMessage message) { @@ -1528,7 +1528,7 @@ public class DnsNameResolverTest { InetAddress.getByAddress(ns1Name, new byte[] { 10, 0, 0, 4 }), DefaultDnsServerAddressStreamProvider.DNS_PORT); - TestDnsServer redirectServer = new TestDnsServer(new HashSet(Arrays.asList(hostname, ns1Name))) { + TestDnsServer redirectServer = new TestDnsServer(new HashSet<>(Arrays.asList(hostname, ns1Name))) { @Override protected DnsMessage filterMessage(DnsMessage message) { for (QuestionRecord record: message.getQuestionRecords()) { @@ -1553,7 +1553,7 @@ public class DnsNameResolverTest { redirectServer.start(); EventLoopGroup group = new NioEventLoopGroup(1); - final List cached = new CopyOnWriteArrayList(); + final List cached = new CopyOnWriteArrayList<>(); final AuthoritativeDnsServerCache authoritativeDnsServerCache = new AuthoritativeDnsServerCache() { @Override public DnsServerAddressStream get(String hostname) { @@ -1576,7 +1576,7 @@ public class DnsNameResolverTest { } }; - final AtomicReference redirectedRef = new AtomicReference(); + final AtomicReference redirectedRef = new AtomicReference<>(); final DnsNameResolver resolver = new DnsNameResolver( group.next(), new ReflectiveChannelFactory(NioDatagramChannel.class), NoopDnsCache.INSTANCE, authoritativeDnsServerCache, @@ -1656,7 +1656,7 @@ public class DnsNameResolverTest { final InetSocketAddress ns5Address = new InetSocketAddress( InetAddress.getByAddress(ns2Name, new byte[] { 10, 0, 0, 5 }), DefaultDnsServerAddressStreamProvider.DNS_PORT); - TestDnsServer redirectServer = new TestDnsServer(new HashSet(Arrays.asList(hostname, ns1Name))) { + TestDnsServer redirectServer = new TestDnsServer(new HashSet<>(Arrays.asList(hostname, ns1Name))) { @Override protected DnsMessage filterMessage(DnsMessage message) { for (QuestionRecord record: message.getQuestionRecords()) { @@ -1683,7 +1683,7 @@ public class DnsNameResolverTest { redirectServer.start(); EventLoopGroup group = new NioEventLoopGroup(1); - final List cached = new CopyOnWriteArrayList(); + final List cached = new CopyOnWriteArrayList<>(); final AuthoritativeDnsServerCache authoritativeDnsServerCache = new AuthoritativeDnsServerCache() { @Override public DnsServerAddressStream get(String hostname) { @@ -1713,7 +1713,7 @@ public class DnsNameResolverTest { cache.cache(ns1Name, null, ns3Address.getAddress(), 10000, loop); cache.cache(ns1Name, null, ns4Address.getAddress(), 10000, loop); - final AtomicReference redirectedRef = new AtomicReference(); + final AtomicReference redirectedRef = new AtomicReference<>(); final DnsNameResolver resolver = new DnsNameResolver( loop, new ReflectiveChannelFactory(NioDatagramChannel.class), cache, authoritativeDnsServerCache, @@ -1803,7 +1803,7 @@ public class DnsNameResolverTest { private static final class TestRecursiveCacheDnsQueryLifecycleObserverFactory implements DnsQueryLifecycleObserverFactory { final Queue observers = - new ConcurrentLinkedQueue(); + new ConcurrentLinkedQueue<>(); @Override public DnsQueryLifecycleObserver newDnsQueryLifecycleObserver(DnsQuestion question) { TestDnsQueryLifecycleObserver observer = new TestDnsQueryLifecycleObserver(question); @@ -1864,7 +1864,7 @@ public class DnsNameResolverTest { } private static final class TestDnsQueryLifecycleObserver implements DnsQueryLifecycleObserver { - final Queue events = new ArrayDeque(); + final Queue events = new ArrayDeque<>(); final DnsQuestion question; TestDnsQueryLifecycleObserver(DnsQuestion question) { @@ -1912,7 +1912,7 @@ public class DnsNameResolverTest { private static final class TestAuthoritativeDnsServerCache implements AuthoritativeDnsServerCache { final AuthoritativeDnsServerCache cache; - final Map cacheHits = new HashMap(); + final Map cacheHits = new HashMap<>(); TestAuthoritativeDnsServerCache(AuthoritativeDnsServerCache cache) { this.cache = cache; @@ -1946,7 +1946,7 @@ public class DnsNameResolverTest { private static final class TestDnsCache implements DnsCache { final DnsCache cache; final Map> cacheHits = - new HashMap>(); + new HashMap<>(); TestDnsCache(DnsCache cache) { this.cache = cache; @@ -2068,14 +2068,14 @@ public class DnsNameResolverTest { @Test public void testDnsNameResolverBuilderCopy() { ChannelFactory channelFactory = - new ReflectiveChannelFactory(NioDatagramChannel.class); + new ReflectiveChannelFactory<>(NioDatagramChannel.class); DnsNameResolverBuilder builder = new DnsNameResolverBuilder(group.next()) .channelFactory(channelFactory); DnsNameResolverBuilder copiedBuilder = builder.copy(); // change channel factory does not propagate to previously made copy ChannelFactory newChannelFactory = - new ReflectiveChannelFactory(NioDatagramChannel.class); + new ReflectiveChannelFactory<>(NioDatagramChannel.class); builder.channelFactory(newChannelFactory); assertEquals(channelFactory, copiedBuilder.channelFactory()); assertEquals(newChannelFactory, builder.channelFactory()); @@ -2088,18 +2088,18 @@ public class DnsNameResolverTest { @Override public Set getRecords(QuestionRecord question) { if (question.getDomainName().equals("cname.netty.io")) { - Map map1 = new HashMap(); + Map map1 = new HashMap<>(); map1.put(DnsAttribute.IP_ADDRESS.toLowerCase(), "10.0.0.99"); return Collections.singleton( new TestDnsServer.TestResourceRecord(question.getDomainName(), RecordType.A, map1)); } else { - Set records = new LinkedHashSet(2); - Map map = new HashMap(); + Set records = new LinkedHashSet<>(2); + Map map = new HashMap<>(); map.put(DnsAttribute.DOMAIN_NAME.toLowerCase(), "cname.netty.io"); records.add(new TestDnsServer.TestResourceRecord( question.getDomainName(), RecordType.CNAME, map)); - Map map1 = new HashMap(); + Map map1 = new HashMap<>(); map1.put(DnsAttribute.IP_ADDRESS.toLowerCase(), "10.0.0.2"); records.add(new TestDnsServer.TestResourceRecord( question.getDomainName(), RecordType.A, map1)); @@ -2137,7 +2137,7 @@ public class DnsNameResolverTest { @Override public Set getRecords(QuestionRecord question) { - Set records = new LinkedHashSet(4); + Set records = new LinkedHashSet<>(4); records.add(new TestDnsServer.TestResourceRecord("x." + question.getDomainName(), RecordType.A, Collections.singletonMap( @@ -2332,7 +2332,7 @@ public class DnsNameResolverTest { @Test public void testCNameCached() throws Exception { - final Map cache = new ConcurrentHashMap(); + final Map cache = new ConcurrentHashMap<>(); final AtomicInteger cnameQueries = new AtomicInteger(); final AtomicInteger aQueries = new AtomicInteger(); diff --git a/resolver-dns/src/test/java/io/netty/resolver/dns/DnsServerAddressesTest.java b/resolver-dns/src/test/java/io/netty/resolver/dns/DnsServerAddressesTest.java index cf437fe82e..94a6e87dff 100644 --- a/resolver-dns/src/test/java/io/netty/resolver/dns/DnsServerAddressesTest.java +++ b/resolver-dns/src/test/java/io/netty/resolver/dns/DnsServerAddressesTest.java @@ -98,7 +98,7 @@ public class DnsServerAddressesTest { // Ensure that all three addresses are returned by the iterator. // In theory, this test can fail at extremely low chance, but we don't really care. - Set set = Collections.newSetFromMap(new IdentityHashMap()); + Set set = Collections.newSetFromMap(new IdentityHashMap<>()); DnsServerAddressStream i = seq.stream(); for (int j = 0; j < 1048576; j ++) { set.add(i.next()); diff --git a/resolver-dns/src/test/java/io/netty/resolver/dns/NameServerComparatorTest.java b/resolver-dns/src/test/java/io/netty/resolver/dns/NameServerComparatorTest.java index e29932a18b..62d5a8708a 100644 --- a/resolver-dns/src/test/java/io/netty/resolver/dns/NameServerComparatorTest.java +++ b/resolver-dns/src/test/java/io/netty/resolver/dns/NameServerComparatorTest.java @@ -101,7 +101,7 @@ public class NameServerComparatorTest { @Test public void testSortAlreadySortedPreferred() { List expected = Arrays.asList(IPV4ADDRESS1, IPV4ADDRESS2, IPV4ADDRESS3); - List addresses = new ArrayList(expected); + List addresses = new ArrayList<>(expected); NameServerComparator comparator = new NameServerComparator(Inet4Address.class); Collections.sort(addresses, comparator); @@ -112,7 +112,7 @@ public class NameServerComparatorTest { @Test public void testSortAlreadySortedNotPreferred() { List expected = Arrays.asList(IPV4ADDRESS1, IPV4ADDRESS2, IPV4ADDRESS3); - List addresses = new ArrayList(expected); + List addresses = new ArrayList<>(expected); NameServerComparator comparator = new NameServerComparator(Inet6Address.class); Collections.sort(addresses, comparator); @@ -123,7 +123,7 @@ public class NameServerComparatorTest { @Test public void testSortAlreadySortedUnresolved() { List expected = Arrays.asList(UNRESOLVED1, UNRESOLVED2, UNRESOLVED3); - List addresses = new ArrayList(expected); + List addresses = new ArrayList<>(expected); NameServerComparator comparator = new NameServerComparator(Inet6Address.class); Collections.sort(addresses, comparator); @@ -136,7 +136,7 @@ public class NameServerComparatorTest { List expected = Arrays.asList( IPV4ADDRESS1, IPV4ADDRESS2, IPV6ADDRESS1, IPV6ADDRESS2, UNRESOLVED1, UNRESOLVED2); - List addresses = new ArrayList(expected); + List addresses = new ArrayList<>(expected); NameServerComparator comparator = new NameServerComparator(Inet4Address.class); Collections.sort(addresses, comparator); @@ -148,7 +148,7 @@ public class NameServerComparatorTest { public void testSort1() { List expected = Arrays.asList( IPV4ADDRESS1, IPV4ADDRESS2, IPV6ADDRESS1, IPV6ADDRESS2, UNRESOLVED1, UNRESOLVED2); - List addresses = new ArrayList( + List addresses = new ArrayList<>( Arrays.asList(IPV6ADDRESS1, IPV4ADDRESS1, IPV6ADDRESS2, UNRESOLVED1, UNRESOLVED2, IPV4ADDRESS2)); NameServerComparator comparator = new NameServerComparator(Inet4Address.class); @@ -161,7 +161,7 @@ public class NameServerComparatorTest { public void testSort2() { List expected = Arrays.asList( IPV4ADDRESS1, IPV4ADDRESS2, IPV6ADDRESS1, IPV6ADDRESS2, UNRESOLVED1, UNRESOLVED2); - List addresses = new ArrayList( + List addresses = new ArrayList<>( Arrays.asList(IPV4ADDRESS1, IPV6ADDRESS1, IPV6ADDRESS2, UNRESOLVED1, IPV4ADDRESS2, UNRESOLVED2)); NameServerComparator comparator = new NameServerComparator(Inet4Address.class); diff --git a/resolver-dns/src/test/java/io/netty/resolver/dns/SearchDomainTest.java b/resolver-dns/src/test/java/io/netty/resolver/dns/SearchDomainTest.java index 3888778ced..f161f44ac6 100644 --- a/resolver-dns/src/test/java/io/netty/resolver/dns/SearchDomainTest.java +++ b/resolver-dns/src/test/java/io/netty/resolver/dns/SearchDomainTest.java @@ -75,7 +75,7 @@ public class SearchDomainTest { @Test public void testResolve() throws Exception { - Set domains = new HashSet(); + Set domains = new HashSet<>(); domains.add("host1.foo.com"); domains.add("host1"); domains.add("host3"); @@ -125,7 +125,7 @@ public class SearchDomainTest { @Test public void testResolveAll() throws Exception { - Set domains = new HashSet(); + Set domains = new HashSet<>(); domains.add("host1.foo.com"); domains.add("host1"); domains.add("host3"); @@ -175,7 +175,7 @@ public class SearchDomainTest { @Test public void testMultipleSearchDomain() throws Exception { - Set domains = new HashSet(); + Set domains = new HashSet<>(); domains.add("host1.foo.com"); domains.add("host2.bar.com"); domains.add("host3.bar.com"); @@ -205,7 +205,7 @@ public class SearchDomainTest { @Test public void testSearchDomainWithNdots2() throws Exception { - Set domains = new HashSet(); + Set domains = new HashSet<>(); domains.add("host1.sub.foo.com"); domains.add("host2.sub.foo.com"); domains.add("host2.sub"); @@ -226,7 +226,7 @@ public class SearchDomainTest { @Test public void testSearchDomainWithNdots0() throws Exception { - Set domains = new HashSet(); + Set domains = new HashSet<>(); domains.add("host1"); domains.add("host1.foo.com"); domains.add("host2.foo.com"); @@ -272,7 +272,7 @@ public class SearchDomainTest { String inetHost) throws InterruptedException { Future> fut = resolver.resolveAll(inetHost); assertTrue(fut.await(10, TimeUnit.SECONDS)); - List list = new ArrayList(); + List list = new ArrayList<>(); for (InetAddress addr : fut.getNow()) { list.add(addr.getHostAddress()); } diff --git a/resolver-dns/src/test/java/io/netty/resolver/dns/TestDnsServer.java b/resolver-dns/src/test/java/io/netty/resolver/dns/TestDnsServer.java index 229ea98a88..1d86bdc283 100644 --- a/resolver-dns/src/test/java/io/netty/resolver/dns/TestDnsServer.java +++ b/resolver-dns/src/test/java/io/netty/resolver/dns/TestDnsServer.java @@ -55,7 +55,7 @@ import java.util.Map; import java.util.Set; class TestDnsServer extends DnsServer { - private static final Map BYTES = new HashMap(); + private static final Map BYTES = new HashMap<>(); private static final String[] IPV6_ADDRESSES; static { @@ -197,9 +197,9 @@ class TestDnsServer extends DnsServer { private final Map> domainMap; MapRecordStoreA(Set domains, int length) { - domainMap = new HashMap>(domains.size()); + domainMap = new HashMap<>(domains.size()); for (String domain : domains) { - List addresses = new ArrayList(length); + List addresses = new ArrayList<>(length); for (int i = 0; i < length; i++) { addresses.add(TestRecordStore.nextIp()); } @@ -224,9 +224,9 @@ class TestDnsServer extends DnsServer { String name = questionRecord.getDomainName(); List addresses = domainMap.get(name); if (addresses != null && questionRecord.getRecordType() == RecordType.A) { - Set records = new LinkedHashSet(); + Set records = new LinkedHashSet<>(); for (String address : addresses) { - Map attributes = new HashMap(); + Map attributes = new HashMap<>(); attributes.put(DnsAttribute.IP_ADDRESS.toLowerCase(), address); records.add(new TestResourceRecord(name, questionRecord.getRecordType(), attributes)); } @@ -280,7 +280,7 @@ class TestDnsServer extends DnsServer { public Set getRecords(QuestionRecord questionRecord) { String name = questionRecord.getDomainName(); if (domains.contains(name)) { - Map attr = new HashMap(); + Map attr = new HashMap<>(); switch (questionRecord.getRecordType()) { case A: do { diff --git a/resolver/src/main/java/io/netty/resolver/AddressResolverGroup.java b/resolver/src/main/java/io/netty/resolver/AddressResolverGroup.java index e9bb9dfd64..2c898baf72 100644 --- a/resolver/src/main/java/io/netty/resolver/AddressResolverGroup.java +++ b/resolver/src/main/java/io/netty/resolver/AddressResolverGroup.java @@ -40,8 +40,7 @@ public abstract class AddressResolverGroup implements C /** * Note that we do not use a {@link ConcurrentMap} here because it is usually expensive to instantiate a resolver. */ - private final Map> resolvers = - new IdentityHashMap>(); + private final Map> resolvers = new IdentityHashMap<>(); protected AddressResolverGroup() { } diff --git a/resolver/src/main/java/io/netty/resolver/HostsFileEntries.java b/resolver/src/main/java/io/netty/resolver/HostsFileEntries.java index 03f555c5e4..1275cd8422 100644 --- a/resolver/src/main/java/io/netty/resolver/HostsFileEntries.java +++ b/resolver/src/main/java/io/netty/resolver/HostsFileEntries.java @@ -32,17 +32,14 @@ public final class HostsFileEntries { /** * Empty entries */ - static final HostsFileEntries EMPTY = - new HostsFileEntries( - Collections.emptyMap(), - Collections.emptyMap()); + static final HostsFileEntries EMPTY = new HostsFileEntries(Collections.emptyMap(), Collections.emptyMap()); private final Map inet4Entries; private final Map inet6Entries; public HostsFileEntries(Map inet4Entries, Map inet6Entries) { - this.inet4Entries = Collections.unmodifiableMap(new HashMap(inet4Entries)); - this.inet6Entries = Collections.unmodifiableMap(new HashMap(inet6Entries)); + this.inet4Entries = Collections.unmodifiableMap(new HashMap<>(inet4Entries)); + this.inet6Entries = Collections.unmodifiableMap(new HashMap<>(inet6Entries)); } /** diff --git a/resolver/src/main/java/io/netty/resolver/HostsFileParser.java b/resolver/src/main/java/io/netty/resolver/HostsFileParser.java index 16eaba6167..b4650589af 100644 --- a/resolver/src/main/java/io/netty/resolver/HostsFileParser.java +++ b/resolver/src/main/java/io/netty/resolver/HostsFileParser.java @@ -150,8 +150,8 @@ public final class HostsFileParser { checkNotNull(reader, "reader"); BufferedReader buff = new BufferedReader(reader); try { - Map ipv4Entries = new HashMap(); - Map ipv6Entries = new HashMap(); + Map ipv4Entries = new HashMap<>(); + Map ipv6Entries = new HashMap<>(); String line; while ((line = buff.readLine()) != null) { // remove comment @@ -166,7 +166,7 @@ public final class HostsFileParser { } // split - List lineParts = new ArrayList(); + List lineParts = new ArrayList<>(); for (String s: WHITESPACES.split(line)) { if (!s.isEmpty()) { lineParts.add(s); diff --git a/resolver/src/main/java/io/netty/resolver/InetSocketAddressResolver.java b/resolver/src/main/java/io/netty/resolver/InetSocketAddressResolver.java index c7db25d10d..f6aff6093e 100644 --- a/resolver/src/main/java/io/netty/resolver/InetSocketAddressResolver.java +++ b/resolver/src/main/java/io/netty/resolver/InetSocketAddressResolver.java @@ -79,7 +79,7 @@ public class InetSocketAddressResolver extends AbstractAddressResolver inetAddresses = future.getNow(); List socketAddresses = - new ArrayList(inetAddresses.size()); + new ArrayList<>(inetAddresses.size()); for (InetAddress inetAddress : inetAddresses) { socketAddresses.add(new InetSocketAddress(inetAddress, unresolvedAddress.getPort())); } diff --git a/resolver/src/main/java/io/netty/resolver/RoundRobinInetAddressResolver.java b/resolver/src/main/java/io/netty/resolver/RoundRobinInetAddressResolver.java index f505328a39..41799239c8 100644 --- a/resolver/src/main/java/io/netty/resolver/RoundRobinInetAddressResolver.java +++ b/resolver/src/main/java/io/netty/resolver/RoundRobinInetAddressResolver.java @@ -83,7 +83,7 @@ public class RoundRobinInetAddressResolver extends InetNameResolver { List inetAddresses = future.getNow(); if (!inetAddresses.isEmpty()) { // create a copy to make sure that it's modifiable random access collection - List result = new ArrayList(inetAddresses); + List result = new ArrayList<>(inetAddresses); // rotate by different distance each time to force round robin distribution Collections.rotate(result, randomIndex(inetAddresses.size())); promise.setSuccess(result); diff --git a/resolver/src/test/java/io/netty/resolver/DefaultHostsFileEntriesResolverTest.java b/resolver/src/test/java/io/netty/resolver/DefaultHostsFileEntriesResolverTest.java index d4d4c99188..88d3d49710 100644 --- a/resolver/src/test/java/io/netty/resolver/DefaultHostsFileEntriesResolverTest.java +++ b/resolver/src/test/java/io/netty/resolver/DefaultHostsFileEntriesResolverTest.java @@ -40,8 +40,8 @@ public class DefaultHostsFileEntriesResolverTest { @Test public void shouldntFindWhenAddressTypeDoesntMatch() { - Map inet4Entries = new HashMap(); - Map inet6Entries = new HashMap(); + Map inet4Entries = new HashMap<>(); + Map inet6Entries = new HashMap<>(); inet4Entries.put("localhost", NetUtil.LOCALHOST4); @@ -54,8 +54,8 @@ public class DefaultHostsFileEntriesResolverTest { @Test public void shouldPickIpv4WhenBothAreDefinedButIpv4IsPreferred() { - Map inet4Entries = new HashMap(); - Map inet6Entries = new HashMap(); + Map inet4Entries = new HashMap<>(); + Map inet6Entries = new HashMap<>(); inet4Entries.put("localhost", NetUtil.LOCALHOST4); inet6Entries.put("localhost", NetUtil.LOCALHOST6); @@ -69,8 +69,8 @@ public class DefaultHostsFileEntriesResolverTest { @Test public void shouldPickIpv6WhenBothAreDefinedButIpv6IsPreferred() { - Map inet4Entries = new HashMap(); - Map inet6Entries = new HashMap(); + Map inet4Entries = new HashMap<>(); + Map inet6Entries = new HashMap<>(); inet4Entries.put("localhost", NetUtil.LOCALHOST4); inet6Entries.put("localhost", NetUtil.LOCALHOST6); diff --git a/testsuite-osgi/src/test/java/io/netty/osgitests/OsgiBundleTest.java b/testsuite-osgi/src/test/java/io/netty/osgitests/OsgiBundleTest.java index 891e2a6087..60034bddcc 100644 --- a/testsuite-osgi/src/test/java/io/netty/osgitests/OsgiBundleTest.java +++ b/testsuite-osgi/src/test/java/io/netty/osgitests/OsgiBundleTest.java @@ -49,7 +49,7 @@ public class OsgiBundleTest { private static final Collection BUNDLES; static { - final Set artifacts = new HashSet(); + final Set artifacts = new HashSet<>(); final File f = new File("target/classes/META-INF/maven/dependencies.properties"); try { final BufferedReader r = new BufferedReader(new FileReader(f)); @@ -86,7 +86,7 @@ public class OsgiBundleTest { @Configuration public final Option[] config() { - final Collection