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.
This commit is contained in:
Chris Vest 2021-08-06 09:14:04 +02:00 committed by GitHub
parent 6c2813bdb0
commit ef203fa6cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
26 changed files with 287 additions and 299 deletions

View File

@ -258,11 +258,11 @@ public abstract class HttpObjectDecoder extends ByteToMessageDecoder {
ctx.fireChannelRead(message); ctx.fireChannelRead(message);
return; return;
default: default:
/** /*
* <a href="https://tools.ietf.org/html/rfc7230#section-3.3.3">RFC 7230, 3.3.3</a> states that if a 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 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 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. server closing the connection. So we treat this as variable length chunked encoding.
*/ */
long contentLength = contentLength(); long contentLength = contentLength();
if (contentLength == 0 || contentLength == -1 && isDecodingRequest()) { if (contentLength == 0 || contentLength == -1 && isDecodingRequest()) {
@ -327,9 +327,9 @@ public abstract class HttpObjectDecoder extends ByteToMessageDecoder {
} }
return; return;
} }
/** /*
* everything else after this point takes care of reading chunked content. basically, read chunk size, 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 read chunk, read and ignore the CRLF and repeat until 0
*/ */
case READ_CHUNK_SIZE: try { case READ_CHUNK_SIZE: try {
AppendableCharSequence line = lineParser.parse(buffer); AppendableCharSequence line = lineParser.parse(buffer);

View File

@ -50,9 +50,8 @@ public interface HttpData extends InterfaceHttpData, ByteBufHolder {
/** /**
* Set the content from the ChannelBuffer (erase any previous data) * Set the content from the ChannelBuffer (erase any previous data)
* *
* @param buffer * @param buffer Must be not null.
* must be not null * @throws IOException If an IO error occurs when setting the content of this HttpData.
* @throws IOException
*/ */
void setContent(ByteBuf buffer) throws IOException; 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 * must be not null except if last is set to False
* @param last * @param last
* True of the buffer is the last one * 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; void addContent(ByteBuf buffer, boolean last) throws IOException;
/** /**
* Set the content from the file (erase any previous data) * Set the content from the file (erase any previous data)
* *
* @param file * @param file Must be not null.
* must be not null * @throws IOException If an IO error occurs when setting the content of this HttpData.
* @throws IOException
*/ */
void setContent(File file) throws IOException; void setContent(File file) throws IOException;
/** /**
* Set the content from the inputStream (erase any previous data) * Set the content from the inputStream (erase any previous data)
* *
* @param inputStream * @param inputStream Must be not null.
* must be not null * @throws IOException If an IO error occurs when setting the content of this HttpData.
* @throws IOException
*/ */
void setContent(InputStream inputStream) throws IOException; 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. * 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. * @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; 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. * 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 * @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; 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 * @return the contents of the file item as a String, using the default
* character encoding. * character encoding.
* @throws IOException * @throws IOException If an IO error occurs while reading the data contents of this HttpData.
*/ */
String getString() throws IOException; String getString() throws IOException;
@ -167,7 +164,7 @@ public interface HttpData extends InterfaceHttpData, ByteBufHolder {
* the charset to use * the charset to use
* @return the contents of the file item as a String, using the specified * @return the contents of the file item as a String, using the specified
* charset. * charset.
* @throws IOException * @throws IOException If an IO error occurs while reading the data contents of this HttpData.
*/ */
String getString(Charset encoding) throws IOException; 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 * the new file will be out of the cleaner of the factory that creates the
* original InterfaceHttpData object. * original InterfaceHttpData object.
* *
* @param dest * @param dest Destination file - must be not null.
* destination file - must be not null * @return {@code true} if the write is successful.
* @return True if the write is successful * @throws IOException If an IO error occurs while renaming the underlying file of this HttpData.
* @throws IOException
*/ */
boolean renameTo(File dest) throws IOException; boolean renameTo(File dest) throws IOException;

View File

@ -594,8 +594,6 @@ public class HttpPostMultipartRequestDecoder implements InterfaceHttpPostRequest
/** /**
* Skip control Characters * Skip control Characters
*
* @throws NotEnoughDataDecoderException
*/ */
private static void skipControlCharacters(ByteBuf undecodedChunk) { private static void skipControlCharacters(ByteBuf undecodedChunk) {
if (!undecodedChunk.hasArray()) { if (!undecodedChunk.hasArray()) {
@ -637,7 +635,7 @@ public class HttpPostMultipartRequestDecoder implements InterfaceHttpPostRequest
* @param closeDelimiterStatus * @param closeDelimiterStatus
* the next getStatus if the delimiter is a close delimiter * the next getStatus if the delimiter is a close delimiter
* @return the next InterfaceHttpData if any * @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, private InterfaceHttpData findMultipartDelimiter(String delimiter, MultiPartStatus dispositionStatus,
MultiPartStatus closeDelimiterStatus) { MultiPartStatus closeDelimiterStatus) {
@ -680,7 +678,6 @@ public class HttpPostMultipartRequestDecoder implements InterfaceHttpPostRequest
* Find the next Disposition * Find the next Disposition
* *
* @return the next InterfaceHttpData if any * @return the next InterfaceHttpData if any
* @throws ErrorDataDecoderException
*/ */
private InterfaceHttpData findMultipartDisposition() { private InterfaceHttpData findMultipartDisposition() {
int readerIndex = undecodedChunk.readerIndex(); int readerIndex = undecodedChunk.readerIndex();
@ -839,7 +836,7 @@ public class HttpPostMultipartRequestDecoder implements InterfaceHttpPostRequest
* @param delimiter * @param delimiter
* the delimiter to use * the delimiter to use
* @return the InterfaceHttpData if any * @return the InterfaceHttpData if any
* @throws ErrorDataDecoderException * @throws ErrorDataDecoderException If an error occurs when decoding the multipart data.
*/ */
protected InterfaceHttpData getFileUpload(String delimiter) { protected InterfaceHttpData getFileUpload(String delimiter) {
// eventually restart from existing FileUpload // 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 * 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 * @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) { private static boolean loadDataMultipartOptimized(ByteBuf undecodedChunk, String delimiter, HttpData httpData) {
if (!undecodedChunk.isReadable()) { if (!undecodedChunk.isReadable()) {

View File

@ -223,7 +223,7 @@ public class WebSocketClientHandshaker00 extends WebSocketClientHandshaker {
* *
* @param response * @param response
* HTTP response returned from the server for the request sent by beginOpeningHandshake00(). * HTTP response returned from the server for the request sent by beginOpeningHandshake00().
* @throws WebSocketHandshakeException * @throws WebSocketHandshakeException If the handshake or challenge is invalid.
*/ */
@Override @Override
protected void verify(FullHttpResponse response) { protected void verify(FullHttpResponse response) {

View File

@ -260,7 +260,7 @@ public class WebSocketClientHandshaker07 extends WebSocketClientHandshaker {
* *
* @param response * @param response
* HTTP response returned from the server for the request sent by beginOpeningHandshake00(). * HTTP response returned from the server for the request sent by beginOpeningHandshake00().
* @throws WebSocketHandshakeException * @throws WebSocketHandshakeException If the handshake or challenge is invalid.
*/ */
@Override @Override
protected void verify(FullHttpResponse response) { protected void verify(FullHttpResponse response) {

View File

@ -262,7 +262,7 @@ public class WebSocketClientHandshaker08 extends WebSocketClientHandshaker {
* *
* @param response * @param response
* HTTP response returned from the server for the request sent by beginOpeningHandshake00(). * HTTP response returned from the server for the request sent by beginOpeningHandshake00().
* @throws WebSocketHandshakeException * @throws WebSocketHandshakeException If the handshake or challenge is invalid.
*/ */
@Override @Override
protected void verify(FullHttpResponse response) { protected void verify(FullHttpResponse response) {

View File

@ -148,10 +148,10 @@ public class HttpClientCodecTest {
// This is just a simple demo...don't block in IO // This is just a simple demo...don't block in IO
assertTrue(ctx.channel() instanceof SocketChannel); assertTrue(ctx.channel() instanceof SocketChannel);
final SocketChannel sChannel = (SocketChannel) ctx.channel(); final SocketChannel sChannel = (SocketChannel) ctx.channel();
/** /*
* The point of this test is to not add any content-length or content-encoding headers The point of this test is to not add any content-length or content-encoding headers
* and the client should still handle this. and the client should still handle this.
* See <a href="https://tools.ietf.org/html/rfc7230#section-3.3.3">RFC 7230, 3.3.3</a>. 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" + sChannel.writeAndFlush(Unpooled.wrappedBuffer(("HTTP/1.0 200 OK\r\n" +
"Date: Fri, 31 Dec 1999 23:59:59 GMT\r\n" + "Date: Fri, 31 Dec 1999 23:59:59 GMT\r\n" +

View File

@ -586,7 +586,8 @@ public class DefaultHttp2LocalFlowController implements Http2LocalFlowController
* *
* @param numBytes the number of bytes to be returned to the flow control window. * @param numBytes the number of bytes to be returned to the flow control window.
* @return true if {@code WINDOW_UPDATE} was written, false otherwise. * @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; boolean consumeBytes(int numBytes) throws Http2Exception;

View File

@ -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 * {@link Http2ChannelDuplexHandler#newStream()}, and then writing a {@link Http2HeadersFrame} object with the stream
* attached. * attached.
* *
* <pre> * <pre>{@code
* final Http2Stream2 stream = handler.newStream(); * final Http2Stream2 stream = handler.newStream();
* ctx.write(headersFrame.stream(stream)).addListener(new ChannelFutureListener() { * ctx.write(headersFrame.stream(stream)).addListener(new ChannelFutureListener() {
* *
@ -110,7 +110,7 @@ import static io.netty.handler.codec.http2.Http2Error.NO_ERROR;
* } * }
* } * }
* } * }
* </pre> * }</pre>
* *
* <p>If a new stream cannot be created due to stream id exhaustion of the endpoint, the {@link ChannelPromise} of the * <p>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}. * HEADERS frame will fail with a {@link Http2NoMoreStreamIdsException}.

View File

@ -67,7 +67,6 @@ public class HpackEncoderTest {
/** /**
* The encoder should not impose an arbitrary limit on the header size if * The encoder should not impose an arbitrary limit on the header size if
* the server has not specified any limit. * the server has not specified any limit.
* @throws Http2Exception
*/ */
@Test @Test
public void testWillEncode16MBHeaderByDefault() throws Http2Exception { public void testWillEncode16MBHeaderByDefault() throws Http2Exception {

View File

@ -121,10 +121,10 @@ public class Http2FrameCodecTest {
} }
private void setUp(Http2FrameCodecBuilder frameCodecBuilder, Http2Settings initialRemoteSettings) throws Exception { 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. 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 This call ensures that in case of two consecutive calls to setUp(), the previous channel is shutdown and
* ByteBufs are released correctly. ByteBufs are released correctly.
*/ */
tearDown(); tearDown();

View File

@ -194,7 +194,6 @@ public abstract class AbstractBinaryMemcacheDecoder<M extends BinaryMemcacheMess
* When the channel goes inactive, release all frames to prevent data leaks. * When the channel goes inactive, release all frames to prevent data leaks.
* *
* @param ctx handler context * @param ctx handler context
* @throws Exception
*/ */
@Override @Override
public void channelInactive(ChannelHandlerContext ctx) throws Exception { public void channelInactive(ChannelHandlerContext ctx) throws Exception {

View File

@ -156,8 +156,9 @@ public final class MqttDecoder extends ReplayingDecoder<DecoderState> {
* Decodes the fixed header. It's one byte for the flags and then variable * Decodes the fixed header. It's one byte for the flags and then variable
* bytes for the remaining length. * 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 * 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 * @param buffer the buffer to decode from
* @return the fixed header * @return the fixed header

View File

@ -64,16 +64,16 @@ public class ProtobufVarint32LengthFieldPrependerTest {
final int num = 266; final int num = 266;
assertThat(ProtobufVarint32LengthFieldPrepender.computeRawVarint32Size(num), is(size)); assertThat(ProtobufVarint32LengthFieldPrepender.computeRawVarint32Size(num), is(size));
final byte[] buf = new byte[size + num]; final byte[] buf = new byte[size + num];
/** /*
* 8 A 0 2 8 A 0 2
* 1000 1010 0000 0010 1000 1010 0000 0010
* 0000 1010 0000 0010 0000 1010 0000 0010
* 0000 0010 0000 1010 0000 0010 0000 1010
* 000 0010 000 1010 000 0010 000 1010
*
* 0000 0001 0000 1010 0000 0001 0000 1010
* 0 1 0 A 0 1 0 A
* 266 266
*/ */
buf[0] = (byte) (0x8A & 0xFF); buf[0] = (byte) (0x8A & 0xFF);
@ -99,16 +99,16 @@ public class ProtobufVarint32LengthFieldPrependerTest {
final int num = 0x4000; final int num = 0x4000;
assertThat(ProtobufVarint32LengthFieldPrepender.computeRawVarint32Size(num), is(size)); assertThat(ProtobufVarint32LengthFieldPrepender.computeRawVarint32Size(num), is(size));
final byte[] buf = new byte[size + num]; final byte[] buf = new byte[size + num];
/** /*
* 8 0 8 0 0 1 8 0 8 0 0 1
* 1000 0000 1000 0000 0000 0001 1000 0000 1000 0000 0000 0001
* 0000 0000 0000 0000 0000 0001 0000 0000 0000 0000 0000 0001
* 0000 0001 0000 0000 0000 0000 0000 0001 0000 0000 0000 0000
* 000 0001 000 0000 000 0000 000 0001 000 0000 000 0000
*
* 0 0000 0100 0000 0000 0000 0 0000 0100 0000 0000 0000
* 0 0 4 0 0 0 0 0 4 0 0 0
*
*/ */
buf[0] = (byte) (0x80 & 0xFF); buf[0] = (byte) (0x80 & 0xFF);
@ -135,16 +135,16 @@ public class ProtobufVarint32LengthFieldPrependerTest {
final int num = 0x200000; final int num = 0x200000;
assertThat(ProtobufVarint32LengthFieldPrepender.computeRawVarint32Size(num), is(size)); assertThat(ProtobufVarint32LengthFieldPrepender.computeRawVarint32Size(num), is(size));
final byte[] buf = new byte[size + num]; final byte[] buf = new byte[size + num];
/** /*
* 8 0 8 0 8 0 0 1 8 0 8 0 8 0 0 1
* 1000 0000 1000 0000 1000 0000 0000 0001 1000 0000 1000 0000 1000 0000 0000 0001
* 0000 0000 0000 0000 0000 0000 0000 0001 0000 0000 0000 0000 0000 0000 0000 0001
* 0000 0001 0000 0000 0000 0000 0000 0000 0000 0001 0000 0000 0000 0000 0000 0000
* 000 0001 000 0000 000 0000 000 0000 000 0001 000 0000 000 0000 000 0000
*
* 0000 0010 0000 0000 0000 0000 0000 0000 0010 0000 0000 0000 0000 0000
* 0 2 0 0 0 0 0 0 2 0 0 0 0 0
*
*/ */
buf[0] = (byte) (0x80 & 0xFF); buf[0] = (byte) (0x80 & 0xFF);

View File

@ -16,6 +16,7 @@
package io.netty.util.concurrent; package io.netty.util.concurrent;
import java.util.concurrent.CancellationException; import java.util.concurrent.CancellationException;
import java.util.concurrent.CompletionException;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException; import java.util.concurrent.TimeoutException;
@ -60,7 +61,7 @@ public interface Future<V> extends java.util.concurrent.Future<V> {
* failed. * failed.
* *
* @throws CancellationException if the computation was cancelled * @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 * @throws InterruptedException if the current thread was interrupted while waiting
* *
*/ */
@ -71,7 +72,7 @@ public interface Future<V> extends java.util.concurrent.Future<V> {
* failed. * failed.
* *
* @throws CancellationException if the computation was cancelled * @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<V> syncUninterruptibly(); Future<V> syncUninterruptibly();

View File

@ -13,29 +13,29 @@
* License for the specific language governing permissions and limitations * License for the specific language governing permissions and limitations
* under the License. * under the License.
*/ */
/** /*
* Copyright (c) 2004-2011 QOS.ch Copyright (c) 2004-2011 QOS.ch
* All rights reserved. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish, without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to permit persons to whom the Software is furnished to do so, subject to
* the following conditions: the following conditions:
*
* The above copyright notice and this permission notice shall be The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software. included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/ */
package io.netty.util.internal.logging; package io.netty.util.internal.logging;

View File

@ -13,29 +13,29 @@
* License for the specific language governing permissions and limitations * License for the specific language governing permissions and limitations
* under the License. * under the License.
*/ */
/** /*
* Copyright (c) 2004-2011 QOS.ch Copyright (c) 2004-2011 QOS.ch
* All rights reserved. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish, without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to permit persons to whom the Software is furnished to do so, subject to
* the following conditions: the following conditions:
*
* The above copyright notice and this permission notice shall be The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software. included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/ */
package io.netty.util.internal.logging; package io.netty.util.internal.logging;

View File

@ -13,29 +13,29 @@
* License for the specific language governing permissions and limitations * License for the specific language governing permissions and limitations
* under the License. * under the License.
*/ */
/** /*
* Copyright (c) 2004-2011 QOS.ch Copyright (c) 2004-2011 QOS.ch
* All rights reserved. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish, without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to permit persons to whom the Software is furnished to do so, subject to
* the following conditions: the following conditions:
*
* The above copyright notice and this permission notice shall be The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software. included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/ */
package io.netty.util.internal.logging; package io.netty.util.internal.logging;

View File

@ -13,29 +13,29 @@
* License for the specific language governing permissions and limitations * License for the specific language governing permissions and limitations
* under the License. * under the License.
*/ */
/** /*
* Copyright (c) 2004-2011 QOS.ch Copyright (c) 2004-2011 QOS.ch
* All rights reserved. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish, without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to permit persons to whom the Software is furnished to do so, subject to
* the following conditions: the following conditions:
*
* The above copyright notice and this permission notice shall be The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software. included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/ */
package io.netty.util.internal.logging; package io.netty.util.internal.logging;

View File

@ -13,29 +13,29 @@
* License for the specific language governing permissions and limitations * License for the specific language governing permissions and limitations
* under the License. * under the License.
*/ */
/** /*
* Copyright (c) 2004-2011 QOS.ch Copyright (c) 2004-2011 QOS.ch
* All rights reserved. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish, without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to permit persons to whom the Software is furnished to do so, subject to
* the following conditions: the following conditions:
*
* The above copyright notice and this permission notice shall be The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software. included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/ */
package io.netty.util.internal.logging; package io.netty.util.internal.logging;

View File

@ -13,29 +13,29 @@
* License for the specific language governing permissions and limitations * License for the specific language governing permissions and limitations
* under the License. * under the License.
*/ */
/** /*
* Copyright (c) 2004-2011 QOS.ch Copyright (c) 2004-2011 QOS.ch
* All rights reserved. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish, without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to permit persons to whom the Software is furnished to do so, subject to
* the following conditions: the following conditions:
*
* The above copyright notice and this permission notice shall be The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software. included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/ */
package io.netty.util.internal.logging; package io.netty.util.internal.logging;

View File

@ -13,28 +13,28 @@
* License for the specific language governing permissions and limitations * License for the specific language governing permissions and limitations
* under the License. * under the License.
*/ */
/** /*
* Copyright (c) 2004-2011 QOS.ch Copyright (c) 2004-2011 QOS.ch
* All rights reserved. All rights reserved.
* <p> <p>
* Permission is hereby granted, free of charge, to any person obtaining Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish, without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to permit persons to whom the Software is furnished to do so, subject to
* the following conditions: the following conditions:
* <p> <p>
* The above copyright notice and this permission notice shall be The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software. included in all copies or substantial portions of the Software.
* <p> <p>
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
package io.netty.util.internal.logging; package io.netty.util.internal.logging;

View File

@ -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 * A system property that can be used to turn on/off the {@link SslMasterKeyHandler} dynamically without having
* to edit your pipeline. * to edit your pipeline.
* <code>-Dio.netty.ssl.masterKeyHandler=true</code> * {@code -Dio.netty.ssl.masterKeyHandler=true}
*/ */
public static final String SYSTEM_PROP_KEY = "io.netty.ssl.masterKeyHandler"; 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 <code>io.netty.wireshark</code>. * 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</code> * ex. {@code RSA Session-ID:XXX Master-Key:YYY}
* This format is understood by Wireshark 1.6.0. * This format is understood by Wireshark 1.6.0.
* https://code.wireshark.org/review/gitweb?p=wireshark.git;a=commit;h=686d4cabb41185591c361f9ec6b709034317144b * 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'. * The key and session identifier are forwarded to the log named 'io.netty.wireshark'.

View File

@ -43,6 +43,7 @@ import io.netty.handler.codec.dns.DnsSection;
import io.netty.resolver.HostsFileEntriesProvider; import io.netty.resolver.HostsFileEntriesProvider;
import io.netty.resolver.HostsFileEntriesResolver; import io.netty.resolver.HostsFileEntriesResolver;
import io.netty.resolver.ResolvedAddressTypes; import io.netty.resolver.ResolvedAddressTypes;
import io.netty.resolver.dns.TestDnsServer.TestResourceRecord;
import io.netty.util.CharsetUtil; import io.netty.util.CharsetUtil;
import io.netty.util.NetUtil; import io.netty.util.NetUtil;
import io.netty.util.ReferenceCountUtil; 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.DnsAttribute;
import org.apache.directory.server.dns.store.RecordStore; import org.apache.directory.server.dns.store.RecordStore;
import org.apache.mina.core.buffer.IoBuffer; import org.apache.mina.core.buffer.IoBuffer;
import org.hamcrest.Matchers;
import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test; 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.IOException;
import java.io.InputStream; import java.io.InputStream;
@ -96,8 +98,8 @@ import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Queue; import java.util.Queue;
import java.util.Set; import java.util.Set;
import java.util.concurrent.CompletionException;
import java.util.concurrent.CancellationException; import java.util.concurrent.CancellationException;
import java.util.concurrent.CompletionException;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.CopyOnWriteArrayList; 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.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference; 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.A;
import static io.netty.handler.codec.dns.DnsRecordType.AAAA; import static io.netty.handler.codec.dns.DnsRecordType.AAAA;
@ -459,19 +459,17 @@ public class DnsNameResolverTest {
* simultaneously. * simultaneously.
*/ */
@Test @Test
public void testNameServerCache() throws IOException, InterruptedException { public void testNameServerCache() throws Exception {
final String overriddenIP = "12.34.12.34"; final String overriddenIP = "12.34.12.34";
final TestDnsServer dnsServer2 = new TestDnsServer(question -> { final TestDnsServer dnsServer2 = new TestDnsServer(question -> {
switch (question.getRecordType()) { if (question.getRecordType() == RecordType.A) {
case A: Map<String, Object> attr = new HashMap<>();
Map<String, Object> attr = new HashMap<>(); attr.put(DnsAttribute.IP_ADDRESS.toLowerCase(Locale.US), overriddenIP);
attr.put(DnsAttribute.IP_ADDRESS.toLowerCase(Locale.US), overriddenIP); return Collections.singleton(
return Collections.singleton( new TestResourceRecord(
new TestDnsServer.TestResourceRecord( question.getDomainName(), question.getRecordType(), attr));
question.getDomainName(), question.getRecordType(), attr));
default:
return null;
} }
return null;
}); });
dnsServer2.start(); dnsServer2.start();
try { try {
@ -1148,8 +1146,8 @@ public class DnsNameResolverTest {
final List<DnsRecord> records = resolver.resolveAll(new DefaultDnsQuestion("foo.com.", A)) final List<DnsRecord> records = resolver.resolveAll(new DefaultDnsQuestion("foo.com.", A))
.syncUninterruptibly().getNow(); .syncUninterruptibly().getNow();
assertThat(records, Matchers.hasSize(1)); assertThat(records, hasSize(1));
assertThat(records.get(0), Matchers.instanceOf(DnsRawRecord.class)); assertThat(records.get(0), instanceOf(DnsRawRecord.class));
final DnsRawRecord record = (DnsRawRecord) records.get(0); final DnsRawRecord record = (DnsRawRecord) records.get(0);
final ByteBuf content = record.content(); final ByteBuf content = record.content();
@ -1953,7 +1951,7 @@ public class DnsNameResolverTest {
try { try {
final List<InetAddress> addresses = resolver.resolveAll(unresolved).sync().get(); final List<InetAddress> addresses = resolver.resolveAll(unresolved).sync().get();
assertThat(addresses, Matchers.<InetAddress>hasSize(greaterThan(0))); assertThat(addresses, hasSize(greaterThan(0)));
for (InetAddress address : addresses) { for (InetAddress address : addresses) {
assertThat(address.getHostName(), startsWith(unresolved)); assertThat(address.getHostName(), startsWith(unresolved));
assertThat(address.getHostAddress(), startsWith(ipAddrPrefix)); 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 domain = "netty.io";
final String ns1Name = "ns1." + domain; final String ns1Name = "ns1." + domain;
final String ns2Name = "ns2." + domain; final String ns2Name = "ns2." + domain;
TestDnsServer testDnsServer = new TestDnsServer(new HashSet<String>( TestDnsServer testDnsServer = new TestDnsServer(new HashSet<String>(
Collections.singletonList(domain))) { singletonList(domain))) {
@Override @Override
protected DnsMessage filterMessage(DnsMessage message) { protected DnsMessage filterMessage(DnsMessage message) {
@ -1997,9 +1996,9 @@ public class DnsNameResolverTest {
try { try {
assertThat(resolver.resolve(domain).await().cause(), assertThat(resolver.resolve(domain).await().cause(),
Matchers.<Throwable>instanceOf(UnknownHostException.class)); instanceOf(UnknownHostException.class));
assertThat(resolver.resolveAll(domain).await().cause(), assertThat(resolver.resolveAll(domain).await().cause(),
Matchers.<Throwable>instanceOf(UnknownHostException.class)); instanceOf(UnknownHostException.class));
} finally { } finally {
resolver.close(); resolver.close();
testDnsServer.stop(); testDnsServer.stop();
@ -2455,7 +2454,7 @@ public class DnsNameResolverTest {
() -> testSearchDomainQueryFailureCompletes(ResolvedAddressTypes.IPV4_PREFERRED)); () -> testSearchDomainQueryFailureCompletes(ResolvedAddressTypes.IPV4_PREFERRED));
} }
private void testSearchDomainQueryFailureCompletes(ResolvedAddressTypes types) throws Throwable { private static void testSearchDomainQueryFailureCompletes(ResolvedAddressTypes types) throws Throwable {
DnsNameResolver resolver = newResolver() DnsNameResolver resolver = newResolver()
.resolvedAddressTypes(types) .resolvedAddressTypes(types)
.ndots(1) .ndots(1)
@ -2562,7 +2561,7 @@ public class DnsNameResolverTest {
TestDnsServer server = new TestDnsServer(Collections.singleton("test.netty.io")); TestDnsServer server = new TestDnsServer(Collections.singleton("test.netty.io"));
server.start(); server.start();
DnsNameResolver resolver = newResolver(ResolvedAddressTypes.IPV4_ONLY) DnsNameResolver resolver = newResolver(ResolvedAddressTypes.IPV4_ONLY)
.searchDomains(Collections.singletonList("netty.io")) .searchDomains(singletonList("netty.io"))
.nameServerProvider(new SingletonDnsServerAddressStreamProvider(server.localAddress())) .nameServerProvider(new SingletonDnsServerAddressStreamProvider(server.localAddress()))
.resolveCache(cache).build(); .resolveCache(cache).build();
try { try {
@ -2807,16 +2806,12 @@ public class DnsNameResolverTest {
if (qName.equals(name)) { if (qName.equals(name)) {
records.add(new TestDnsServer.TestResourceRecord( records.add(new TestDnsServer.TestResourceRecord(
qName, RecordType.CNAME, qName, RecordType.CNAME,
Collections.<String, Object>singletonMap( Collections.singletonMap(
DnsAttribute.DOMAIN_NAME.toLowerCase(), "cname.netty.io"))); DnsAttribute.DOMAIN_NAME.toLowerCase(), "cname.netty.io")));
records.add(new TestDnsServer.TestResourceRecord(qName,
RecordType.A, Collections.<String, Object>singletonMap(
DnsAttribute.IP_ADDRESS.toLowerCase(), ipv4Addr)));
} else {
records.add(new TestDnsServer.TestResourceRecord(qName,
RecordType.A, Collections.<String, Object>singletonMap(
DnsAttribute.IP_ADDRESS.toLowerCase(), ipv4Addr)));
} }
records.add(new TestDnsServer.TestResourceRecord(qName,
RecordType.A, Collections.singletonMap(
DnsAttribute.IP_ADDRESS.toLowerCase(), ipv4Addr)));
return records; return records;
}); });
dnsServer2.start(); dnsServer2.start();
@ -2830,8 +2825,8 @@ public class DnsNameResolverTest {
resolver = builder.build(); resolver = builder.build();
List<InetAddress> resolvedAddresses = resolver.resolveAll(name).syncUninterruptibly().getNow(); List<InetAddress> resolvedAddresses = resolver.resolveAll(name).syncUninterruptibly().getNow();
assertEquals(Collections.singletonList(InetAddress.getByAddress(name, new byte[] { 1, 2, 3, 4 })), assertEquals(singletonList(InetAddress.getByAddress(name, new byte[] { 1, 2, 3, 4 })),
resolvedAddresses); resolvedAddresses);
} finally { } finally {
dnsServer2.stop(); dnsServer2.stop();
if (resolver != null) { if (resolver != null) {
@ -2848,10 +2843,10 @@ public class DnsNameResolverTest {
Set<ResourceRecord> records = new LinkedHashSet<ResourceRecord>(2); Set<ResourceRecord> records = new LinkedHashSet<ResourceRecord>(2);
String qName = question.getDomainName().toLowerCase(); String qName = question.getDomainName().toLowerCase();
records.add(new TestDnsServer.TestResourceRecord(qName, records.add(new TestDnsServer.TestResourceRecord(qName,
RecordType.A, Collections.<String, Object>singletonMap( RecordType.A, Collections.singletonMap(
DnsAttribute.IP_ADDRESS.toLowerCase(), ipv4Addr))); DnsAttribute.IP_ADDRESS.toLowerCase(), ipv4Addr)));
records.add(new TestDnsServer.TestResourceRecord(qName, records.add(new TestDnsServer.TestResourceRecord(qName,
RecordType.A, Collections.<String, Object>singletonMap( RecordType.A, Collections.singletonMap(
DnsAttribute.IP_ADDRESS.toLowerCase(), ipv4Addr))); DnsAttribute.IP_ADDRESS.toLowerCase(), ipv4Addr)));
return records; return records;
}); });
@ -2940,11 +2935,11 @@ public class DnsNameResolverTest {
if (name.equals(host)) { if (name.equals(host)) {
Set<ResourceRecord> records = new HashSet<ResourceRecord>(2); Set<ResourceRecord> records = new HashSet<ResourceRecord>(2);
records.add(new TestDnsServer.TestResourceRecord(name, RecordType.A, records.add(new TestDnsServer.TestResourceRecord(name, RecordType.A,
Collections.<String, Object>singletonMap(DnsAttribute.IP_ADDRESS.toLowerCase(), Collections.singletonMap(DnsAttribute.IP_ADDRESS.toLowerCase(),
"10.0.0.1"))); "10.0.0.1")));
records.add(new TestDnsServer.TestResourceRecord(name, RecordType.A, records.add(new TestDnsServer.TestResourceRecord(name, RecordType.A,
Collections.<String, Object>singletonMap(DnsAttribute.IP_ADDRESS.toLowerCase(), Collections.singletonMap(DnsAttribute.IP_ADDRESS.toLowerCase(),
"10.0.0.2"))); "10.0.0.2")));
return records; return records;
} }
return null; return null;
@ -3020,9 +3015,9 @@ public class DnsNameResolverTest {
TestDnsServer dnsServer2 = new TestDnsServer(question -> { TestDnsServer dnsServer2 = new TestDnsServer(question -> {
String name = question.getDomainName(); String name = question.getDomainName();
if (name.equals(host)) { if (name.equals(host)) {
return Collections.<ResourceRecord>singleton( return Collections.singleton(
new TestDnsServer.TestResourceRecord(name, RecordType.TXT, new TestDnsServer.TestResourceRecord(name, RecordType.TXT,
Collections.<String, Object>singletonMap( Collections.singletonMap(
DnsAttribute.CHARACTER_STRING.toLowerCase(), txt))); DnsAttribute.CHARACTER_STRING.toLowerCase(), txt)));
} }
return null; return null;
@ -3080,8 +3075,8 @@ public class DnsNameResolverTest {
Socket socket = serverSocket.accept(); Socket socket = serverSocket.accept();
InputStream in = socket.getInputStream(); InputStream in = socket.getInputStream();
assertTrue((in.read() << 8 | (in.read() & 0xff)) > 2); // skip length field assertTrue((in.read() << 8 | in.read() & 0xff) > 2); // skip length field
int txnId = in.read() << 8 | (in.read() & 0xff); int txnId = in.read() << 8 | in.read() & 0xff;
IoBuffer ioBuffer = IoBuffer.allocate(1024); IoBuffer ioBuffer = IoBuffer.allocate(1024);
// Must replace the transactionId with the one from the TCP request // Must replace the transactionId with the one from the TCP request
@ -3141,7 +3136,7 @@ public class DnsNameResolverTest {
public void testCancelPromise() throws Exception { public void testCancelPromise() throws Exception {
final EventLoop eventLoop = group.next(); final EventLoop eventLoop = group.next();
final Promise<InetAddress> promise = eventLoop.newPromise(); final Promise<InetAddress> promise = eventLoop.newPromise();
final TestDnsServer dnsServer1 = new TestDnsServer(Collections.<String>emptySet()) { final TestDnsServer dnsServer1 = new TestDnsServer(Collections.emptySet()) {
@Override @Override
protected DnsMessage filterMessage(DnsMessage message) { protected DnsMessage filterMessage(DnsMessage message) {
promise.cancel(true); promise.cancel(true);
@ -3150,7 +3145,7 @@ public class DnsNameResolverTest {
}; };
dnsServer1.start(); dnsServer1.start();
final AtomicBoolean isQuerySentToSecondServer = new AtomicBoolean(); final AtomicBoolean isQuerySentToSecondServer = new AtomicBoolean();
final TestDnsServer dnsServer2 = new TestDnsServer(Collections.<String>emptySet()) { final TestDnsServer dnsServer2 = new TestDnsServer(Collections.emptySet()) {
@Override @Override
protected DnsMessage filterMessage(DnsMessage message) { protected DnsMessage filterMessage(DnsMessage message) {
isQuerySentToSecondServer.set(true); isQuerySentToSecondServer.set(true);

View File

@ -88,15 +88,15 @@ final class KQueueRecvByteAllocatorHandle extends DelegatingHandle implements Ex
} }
boolean maybeMoreDataToRead() { boolean maybeMoreDataToRead() {
/** /*
* kqueue with EV_CLEAR flag set requires that we read until we consume "data" bytes kqueue with EV_CLEAR flag set requires that we read until we consume "data" bytes
* (see <a href="https://www.freebsd.org/cgi/man.cgi?kqueue">kqueue man</a>). However in order to (see kqueue man: https://www.freebsd.org/cgi/man.cgi?kqueue). 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 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 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 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. read, and will force a EVFILT_READ ready event.
*
* It is assumed EOF is handled externally by checking {@link #isReadEOF()}. It is assumed EOF is handled externally by checking {@link #isReadEOF()}.
*/ */
return numberBytesPending != 0; return numberBytesPending != 0;
} }

View File

@ -50,7 +50,7 @@ public final class Unix {
/** /**
* Internal method... Should never be called from the user. * Internal method... Should never be called from the user.
* *
* @param registerTask * @param registerTask The task to run if this thread caused registration.
*/ */
@UnstableApi @UnstableApi
public static void registerInternal(Runnable registerTask) { public static void registerInternal(Runnable registerTask) {