From ef203fa6cbba691abc8d0db3f8c95912e8599996 Mon Sep 17 00:00:00 2001 From: Chris Vest Date: Fri, 6 Aug 2021 09:14:04 +0200 Subject: [PATCH] Fix a number of javadoc issues (#11544) Motivation: Let's have fewer warnings about broken, missing, or abuse of javadoc comments. Modification: Added descriptions to throws clauses that were missing them. Remove link clauses from throws clauses - these are implied. Turned some javadoc comments into block comments because they were not applied to APIs. Use code clauses instead of code tags. Result: Fewer javadoc crimes. --- .../handler/codec/http/HttpObjectDecoder.java | 16 ++-- .../codec/http/multipart/HttpData.java | 32 +++---- .../HttpPostMultipartRequestDecoder.java | 8 +- .../WebSocketClientHandshaker00.java | 2 +- .../WebSocketClientHandshaker07.java | 2 +- .../WebSocketClientHandshaker08.java | 2 +- .../codec/http/HttpClientCodecTest.java | 8 +- .../DefaultHttp2LocalFlowController.java | 3 +- .../handler/codec/http2/Http2FrameCodec.java | 4 +- .../handler/codec/http2/HpackEncoderTest.java | 1 - .../codec/http2/Http2FrameCodecTest.java | 8 +- .../binary/AbstractBinaryMemcacheDecoder.java | 1 - .../netty/handler/codec/mqtt/MqttDecoder.java | 3 +- ...tobufVarint32LengthFieldPrependerTest.java | 60 ++++++------- .../java/io/netty/util/concurrent/Future.java | 5 +- .../util/internal/logging/CommonsLogger.java | 46 +++++----- .../internal/logging/FormattingTuple.java | 46 +++++----- .../util/internal/logging/InternalLogger.java | 46 +++++----- .../util/internal/logging/JdkLogger.java | 46 +++++----- .../util/internal/logging/Log4JLogger.java | 46 +++++----- .../internal/logging/MessageFormatter.java | 46 +++++----- .../logging/MessageFormatterTest.java | 44 +++++----- .../handler/ssl/SslMasterKeyHandler.java | 6 +- .../resolver/dns/DnsNameResolverTest.java | 85 +++++++++---------- .../kqueue/KQueueRecvByteAllocatorHandle.java | 18 ++-- .../main/java/io/netty/channel/unix/Unix.java | 2 +- 26 files changed, 287 insertions(+), 299 deletions(-) diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/HttpObjectDecoder.java b/codec-http/src/main/java/io/netty/handler/codec/http/HttpObjectDecoder.java index ca4a69f72a..a1b9401f93 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/HttpObjectDecoder.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/HttpObjectDecoder.java @@ -258,11 +258,11 @@ public abstract class HttpObjectDecoder extends ByteToMessageDecoder { ctx.fireChannelRead(message); return; default: - /** - * RFC 7230, 3.3.3 states that if a - * request does not have either a transfer-encoding or a content-length header then the message body - * length is 0. However for a response the body length is the number of octets received prior to the - * server closing the connection. So we treat this as variable length chunked encoding. + /* + RFC 7230, 3.3.3 (https://tools.ietf.org/html/rfc7230#section-3.3.3) states that if a + request does not have either a transfer-encoding or a content-length header then the message body + length is 0. However for a response the body length is the number of octets received prior to the + server closing the connection. So we treat this as variable length chunked encoding. */ long contentLength = contentLength(); if (contentLength == 0 || contentLength == -1 && isDecodingRequest()) { @@ -327,9 +327,9 @@ public abstract class HttpObjectDecoder extends ByteToMessageDecoder { } return; } - /** - * everything else after this point takes care of reading chunked content. basically, read chunk size, - * read chunk, read and ignore the CRLF and repeat until 0 + /* + everything else after this point takes care of reading chunked content. basically, read chunk size, + read chunk, read and ignore the CRLF and repeat until 0 */ case READ_CHUNK_SIZE: try { AppendableCharSequence line = lineParser.parse(buffer); diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/multipart/HttpData.java b/codec-http/src/main/java/io/netty/handler/codec/http/multipart/HttpData.java index 266e566523..b51981de99 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/multipart/HttpData.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/multipart/HttpData.java @@ -50,9 +50,8 @@ public interface HttpData extends InterfaceHttpData, ByteBufHolder { /** * Set the content from the ChannelBuffer (erase any previous data) * - * @param buffer - * must be not null - * @throws IOException + * @param buffer Must be not null. + * @throws IOException If an IO error occurs when setting the content of this HttpData. */ void setContent(ByteBuf buffer) throws IOException; @@ -63,25 +62,23 @@ public interface HttpData extends InterfaceHttpData, ByteBufHolder { * must be not null except if last is set to False * @param last * True of the buffer is the last one - * @throws IOException + * @throws IOException If an IO error occurs while adding content to this HttpData. */ void addContent(ByteBuf buffer, boolean last) throws IOException; /** * Set the content from the file (erase any previous data) * - * @param file - * must be not null - * @throws IOException + * @param file Must be not null. + * @throws IOException If an IO error occurs when setting the content of this HttpData. */ void setContent(File file) throws IOException; /** * Set the content from the inputStream (erase any previous data) * - * @param inputStream - * must be not null - * @throws IOException + * @param inputStream Must be not null. + * @throws IOException If an IO error occurs when setting the content of this HttpData. */ void setContent(InputStream inputStream) throws IOException; @@ -125,7 +122,7 @@ public interface HttpData extends InterfaceHttpData, ByteBufHolder { * Note: this method will allocate a lot of memory, if the data is currently stored on the file system. * * @return the contents of the file item as an array of bytes. - * @throws IOException + * @throws IOException If an IO error occurs while reading the data contents of this HttpData. */ byte[] get() throws IOException; @@ -134,7 +131,7 @@ public interface HttpData extends InterfaceHttpData, ByteBufHolder { * Note: this method will allocate a lot of memory, if the data is currently stored on the file system. * * @return the content of the file item as a ByteBuf - * @throws IOException + * @throws IOException If an IO error occurs while reading the data contents of this HttpData. */ ByteBuf getByteBuf() throws IOException; @@ -155,7 +152,7 @@ public interface HttpData extends InterfaceHttpData, ByteBufHolder { * * @return the contents of the file item as a String, using the default * character encoding. - * @throws IOException + * @throws IOException If an IO error occurs while reading the data contents of this HttpData. */ String getString() throws IOException; @@ -167,7 +164,7 @@ public interface HttpData extends InterfaceHttpData, ByteBufHolder { * the charset to use * @return the contents of the file item as a String, using the specified * charset. - * @throws IOException + * @throws IOException If an IO error occurs while reading the data contents of this HttpData. */ String getString(Charset encoding) throws IOException; @@ -192,10 +189,9 @@ public interface HttpData extends InterfaceHttpData, ByteBufHolder { * the new file will be out of the cleaner of the factory that creates the * original InterfaceHttpData object. * - * @param dest - * destination file - must be not null - * @return True if the write is successful - * @throws IOException + * @param dest Destination file - must be not null. + * @return {@code true} if the write is successful. + * @throws IOException If an IO error occurs while renaming the underlying file of this HttpData. */ boolean renameTo(File dest) throws IOException; 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 019f388264..767a60d125 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 @@ -594,8 +594,6 @@ public class HttpPostMultipartRequestDecoder implements InterfaceHttpPostRequest /** * Skip control Characters - * - * @throws NotEnoughDataDecoderException */ private static void skipControlCharacters(ByteBuf undecodedChunk) { if (!undecodedChunk.hasArray()) { @@ -637,7 +635,7 @@ public class HttpPostMultipartRequestDecoder implements InterfaceHttpPostRequest * @param closeDelimiterStatus * the next getStatus if the delimiter is a close delimiter * @return the next InterfaceHttpData if any - * @throws ErrorDataDecoderException + * @throws ErrorDataDecoderException If no multipart delimiter is found, or an error occurs during decoding. */ private InterfaceHttpData findMultipartDelimiter(String delimiter, MultiPartStatus dispositionStatus, MultiPartStatus closeDelimiterStatus) { @@ -680,7 +678,6 @@ public class HttpPostMultipartRequestDecoder implements InterfaceHttpPostRequest * Find the next Disposition * * @return the next InterfaceHttpData if any - * @throws ErrorDataDecoderException */ private InterfaceHttpData findMultipartDisposition() { int readerIndex = undecodedChunk.readerIndex(); @@ -839,7 +836,7 @@ public class HttpPostMultipartRequestDecoder implements InterfaceHttpPostRequest * @param delimiter * the delimiter to use * @return the InterfaceHttpData if any - * @throws ErrorDataDecoderException + * @throws ErrorDataDecoderException If an error occurs when decoding the multipart data. */ protected InterfaceHttpData getFileUpload(String delimiter) { // eventually restart from existing FileUpload @@ -1146,7 +1143,6 @@ public class HttpPostMultipartRequestDecoder implements InterfaceHttpPostRequest * Load the field value or file data from a Multipart request * * @return {@code true} if the last chunk is loaded (boundary delimiter found), {@code false} if need more chunks - * @throws ErrorDataDecoderException */ private static boolean loadDataMultipartOptimized(ByteBuf undecodedChunk, String delimiter, HttpData httpData) { if (!undecodedChunk.isReadable()) { diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketClientHandshaker00.java b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketClientHandshaker00.java index 2dad64925f..71860369bc 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketClientHandshaker00.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketClientHandshaker00.java @@ -223,7 +223,7 @@ public class WebSocketClientHandshaker00 extends WebSocketClientHandshaker { * * @param response * HTTP response returned from the server for the request sent by beginOpeningHandshake00(). - * @throws WebSocketHandshakeException + * @throws WebSocketHandshakeException If the handshake or challenge is invalid. */ @Override protected void verify(FullHttpResponse response) { diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketClientHandshaker07.java b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketClientHandshaker07.java index 924978a256..6b7587ebf4 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketClientHandshaker07.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketClientHandshaker07.java @@ -260,7 +260,7 @@ public class WebSocketClientHandshaker07 extends WebSocketClientHandshaker { * * @param response * HTTP response returned from the server for the request sent by beginOpeningHandshake00(). - * @throws WebSocketHandshakeException + * @throws WebSocketHandshakeException If the handshake or challenge is invalid. */ @Override protected void verify(FullHttpResponse response) { diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketClientHandshaker08.java b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketClientHandshaker08.java index f24e7c469a..50dd4599fc 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketClientHandshaker08.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketClientHandshaker08.java @@ -262,7 +262,7 @@ public class WebSocketClientHandshaker08 extends WebSocketClientHandshaker { * * @param response * HTTP response returned from the server for the request sent by beginOpeningHandshake00(). - * @throws WebSocketHandshakeException + * @throws WebSocketHandshakeException If the handshake or challenge is invalid. */ @Override protected void verify(FullHttpResponse response) { diff --git a/codec-http/src/test/java/io/netty/handler/codec/http/HttpClientCodecTest.java b/codec-http/src/test/java/io/netty/handler/codec/http/HttpClientCodecTest.java index cd164d715a..5e6562abd0 100644 --- a/codec-http/src/test/java/io/netty/handler/codec/http/HttpClientCodecTest.java +++ b/codec-http/src/test/java/io/netty/handler/codec/http/HttpClientCodecTest.java @@ -148,10 +148,10 @@ public class HttpClientCodecTest { // This is just a simple demo...don't block in IO assertTrue(ctx.channel() instanceof SocketChannel); final SocketChannel sChannel = (SocketChannel) ctx.channel(); - /** - * The point of this test is to not add any content-length or content-encoding headers - * and the client should still handle this. - * See RFC 7230, 3.3.3. + /* + The point of this test is to not add any content-length or content-encoding headers + and the client should still handle this. + See RFC 7230, 3.3.3: https://tools.ietf.org/html/rfc7230#section-3.3.3. */ sChannel.writeAndFlush(Unpooled.wrappedBuffer(("HTTP/1.0 200 OK\r\n" + "Date: Fri, 31 Dec 1999 23:59:59 GMT\r\n" + diff --git a/codec-http2/src/main/java/io/netty/handler/codec/http2/DefaultHttp2LocalFlowController.java b/codec-http2/src/main/java/io/netty/handler/codec/http2/DefaultHttp2LocalFlowController.java index 43a8dbe930..58c736ac90 100644 --- a/codec-http2/src/main/java/io/netty/handler/codec/http2/DefaultHttp2LocalFlowController.java +++ b/codec-http2/src/main/java/io/netty/handler/codec/http2/DefaultHttp2LocalFlowController.java @@ -586,7 +586,8 @@ public class DefaultHttp2LocalFlowController implements Http2LocalFlowController * * @param numBytes the number of bytes to be returned to the flow control window. * @return true if {@code WINDOW_UPDATE} was written, false otherwise. - * @throws Http2Exception + * @throws Http2Exception If the number of bytes is too great for the current window, + * or an internal error occurs. */ boolean consumeBytes(int numBytes) throws Http2Exception; diff --git a/codec-http2/src/main/java/io/netty/handler/codec/http2/Http2FrameCodec.java b/codec-http2/src/main/java/io/netty/handler/codec/http2/Http2FrameCodec.java index 23a51125b9..1479a93bd0 100644 --- a/codec-http2/src/main/java/io/netty/handler/codec/http2/Http2FrameCodec.java +++ b/codec-http2/src/main/java/io/netty/handler/codec/http2/Http2FrameCodec.java @@ -89,7 +89,7 @@ import static io.netty.handler.codec.http2.Http2Error.NO_ERROR; * {@link Http2ChannelDuplexHandler#newStream()}, and then writing a {@link Http2HeadersFrame} object with the stream * attached. * - *
+ * 
{@code
  *     final Http2Stream2 stream = handler.newStream();
  *     ctx.write(headersFrame.stream(stream)).addListener(new ChannelFutureListener() {
  *
@@ -110,7 +110,7 @@ import static io.netty.handler.codec.http2.Http2Error.NO_ERROR;
  *             }
  *         }
  *     }
- * 
+ * }
* *

If a new stream cannot be created due to stream id exhaustion of the endpoint, the {@link ChannelPromise} of the * HEADERS frame will fail with a {@link Http2NoMoreStreamIdsException}. diff --git a/codec-http2/src/test/java/io/netty/handler/codec/http2/HpackEncoderTest.java b/codec-http2/src/test/java/io/netty/handler/codec/http2/HpackEncoderTest.java index b18ea075f4..39baf6f44d 100644 --- a/codec-http2/src/test/java/io/netty/handler/codec/http2/HpackEncoderTest.java +++ b/codec-http2/src/test/java/io/netty/handler/codec/http2/HpackEncoderTest.java @@ -67,7 +67,6 @@ public class HpackEncoderTest { /** * The encoder should not impose an arbitrary limit on the header size if * the server has not specified any limit. - * @throws Http2Exception */ @Test public void testWillEncode16MBHeaderByDefault() throws Http2Exception { 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 5efc4f490d..1b4860ea07 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 @@ -121,10 +121,10 @@ public class Http2FrameCodecTest { } private void setUp(Http2FrameCodecBuilder frameCodecBuilder, Http2Settings initialRemoteSettings) throws Exception { - /** - * Some tests call this method twice. Once with JUnit's @Before and once directly to pass special settings. - * This call ensures that in case of two consecutive calls to setUp(), the previous channel is shutdown and - * ByteBufs are released correctly. + /* + Some tests call this method twice. Once with JUnit's @Before and once directly to pass special settings. + This call ensures that in case of two consecutive calls to setUp(), the previous channel is shutdown and + ByteBufs are released correctly. */ tearDown(); diff --git a/codec-memcache/src/main/java/io/netty/handler/codec/memcache/binary/AbstractBinaryMemcacheDecoder.java b/codec-memcache/src/main/java/io/netty/handler/codec/memcache/binary/AbstractBinaryMemcacheDecoder.java index d021d83a13..1cd4962055 100644 --- a/codec-memcache/src/main/java/io/netty/handler/codec/memcache/binary/AbstractBinaryMemcacheDecoder.java +++ b/codec-memcache/src/main/java/io/netty/handler/codec/memcache/binary/AbstractBinaryMemcacheDecoder.java @@ -194,7 +194,6 @@ public abstract class AbstractBinaryMemcacheDecoder { * Decodes the fixed header. It's one byte for the flags and then variable * bytes for the remaining length. * - * @see + * See * https://docs.oasis-open.org/mqtt/mqtt/v3.1.1/errata01/os/mqtt-v3.1.1-errata01-os-complete.html#_Toc442180841 + * for more information. * * @param buffer the buffer to decode from * @return the fixed header diff --git a/codec/src/test/java/io/netty/handler/codec/protobuf/ProtobufVarint32LengthFieldPrependerTest.java b/codec/src/test/java/io/netty/handler/codec/protobuf/ProtobufVarint32LengthFieldPrependerTest.java index 46fea14929..4097e4dfc5 100644 --- a/codec/src/test/java/io/netty/handler/codec/protobuf/ProtobufVarint32LengthFieldPrependerTest.java +++ b/codec/src/test/java/io/netty/handler/codec/protobuf/ProtobufVarint32LengthFieldPrependerTest.java @@ -64,16 +64,16 @@ public class ProtobufVarint32LengthFieldPrependerTest { final int num = 266; assertThat(ProtobufVarint32LengthFieldPrepender.computeRawVarint32Size(num), is(size)); final byte[] buf = new byte[size + num]; - /** - * 8 A 0 2 - * 1000 1010 0000 0010 - * 0000 1010 0000 0010 - * 0000 0010 0000 1010 - * 000 0010 000 1010 - * - * 0000 0001 0000 1010 - * 0 1 0 A - * 266 + /* + 8 A 0 2 + 1000 1010 0000 0010 + 0000 1010 0000 0010 + 0000 0010 0000 1010 + 000 0010 000 1010 + + 0000 0001 0000 1010 + 0 1 0 A + 266 */ buf[0] = (byte) (0x8A & 0xFF); @@ -99,16 +99,16 @@ public class ProtobufVarint32LengthFieldPrependerTest { final int num = 0x4000; assertThat(ProtobufVarint32LengthFieldPrepender.computeRawVarint32Size(num), is(size)); final byte[] buf = new byte[size + num]; - /** - * 8 0 8 0 0 1 - * 1000 0000 1000 0000 0000 0001 - * 0000 0000 0000 0000 0000 0001 - * 0000 0001 0000 0000 0000 0000 - * 000 0001 000 0000 000 0000 - * - * 0 0000 0100 0000 0000 0000 - * 0 0 4 0 0 0 - * + /* + 8 0 8 0 0 1 + 1000 0000 1000 0000 0000 0001 + 0000 0000 0000 0000 0000 0001 + 0000 0001 0000 0000 0000 0000 + 000 0001 000 0000 000 0000 + + 0 0000 0100 0000 0000 0000 + 0 0 4 0 0 0 + */ buf[0] = (byte) (0x80 & 0xFF); @@ -135,16 +135,16 @@ public class ProtobufVarint32LengthFieldPrependerTest { final int num = 0x200000; assertThat(ProtobufVarint32LengthFieldPrepender.computeRawVarint32Size(num), is(size)); final byte[] buf = new byte[size + num]; - /** - * 8 0 8 0 8 0 0 1 - * 1000 0000 1000 0000 1000 0000 0000 0001 - * 0000 0000 0000 0000 0000 0000 0000 0001 - * 0000 0001 0000 0000 0000 0000 0000 0000 - * 000 0001 000 0000 000 0000 000 0000 - * - * 0000 0010 0000 0000 0000 0000 0000 - * 0 2 0 0 0 0 0 - * + /* + 8 0 8 0 8 0 0 1 + 1000 0000 1000 0000 1000 0000 0000 0001 + 0000 0000 0000 0000 0000 0000 0000 0001 + 0000 0001 0000 0000 0000 0000 0000 0000 + 000 0001 000 0000 000 0000 000 0000 + + 0000 0010 0000 0000 0000 0000 0000 + 0 2 0 0 0 0 0 + */ buf[0] = (byte) (0x80 & 0xFF); diff --git a/common/src/main/java/io/netty/util/concurrent/Future.java b/common/src/main/java/io/netty/util/concurrent/Future.java index ef05aa8a64..d25e955492 100644 --- a/common/src/main/java/io/netty/util/concurrent/Future.java +++ b/common/src/main/java/io/netty/util/concurrent/Future.java @@ -16,6 +16,7 @@ package io.netty.util.concurrent; import java.util.concurrent.CancellationException; +import java.util.concurrent.CompletionException; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; @@ -60,7 +61,7 @@ public interface Future extends java.util.concurrent.Future { * failed. * * @throws CancellationException if the computation was cancelled - * @throws {@link java.util.concurrent.CompletionException} if the computation threw an exception. + * @throws CompletionException if the computation threw an exception. * @throws InterruptedException if the current thread was interrupted while waiting * */ @@ -71,7 +72,7 @@ public interface Future extends java.util.concurrent.Future { * failed. * * @throws CancellationException if the computation was cancelled - * @throws {@link java.util.concurrent.CompletionException} if the computation threw an exception. + * @throws CompletionException if the computation threw an exception. */ Future syncUninterruptibly(); diff --git a/common/src/main/java/io/netty/util/internal/logging/CommonsLogger.java b/common/src/main/java/io/netty/util/internal/logging/CommonsLogger.java index b5266c98f0..9407e81179 100644 --- a/common/src/main/java/io/netty/util/internal/logging/CommonsLogger.java +++ b/common/src/main/java/io/netty/util/internal/logging/CommonsLogger.java @@ -13,29 +13,29 @@ * License for the specific language governing permissions and limitations * under the License. */ -/** - * Copyright (c) 2004-2011 QOS.ch - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * +/* + Copyright (c) 2004-2011 QOS.ch + All rights reserved. + + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + + The above copyright notice and this permission notice shall be + included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ package io.netty.util.internal.logging; diff --git a/common/src/main/java/io/netty/util/internal/logging/FormattingTuple.java b/common/src/main/java/io/netty/util/internal/logging/FormattingTuple.java index 59862691c8..bcbdb24787 100644 --- a/common/src/main/java/io/netty/util/internal/logging/FormattingTuple.java +++ b/common/src/main/java/io/netty/util/internal/logging/FormattingTuple.java @@ -13,29 +13,29 @@ * License for the specific language governing permissions and limitations * under the License. */ -/** - * Copyright (c) 2004-2011 QOS.ch - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * +/* + Copyright (c) 2004-2011 QOS.ch + All rights reserved. + + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + + The above copyright notice and this permission notice shall be + included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ package io.netty.util.internal.logging; diff --git a/common/src/main/java/io/netty/util/internal/logging/InternalLogger.java b/common/src/main/java/io/netty/util/internal/logging/InternalLogger.java index 704bd3ada7..f05dfd649e 100644 --- a/common/src/main/java/io/netty/util/internal/logging/InternalLogger.java +++ b/common/src/main/java/io/netty/util/internal/logging/InternalLogger.java @@ -13,29 +13,29 @@ * License for the specific language governing permissions and limitations * under the License. */ -/** - * Copyright (c) 2004-2011 QOS.ch - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * +/* + Copyright (c) 2004-2011 QOS.ch + All rights reserved. + + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + + The above copyright notice and this permission notice shall be + included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ package io.netty.util.internal.logging; diff --git a/common/src/main/java/io/netty/util/internal/logging/JdkLogger.java b/common/src/main/java/io/netty/util/internal/logging/JdkLogger.java index 9cddce298d..791c007edf 100644 --- a/common/src/main/java/io/netty/util/internal/logging/JdkLogger.java +++ b/common/src/main/java/io/netty/util/internal/logging/JdkLogger.java @@ -13,29 +13,29 @@ * License for the specific language governing permissions and limitations * under the License. */ -/** - * Copyright (c) 2004-2011 QOS.ch - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * +/* + Copyright (c) 2004-2011 QOS.ch + All rights reserved. + + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + + The above copyright notice and this permission notice shall be + included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ package io.netty.util.internal.logging; diff --git a/common/src/main/java/io/netty/util/internal/logging/Log4JLogger.java b/common/src/main/java/io/netty/util/internal/logging/Log4JLogger.java index 8865c1057a..20e0ff3874 100644 --- a/common/src/main/java/io/netty/util/internal/logging/Log4JLogger.java +++ b/common/src/main/java/io/netty/util/internal/logging/Log4JLogger.java @@ -13,29 +13,29 @@ * License for the specific language governing permissions and limitations * under the License. */ -/** - * Copyright (c) 2004-2011 QOS.ch - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * +/* + Copyright (c) 2004-2011 QOS.ch + All rights reserved. + + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + + The above copyright notice and this permission notice shall be + included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ package io.netty.util.internal.logging; 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 c2b43dac84..a1746a6a87 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 @@ -13,29 +13,29 @@ * License for the specific language governing permissions and limitations * under the License. */ -/** - * Copyright (c) 2004-2011 QOS.ch - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * +/* + Copyright (c) 2004-2011 QOS.ch + All rights reserved. + + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + + The above copyright notice and this permission notice shall be + included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ package io.netty.util.internal.logging; diff --git a/common/src/test/java/io/netty/util/internal/logging/MessageFormatterTest.java b/common/src/test/java/io/netty/util/internal/logging/MessageFormatterTest.java index 60a44fcf39..d23131844a 100644 --- a/common/src/test/java/io/netty/util/internal/logging/MessageFormatterTest.java +++ b/common/src/test/java/io/netty/util/internal/logging/MessageFormatterTest.java @@ -13,28 +13,28 @@ * License for the specific language governing permissions and limitations * under the License. */ -/** - * Copyright (c) 2004-2011 QOS.ch - * All rights reserved. - *

- * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - *

- * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - *

- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +/* + Copyright (c) 2004-2011 QOS.ch + All rights reserved. +

+ Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: +

+ The above copyright notice and this permission notice shall be + included in all copies or substantial portions of the Software. +

+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ package io.netty.util.internal.logging; diff --git a/handler/src/main/java/io/netty/handler/ssl/SslMasterKeyHandler.java b/handler/src/main/java/io/netty/handler/ssl/SslMasterKeyHandler.java index 345c121518..01bdd78924 100644 --- a/handler/src/main/java/io/netty/handler/ssl/SslMasterKeyHandler.java +++ b/handler/src/main/java/io/netty/handler/ssl/SslMasterKeyHandler.java @@ -52,7 +52,7 @@ public abstract class SslMasterKeyHandler implements ChannelHandler { /** * A system property that can be used to turn on/off the {@link SslMasterKeyHandler} dynamically without having * to edit your pipeline. - * -Dio.netty.ssl.masterKeyHandler=true + * {@code -Dio.netty.ssl.masterKeyHandler=true} */ public static final String SYSTEM_PROP_KEY = "io.netty.ssl.masterKeyHandler"; @@ -171,8 +171,8 @@ public abstract class SslMasterKeyHandler implements ChannelHandler { } /** - * Record the session identifier and master key to the {@link InternalLogger} named io.netty.wireshark. - * ex. RSA Session-ID:XXX Master-Key:YYY + * Record the session identifier and master key to the {@link InternalLogger} named {@code io.netty.wireshark}. + * ex. {@code RSA Session-ID:XXX Master-Key:YYY} * This format is understood by Wireshark 1.6.0. * https://code.wireshark.org/review/gitweb?p=wireshark.git;a=commit;h=686d4cabb41185591c361f9ec6b709034317144b * The key and session identifier are forwarded to the log named 'io.netty.wireshark'. 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 2e1236695b..eccf606f11 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 @@ -43,6 +43,7 @@ import io.netty.handler.codec.dns.DnsSection; import io.netty.resolver.HostsFileEntriesProvider; import io.netty.resolver.HostsFileEntriesResolver; import io.netty.resolver.ResolvedAddressTypes; +import io.netty.resolver.dns.TestDnsServer.TestResourceRecord; import io.netty.util.CharsetUtil; import io.netty.util.NetUtil; import io.netty.util.ReferenceCountUtil; @@ -66,10 +67,11 @@ import org.apache.directory.server.dns.messages.ResponseCode; import org.apache.directory.server.dns.store.DnsAttribute; import org.apache.directory.server.dns.store.RecordStore; import org.apache.mina.core.buffer.IoBuffer; -import org.hamcrest.Matchers; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Timeout; +import org.junit.jupiter.api.function.Executable; import java.io.IOException; import java.io.InputStream; @@ -96,8 +98,8 @@ import java.util.Map; import java.util.Map.Entry; import java.util.Queue; import java.util.Set; -import java.util.concurrent.CompletionException; import java.util.concurrent.CancellationException; +import java.util.concurrent.CompletionException; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.CopyOnWriteArrayList; @@ -107,8 +109,6 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicReference; -import org.junit.jupiter.api.Timeout; -import org.junit.jupiter.api.function.Executable; import static io.netty.handler.codec.dns.DnsRecordType.A; import static io.netty.handler.codec.dns.DnsRecordType.AAAA; @@ -459,19 +459,17 @@ public class DnsNameResolverTest { * simultaneously. */ @Test - public void testNameServerCache() throws IOException, InterruptedException { + public void testNameServerCache() throws Exception { final String overriddenIP = "12.34.12.34"; final TestDnsServer dnsServer2 = new TestDnsServer(question -> { - switch (question.getRecordType()) { - case A: - Map attr = new HashMap<>(); - attr.put(DnsAttribute.IP_ADDRESS.toLowerCase(Locale.US), overriddenIP); - return Collections.singleton( - new TestDnsServer.TestResourceRecord( - question.getDomainName(), question.getRecordType(), attr)); - default: - return null; + if (question.getRecordType() == RecordType.A) { + Map attr = new HashMap<>(); + attr.put(DnsAttribute.IP_ADDRESS.toLowerCase(Locale.US), overriddenIP); + return Collections.singleton( + new TestResourceRecord( + question.getDomainName(), question.getRecordType(), attr)); } + return null; }); dnsServer2.start(); try { @@ -1148,8 +1146,8 @@ public class DnsNameResolverTest { final List records = resolver.resolveAll(new DefaultDnsQuestion("foo.com.", A)) .syncUninterruptibly().getNow(); - assertThat(records, Matchers.hasSize(1)); - assertThat(records.get(0), Matchers.instanceOf(DnsRawRecord.class)); + assertThat(records, hasSize(1)); + assertThat(records.get(0), instanceOf(DnsRawRecord.class)); final DnsRawRecord record = (DnsRawRecord) records.get(0); final ByteBuf content = record.content(); @@ -1953,7 +1951,7 @@ public class DnsNameResolverTest { try { final List addresses = resolver.resolveAll(unresolved).sync().get(); - assertThat(addresses, Matchers.hasSize(greaterThan(0))); + assertThat(addresses, hasSize(greaterThan(0))); for (InetAddress address : addresses) { assertThat(address.getHostName(), startsWith(unresolved)); assertThat(address.getHostAddress(), startsWith(ipAddrPrefix)); @@ -1964,13 +1962,14 @@ public class DnsNameResolverTest { } } - private void testNsLoopFailsResolve(AuthoritativeDnsServerCache authoritativeDnsServerCache) throws Exception { + private static void testNsLoopFailsResolve(AuthoritativeDnsServerCache authoritativeDnsServerCache) + throws Exception { final String domain = "netty.io"; final String ns1Name = "ns1." + domain; final String ns2Name = "ns2." + domain; TestDnsServer testDnsServer = new TestDnsServer(new HashSet( - Collections.singletonList(domain))) { + singletonList(domain))) { @Override protected DnsMessage filterMessage(DnsMessage message) { @@ -1997,9 +1996,9 @@ public class DnsNameResolverTest { try { assertThat(resolver.resolve(domain).await().cause(), - Matchers.instanceOf(UnknownHostException.class)); + instanceOf(UnknownHostException.class)); assertThat(resolver.resolveAll(domain).await().cause(), - Matchers.instanceOf(UnknownHostException.class)); + instanceOf(UnknownHostException.class)); } finally { resolver.close(); testDnsServer.stop(); @@ -2455,7 +2454,7 @@ public class DnsNameResolverTest { () -> testSearchDomainQueryFailureCompletes(ResolvedAddressTypes.IPV4_PREFERRED)); } - private void testSearchDomainQueryFailureCompletes(ResolvedAddressTypes types) throws Throwable { + private static void testSearchDomainQueryFailureCompletes(ResolvedAddressTypes types) throws Throwable { DnsNameResolver resolver = newResolver() .resolvedAddressTypes(types) .ndots(1) @@ -2562,7 +2561,7 @@ public class DnsNameResolverTest { TestDnsServer server = new TestDnsServer(Collections.singleton("test.netty.io")); server.start(); DnsNameResolver resolver = newResolver(ResolvedAddressTypes.IPV4_ONLY) - .searchDomains(Collections.singletonList("netty.io")) + .searchDomains(singletonList("netty.io")) .nameServerProvider(new SingletonDnsServerAddressStreamProvider(server.localAddress())) .resolveCache(cache).build(); try { @@ -2807,16 +2806,12 @@ public class DnsNameResolverTest { if (qName.equals(name)) { records.add(new TestDnsServer.TestResourceRecord( qName, RecordType.CNAME, - Collections.singletonMap( + Collections.singletonMap( DnsAttribute.DOMAIN_NAME.toLowerCase(), "cname.netty.io"))); - records.add(new TestDnsServer.TestResourceRecord(qName, - RecordType.A, Collections.singletonMap( - DnsAttribute.IP_ADDRESS.toLowerCase(), ipv4Addr))); - } else { - records.add(new TestDnsServer.TestResourceRecord(qName, - RecordType.A, Collections.singletonMap( - DnsAttribute.IP_ADDRESS.toLowerCase(), ipv4Addr))); } + records.add(new TestDnsServer.TestResourceRecord(qName, + RecordType.A, Collections.singletonMap( + DnsAttribute.IP_ADDRESS.toLowerCase(), ipv4Addr))); return records; }); dnsServer2.start(); @@ -2830,8 +2825,8 @@ public class DnsNameResolverTest { resolver = builder.build(); List resolvedAddresses = resolver.resolveAll(name).syncUninterruptibly().getNow(); - assertEquals(Collections.singletonList(InetAddress.getByAddress(name, new byte[] { 1, 2, 3, 4 })), - resolvedAddresses); + assertEquals(singletonList(InetAddress.getByAddress(name, new byte[] { 1, 2, 3, 4 })), + resolvedAddresses); } finally { dnsServer2.stop(); if (resolver != null) { @@ -2848,10 +2843,10 @@ public class DnsNameResolverTest { Set records = new LinkedHashSet(2); String qName = question.getDomainName().toLowerCase(); records.add(new TestDnsServer.TestResourceRecord(qName, - RecordType.A, Collections.singletonMap( + RecordType.A, Collections.singletonMap( DnsAttribute.IP_ADDRESS.toLowerCase(), ipv4Addr))); records.add(new TestDnsServer.TestResourceRecord(qName, - RecordType.A, Collections.singletonMap( + RecordType.A, Collections.singletonMap( DnsAttribute.IP_ADDRESS.toLowerCase(), ipv4Addr))); return records; }); @@ -2940,11 +2935,11 @@ public class DnsNameResolverTest { if (name.equals(host)) { Set records = new HashSet(2); records.add(new TestDnsServer.TestResourceRecord(name, RecordType.A, - Collections.singletonMap(DnsAttribute.IP_ADDRESS.toLowerCase(), - "10.0.0.1"))); + Collections.singletonMap(DnsAttribute.IP_ADDRESS.toLowerCase(), + "10.0.0.1"))); records.add(new TestDnsServer.TestResourceRecord(name, RecordType.A, - Collections.singletonMap(DnsAttribute.IP_ADDRESS.toLowerCase(), - "10.0.0.2"))); + Collections.singletonMap(DnsAttribute.IP_ADDRESS.toLowerCase(), + "10.0.0.2"))); return records; } return null; @@ -3020,9 +3015,9 @@ public class DnsNameResolverTest { TestDnsServer dnsServer2 = new TestDnsServer(question -> { String name = question.getDomainName(); if (name.equals(host)) { - return Collections.singleton( + return Collections.singleton( new TestDnsServer.TestResourceRecord(name, RecordType.TXT, - Collections.singletonMap( + Collections.singletonMap( DnsAttribute.CHARACTER_STRING.toLowerCase(), txt))); } return null; @@ -3080,8 +3075,8 @@ public class DnsNameResolverTest { Socket socket = serverSocket.accept(); InputStream in = socket.getInputStream(); - assertTrue((in.read() << 8 | (in.read() & 0xff)) > 2); // skip length field - int txnId = in.read() << 8 | (in.read() & 0xff); + assertTrue((in.read() << 8 | in.read() & 0xff) > 2); // skip length field + int txnId = in.read() << 8 | in.read() & 0xff; IoBuffer ioBuffer = IoBuffer.allocate(1024); // Must replace the transactionId with the one from the TCP request @@ -3141,7 +3136,7 @@ public class DnsNameResolverTest { public void testCancelPromise() throws Exception { final EventLoop eventLoop = group.next(); final Promise promise = eventLoop.newPromise(); - final TestDnsServer dnsServer1 = new TestDnsServer(Collections.emptySet()) { + final TestDnsServer dnsServer1 = new TestDnsServer(Collections.emptySet()) { @Override protected DnsMessage filterMessage(DnsMessage message) { promise.cancel(true); @@ -3150,7 +3145,7 @@ public class DnsNameResolverTest { }; dnsServer1.start(); final AtomicBoolean isQuerySentToSecondServer = new AtomicBoolean(); - final TestDnsServer dnsServer2 = new TestDnsServer(Collections.emptySet()) { + final TestDnsServer dnsServer2 = new TestDnsServer(Collections.emptySet()) { @Override protected DnsMessage filterMessage(DnsMessage message) { isQuerySentToSecondServer.set(true); diff --git a/transport-native-kqueue/src/main/java/io/netty/channel/kqueue/KQueueRecvByteAllocatorHandle.java b/transport-native-kqueue/src/main/java/io/netty/channel/kqueue/KQueueRecvByteAllocatorHandle.java index 7243c9780f..155391e8ca 100644 --- a/transport-native-kqueue/src/main/java/io/netty/channel/kqueue/KQueueRecvByteAllocatorHandle.java +++ b/transport-native-kqueue/src/main/java/io/netty/channel/kqueue/KQueueRecvByteAllocatorHandle.java @@ -88,15 +88,15 @@ final class KQueueRecvByteAllocatorHandle extends DelegatingHandle implements Ex } boolean maybeMoreDataToRead() { - /** - * kqueue with EV_CLEAR flag set requires that we read until we consume "data" bytes - * (see kqueue man). However in order to - * respect auto read we supporting reading to stop if auto read is off. If auto read is on we force reading to - * continue to avoid a {@link StackOverflowError} between channelReadComplete and reading from the - * channel. It is expected that the {@link #KQueueSocketChannel} implementations will track if all data was not - * read, and will force a EVFILT_READ ready event. - * - * It is assumed EOF is handled externally by checking {@link #isReadEOF()}. + /* + kqueue with EV_CLEAR flag set requires that we read until we consume "data" bytes + (see kqueue man: https://www.freebsd.org/cgi/man.cgi?kqueue). However, in order to + respect auto read we support reading to stop if auto read is off. If auto read is on we force reading to + continue to avoid a {@link StackOverflowError} between channelReadComplete and reading from the + channel. It is expected that the {@link #KQueueSocketChannel} implementations will track if all data was not + read, and will force a EVFILT_READ ready event. + + It is assumed EOF is handled externally by checking {@link #isReadEOF()}. */ return numberBytesPending != 0; } diff --git a/transport-native-unix-common/src/main/java/io/netty/channel/unix/Unix.java b/transport-native-unix-common/src/main/java/io/netty/channel/unix/Unix.java index c020997bab..e75e6cb0b6 100644 --- a/transport-native-unix-common/src/main/java/io/netty/channel/unix/Unix.java +++ b/transport-native-unix-common/src/main/java/io/netty/channel/unix/Unix.java @@ -50,7 +50,7 @@ public final class Unix { /** * Internal method... Should never be called from the user. * - * @param registerTask + * @param registerTask The task to run if this thread caused registration. */ @UnstableApi public static void registerInternal(Runnable registerTask) {