Netty

Clone Tools
  • last updated a few seconds ago
Constraints
Constraints: committers
 
Constraints: files
Constraints: dates
Bug fix for HttpPostMultipartRequestDecoder part decoding with an invalid charset not reported as an ErrorDataDecoderException

Motivation:

The current HttpPostMultipartRequestDecoder can decode multipart/form-data parts with a Content-Type that specifies a charset. When this charset is invalid the Charset.forName() throws an unchecked UnsupportedCharsetException. This exception is not catched by the decoder. It should actually be rethrown as an ErrorDataDecoderException, because the developer using the API would expect this validation failure to be reported as such.

Modifications:

Add a catch block for UnsupportedCharsetException and rethrow it as an ErrorDataDecoderException.

Result:

UnsupportedCharsetException are now rethrown as ErrorDataDecoderException.

Allow to customize NIO (channel) select strategies.

Motivation:

Under high throughput/low latency workloads, selector wakeups are

degrading performance when the incoming operations are triggered

from outside of the event loop. This is a common scenario for

"client" applications where the originating input is coming from

application threads rather from the socket attached inside the

event loops.

As a result, it can be desirable to defer the blocking select

so that incoming tasks (write/flush) do not need to wakeup

the selector.

Modifications:

This changeset adds the notion of a generic SelectStrategy which,

based on its contract, allows the implementation to optionally

defer the blocking select based on some custom criteria.

The default implementation resembles the original behaviour, that

is if tasks are in the queue `selectNow()` and move on, and if no

tasks need to be processed go into the blocking select and wait

for wakeup.

The strategy can be customized per `NioEventLoopGroup` in the

constructor.

Result:

High performance client applications are now given the chance to

customize for how long the actual selector blocking should be

deferred by employing a custom select strategy.

    • -0
    • +29
    /common/src/main/java/io/netty/util/IntSupplier.java
Allow to customize NIO (channel) select strategies.

Motivation:

Under high throughput/low latency workloads, selector wakeups are

degrading performance when the incoming operations are triggered

from outside of the event loop. This is a common scenario for

"client" applications where the originating input is coming from

application threads rather from the socket attached inside the

event loops.

As a result, it can be desirable to defer the blocking select

so that incoming tasks (write/flush) do not need to wakeup

the selector.

Modifications:

This changeset adds the notion of a generic SelectStrategy which,

based on its contract, allows the implementation to optionally

defer the blocking select based on some custom criteria.

The default implementation resembles the original behaviour, that

is if tasks are in the queue `selectNow()` and move on, and if no

tasks need to be processed go into the blocking select and wait

for wakeup.

The strategy can be customized per `NioEventLoopGroup` in the

constructor.

Result:

High performance client applications are now given the chance to

customize for how long the actual selector blocking should be

deferred by employing a custom select strategy.

    • -0
    • +29
    /common/src/main/java/io/netty/util/IntSupplier.java
Remove TCP_MD5 from EpollServerChannelConfig.

Motivation:

TCP_MD5 is only supported by SocketChannels so remove it from EpollServerChannelConfig which is generic.

Modifications:

Remove invalid code.

Result:

Remove invalid / dead code.

Remove TCP_MD5 from EpollServerChannelConfig.

Motivation:

TCP_MD5 is only supported by SocketChannels so remove it from EpollServerChannelConfig which is generic.

Modifications:

Remove invalid code.

Result:

Remove invalid / dead code.

Fix EpollServerSocketConfig.isFreebind()

Motivation:

EpollServerSocketConfig.isFreebind() throws an exception when called.

Modifications:

Use the correct getsockopt arguments.

Result:

No more exception when call EpollServerSocketConfig.isFreebind()

Fix EpollServerSocketConfig.isFreebind()

Motivation:

EpollServerSocketConfig.isFreebind() throws an exception when called.

Modifications:

Use the correct getsockopt arguments.

Result:

No more exception when call EpollServerSocketConfig.isFreebind()

HTTP/2 DefaultHttp2ConnectionEncoder data frame size incorrect if error

Motivation:

If an error occurs during a write operation then DefaultHttp2ConnectionEncoder.FlowControlledData will clear the CoalescingBufferQueue which will reset the queue's readable bytes to 0. To recover from an error the DefaultHttp2RemoteFlowController will attempt to return bytes to the flow control window, but since the frame has reset its own size this will lead to invalid flow control accounting.

Modifications:

- DefaultHttp2ConnectionEncoder.FlowControlledData should not reset its size if an error occurs

Result:

No more flow controller errors due to DefaultHttp2ConnectionEncoder.FlowControlledData setting its size to 0 if an error occurs.

Guard against re-entrance in PendingWriteQueue.

Motivation:

PendingWriteQueue should guard against re-entrant writes once

removeAndFailAll() is run.

Modifications:

removeAndFailAll() should repeat until the queue is finally empty.

Result:

assertEmpty() will always hold.

Guard against re-entrance in PendingWriteQueue.

Motivation:

PendingWriteQueue should guard against re-entrant writes once

removeAndFailAll() is run.

Modifications:

removeAndFailAll() should repeat until the queue is finally empty.

Result:

assertEmpty() will always hold.

HTTP/2 SimpleChannelPromiseAggregator don't fail fast

Motivation:

Http2Codec.SimpleChannelPromiseAggregator currently fails fast if as soon as a tryFailure or setFailure method is called. This can lead to write operations which pass the result of SimpleChannelPromiseAggregator.newPromise to multiple channel.write calls throwing exceptions due to the promise being already done. This behavior is not expected by most of the Netty codecs (SslHandler) and can also create unexpected leaks in the http2 codec (DefaultHttp2FrameWriter).

Modifications:

- Http2Codec.SimpleChannelPromiseAggregator shouldn't complete the promise until doneAllocatingPromises is called

- Usages of Http2Codec.SimpleChannelPromiseAggregator should be adjusted to handle the change in behavior

- What were leaks in DefaultHttp2FrameWriter should be fixed to catch any other cases where ctx.write may throw

Result:

SimpleChannelPromiseAggregator won't generate promises which are done when newPromise is called.

e2f5012 unit test cleanup

Motivation:

e2f5012 added unit tests which did not verify the buffer was released as it was intended to.

Modification:

- Unit tests must verify release is called

Result:

Unit tests enforce that ByteBufs are released.

DefaultChannelHandlerContext write leak

Motivation:

DefaultChannelHandlerContext calls a utility method validatePromise which may throw if the arguments are not valid. If this method throws then the message will not be released.

Modifications:

- If an exception is thrown the message should be released

Result:

No more leak in DefaultChannelHandlerContext.write

Fix potential infinite loop when resolving CNAME records

Related: #4771

Motivation:

A malicious or misconfigured DNS server can send the CNAME records that

resolve into each other, causing an unexpected infinite loop in

DnsNameResolverContext.onResponseCNAME().

Modifications:

- Remove the dereferenced CNAME from the alias map so that infinite loop

is impossible.

- Fix inspection warnings and typos in DnsNameResolverTest

Result:

Fixes #4771

Add DatagramPacketEncoder and DatagramPacketDecoder

Motivation:

UDP-oriented codec reusing the existing encoders and decoders would be helpful. See #1350

Modifications:

Add DatagramPacketEncoder and DatagramPacketDecoder to reuse the existing encoders and decoders.

Result:

People can use DatagramPacketEncoder and DatagramPacketDecoder to wrap existing encoders and decoders to create UDP-oriented codec.

Just a couple of minor javadoc fixes

Just a couple of minor javadoc fixes

Add CharsetUtil.encoder/decoder() methods

Motivation:

See #3321

Modifications:

1. Add CharsetUtil.encoder/decoder() methods

2. Deprecate CharsetUtil.getEncoder/getDecoder() methods

Result:

Users can use new CharsetUtil.encoder/decoder() to specify error actions

Add CharsetUtil.encoder/decoder() methods

Motivation:

See #3321

Modifications:

1. Add CharsetUtil.encoder/decoder() methods

2. Deprecate CharsetUtil.getEncoder/getDecoder() methods

Result:

Users can use new CharsetUtil.encoder/decoder() to specify error actions

HTTP/2 ByteBufUtil.writeUtf8 cleanup

Motiviation:

691bc1690e9542d6093b91ffe1fbdf7d075bcd42 made writeUtf8 consistent with String.getBytes() so that it never throws.

94f27be59b637c74763cc3b9fd27cf628b59f7bd provided a writeUtf8 method which takes a ByteBufAllocator to do an appropriately sized buffer allocation.

Result:

- Assume writeUtf8 will not throw in HTTP/2 codec

- Use the new writeUtf8 method

Result:

Cleaner code in codec-http2.

HTTP/2 Reduce Log Level

Motivation:

https://github.com/netty/netty/commit/83c4aa6ad880445856551de1f7d4aeb40ee06df4 changed the log level to warn, but should have changed to debug.

Modifications:

- Change the log level to debug in Http2ConnectionHandler if the GO_AWAY fails to send. The write failure could be the result of the channel already being closed.

Result:

Fixes https://github.com/netty/netty/issues/4930.

Use smaller connect timeout to speed up tests.

Motivation:

For on tests we expected a ConnectTimeoutException but used the default timeout of 10 seconds. This slows down testing.

Modifications:

Use connect timeout of 1 second in unit test.

Result:

Faster execution of unit test.

Use smaller connect timeout to speed up tests.

Motivation:

For on tests we expected a ConnectTimeoutException but used the default timeout of 10 seconds. This slows down testing.

Modifications:

Use connect timeout of 1 second in unit test.

Result:

Faster execution of unit test.

Add support for TCP_DEFER_ACCEPT and TCP_QUICKACK

Motivation:

When using the native transport have support for TCP_DEFER_ACCEPT or / and TCP_QUICKACK can be useful.

Modifications:

- Add support for TCP_DEFER_ACCEPT and TCP_QUICKACK

- Ad unit tests

Result:

TCP_DEFER_ACCEPT and TCP_QUICKACK are supported now.

Add support for TCP_DEFER_ACCEPT and TCP_QUICKACK

Motivation:

When using the native transport have support for TCP_DEFER_ACCEPT or / and TCP_QUICKACK can be useful.

Modifications:

- Add support for TCP_DEFER_ACCEPT and TCP_QUICKACK

- Ad unit tests

Result:

TCP_DEFER_ACCEPT and TCP_QUICKACK are supported now.

Conflicts:

transport-native-epoll/src/main/java/io/netty/channel/epoll/EpollChannelOption.java

Add junit timeout listener to print the full thread dump on test timeout

Motivation:

See #3172

Modifications:

https://github.com/netty/netty-build/pull/6 added a junit timeout listener to the netty-build project. This patch just set it up.

Result:

If a test is set the timeout parameter using junit's @Test(timeout = ...) and the timeout is triggered, a full stack trace dump will be outputted and also output the deadlocks if any.

Add junit timeout listener to print the full thread dump on test timeout

Motivation:

See #3172

Modifications:

https://github.com/netty/netty-build/pull/6 added a junit timeout listener to the netty-build project. This patch just set it up.

Result:

If a test is set the timeout parameter using junit's @Test(timeout = ...) and the timeout is triggered, a full stack trace dump will be outputted and also output the deadlocks if any.

Add asserts so users will see errors when try to use methods from outside the EventLoop.

Motivation:

We should guard users from using Unsafe methods from outside the EventLoop if not designed to do so.

Modifications:

Add asserts

Result:

Easier for users to detect miss-use.

Add asserts so users will see errors when try to use methods from outside the EventLoop.

Motivation:

We should guard users from using Unsafe methods from outside the EventLoop if not designed to do so.

Modifications:

Add asserts

Result:

Easier for users to detect miss-use.

HTTP/2 DefaultHttp2Connection NPE

Motivation:

If while iterating the active streams a close operation occurs this will be queued and process after the iteration has completed to avoid a concurrent modification exception. However it is possible that during the iteration the stream which was closed could have been removed from the priority tree and its parent would be set to null. Then after the iteration completes the close operation will attempt to dereference the parent and results in a NPE.

Modifications:

- pending close operations should verify the stream's parent is not null before processing the event

Result:

No More NPE.