Netty

Clone Tools
  • last updated a few seconds ago
Constraints
Constraints: committers
 
Constraints: files
Constraints: dates
Preserve the original filename when encoding a multipart/form in mixed mode. (#9270)

Motivation:

The HttpPostRequestEncoder overwrites the original filename of file uploads sharing the same name encoded in mixed mode when it rewrites the multipart body header of the previous file. The original filename should be preserved instead.

Modifications:

Change the HttpPostRequestEncoder to reuse the correct filename when the encoder switches to mixed mode. The original test is incorrect and has been modified too, in addition it tests with an extra file upload since the current test was not testing the continuation of a mixed mode.

Result:

The HttpPostRequestEncoder will preserve the original filename of the first fileupload when switching to mixed mode

    • -0
    • +1
    /codec-http/src/test/resources/file-03.txt
Preserve the original filename when encoding a multipart/form in mixed mode. (#9270)

Motivation:

The HttpPostRequestEncoder overwrites the original filename of file uploads sharing the same name encoded in mixed mode when it rewrites the multipart body header of the previous file. The original filename should be preserved instead.

Modifications:

Change the HttpPostRequestEncoder to reuse the correct filename when the encoder switches to mixed mode. The original test is incorrect and has been modified too, in addition it tests with an extra file upload since the current test was not testing the continuation of a mixed mode.

Result:

The HttpPostRequestEncoder will preserve the original filename of the first fileupload when switching to mixed mode

    • -0
    • +1
    /codec-http/src/test/resources/file-03.txt
Fixed the haproxy message mem leak issue (#9250)

Motivation:

HAProxyMessage should be released as it contains a list of TLV which hold a ByteBuf, otherwise, it may cause memory leaks.

Modification:

- Let HAProxyMessage extend AbstractReferenceCounted

- Adjust tests.

Result:

Fixes #9201

Fixed the haproxy message mem leak issue (#9250)

Motivation:

HAProxyMessage should be released as it contains a list of TLV which hold a ByteBuf, otherwise, it may cause memory leaks.

Modification:

- Let HAProxyMessage extend AbstractReferenceCounted

- Adjust tests.

Result:

Fixes #9201

EmptyByteBuf.getCharSequence(0,...) must return empty String

Motivation:

At the moment EmptyByteBuf.getCharSequence(0,...) will return null while it must return a "".

Modifications:

- Let EmptyByteBuf.getCharSequence(0,...) return ""

- Add unit test

Result:

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

Split multiplexing from frame decoding to allow easier customization of frame processing and better seperation of responsibilities (#9239)

Motivation:

In the past we had the following class hierarchy:

Http2ConnectionHandler --- Http2FrameCodec -- Http2MultiplexCodec

This hierarchy makes it impossible to plug in any code that would like to act on Http2Frame and Http2StreamFrame which can be quite useful for various situations (like metrics, logging etc). Beside this it also made the implementtion very hacky. To allow easier maintainance and also allow more flexible costumizations we should split Http2MultiplexCodec and Http2FrameCode.

Modifications:

- Introduce Http2MultiplexHandler (which is a replacement for Http2MultiplexCodec when used together with Http2FrameCodec)

- Mark Http2MultiplexCodecBuilder and Http2MultiplexCodec as deprecated. People should use Http2FrameCodecBuilder / Http2FrameCodec together with Http2MultiplexHandlder in the future

- Adjust / Add tests

- Adjust examples

Result:

More flexible usage possible and less hacky / coupled implementation for http2 multiplexing

  1. … 3 more files in changeset.
Split multiplexing from frame decoding to allow easier customization of frame processing and better seperation of responsibilities (#9239)

Motivation:

In the past we had the following class hierarchy:

Http2ConnectionHandler --- Http2FrameCodec -- Http2MultiplexCodec

This hierarchy makes it impossible to plug in any code that would like to act on Http2Frame and Http2StreamFrame which can be quite useful for various situations (like metrics, logging etc). Beside this it also made the implementtion very hacky. To allow easier maintainance and also allow more flexible costumizations we should split Http2MultiplexCodec and Http2FrameCode.

Modifications:

- Introduce Http2MultiplexHandler (which is a replacement for Http2MultiplexCodec when used together with Http2FrameCodec)

- Mark Http2MultiplexCodecBuilder and Http2MultiplexCodec as deprecated. People should use Http2FrameCodecBuilder / Http2FrameCodec together with Http2MultiplexHandlder in the future

- Adjust / Add tests

- Adjust examples

Result:

More flexible usage possible and less hacky / coupled implementation for http2 multiplexing

  1. … 3 more files in changeset.
Bugfix #9257: WebSocketProtocolHandler does NOT support autoRead=false (#9258)

Motivation:

I need to control WebSockets inbound flow manually, when autoRead=false

Modification:

Add missed ctx.read() call into WebSocketProtocolHandler, where read request has been swallowed.

Result:

Fixes #9257

Bugfix #9257: WebSocketProtocolHandler does NOT support autoRead=false (#9258)

Motivation:

I need to control WebSockets inbound flow manually, when autoRead=false

Modification:

Add missed ctx.read() call into WebSocketProtocolHandler, where read request has been swallowed.

Result:

Fixes #9257

Make EventLoopTaskQueueFactory a top-level interface

Motivation:

c9aaa93d83b5b571dbc733d2632232db82b3d884 added the ability to specify an EventLoopTaskQueueFactory but did place it under MultithreadEventLoopGroup while not really belongs there.

Modifications:

Make EventLoopTaskQueueFactory a top-level interface

Result:

More logical code layout.

Recycle RecyclableArrayDeque as fast as possible in FlowControlHandler (#9263)

Motivation:

FlowControlHandler does use a recyclable ArrayDeque internally but only recycles it when the channel is closed. We should better recycle it once it is empty.

Modifications:

Recycle the deque as fast as possible

Result:

Less RecyclableArrayDeque instances.

Recycle RecyclableArrayDeque as fast as possible in FlowControlHandler (#9263)

Motivation:

FlowControlHandler does use a recyclable ArrayDeque internally but only recycles it when the channel is closed. We should better recycle it once it is empty.

Modifications:

Recycle the deque as fast as possible

Result:

Less RecyclableArrayDeque instances.

Return the result of the list.recycle() call (#9264)

Motivation:

Resolve the issue highlighted by SpotJMHBugs that the creation of the RecyclableArrayList may be elided by the JIT since the result isn't consumed or returned.

Modifications:

Return the result of `list.recycle()` so that the list isn't elided.

Result:

The JMH benchmark shows a change in performance indicating that the prior results of this may be unsound.

Return the result of the list.recycle() call (#9264)

Motivation:

Resolve the issue highlighted by SpotJMHBugs that the creation of the RecyclableArrayList may be elided by the JIT since the result isn't consumed or returned.

Modifications:

Return the result of `list.recycle()` so that the list isn't elided.

Result:

The JMH benchmark shows a change in performance indicating that the prior results of this may be unsound.

Recycle RecyclableArrayDeque as fast as possible in FlowControlHandler

Motivation:

FlowControlHandler does use a recyclable ArrayDeque internally but only recycles it when the channel is closed. We should better recycle it once it is empty.

Modifications:

Recycle the deque as fast as possible

Result:

Less RecyclableArrayDeque instances.

Subsequence versions of ByteBufUtil#writeUtf8(...) methods (#9224)

Motivation

It would be useful to be able to write UTF-8 encoded subsequence of

CharSequence characters to a ByteBuf without needing to create a

temporary object via CharSequence#subSequence().

Modification

Add overloads of ByteBufUtil writeUtf8, reserveAndWriteUtf8 and

utf8Bytes methods which take explicit subsequence bounds.

Result

More efficient writing of substrings to byte buffers possible

Subsequence versions of ByteBufUtil#writeUtf8(...) methods (#9224)

Motivation

It would be useful to be able to write UTF-8 encoded subsequence of

CharSequence characters to a ByteBuf without needing to create a

temporary object via CharSequence#subSequence().

Modification

Add overloads of ByteBufUtil writeUtf8, reserveAndWriteUtf8 and

utf8Bytes methods which take explicit subsequence bounds.

Result

More efficient writing of substrings to byte buffers possible

Fix flaky DnsNameResolverTest.testTruncatedWithTcpFallback (#9262)

Motivation:

testTruncatedWithTcpFallback was flacky as we may end up closing the socket before we could read all data. We should only close the socket after we succesfully read all data.

Modifications:

Move socket.close() to finally block

Result:

Fix flaky test and so make the CI more stable again.

Fix flaky DnsNameResolverTest.testTruncatedWithTcpFallback (#9262)

Motivation:

testTruncatedWithTcpFallback was flacky as we may end up closing the socket before we could read all data. We should only close the socket after we succesfully read all data.

Modifications:

Move socket.close() to finally block

Result:

Fix flaky test and so make the CI more stable again.

Allow to specify a EventLoopTaskQueueFactory for various EventLoopGroup implementations (#9247)

Motivation:

Sometimes it is desirable to be able to use a different Queue implementation for the EventLoop of a Channel. This is currently not possible without resort to reflection.

Modifications:

- Add a new constructor to Nio|Epoll|KQueueEventLoopGroup which allows to specify a factory which is used to create the task queue. This was the user can override the default implementation.

- Add test

Result:

Be able to change Queue that is used for the EventLoop.

Fix flaky DnsNameResolverTest.testTruncatedWithTcpFallback

Motivation:

testTruncatedWithTcpFallback was flacky as we may end up closing the socket before we could read all data. We should only close the socket after we succesfully read all data.

Modifications:

Move socket.close() to finally block

Result:

Fix flaky test and so make the CI more stable again.

De-duplicate PooledByteBuf implementations (#9120)

Motivation

There's quite a lot of duplicate/equivalent logic across the various

concrete ByteBuf implementations. We could take this even further but

for now I've focused on the PooledByteBuf sub-hierarchy.

Modifications

- Move common logic/methods into existing PooledByteBuf abstract

superclass

- Shorten PooledByteBuf.capacity(int) method implementation

Result

Less code to maintain

De-duplicate PooledByteBuf implementations (#9120)

Motivation

There's quite a lot of duplicate/equivalent logic across the various

concrete ByteBuf implementations. We could take this even further but

for now I've focused on the PooledByteBuf sub-hierarchy.

Modifications

- Move common logic/methods into existing PooledByteBuf abstract

superclass

- Shorten PooledByteBuf.capacity(int) method implementation

Result

Less code to maintain

codec-http2: Lazily translate cookies for HTTP/1 (#9251)

Motivation:

For HTTP/2 messages with multiple cookies HttpConversionUtil.addHttp2ToHttpHeaders spends a good portion of time creating throwaway StringBuilders.

Modification:

Handle cookies lazily by using a ThreadLocal StringBuilder and then converting it to the H1 header at the end.

Result:

Less allocations.

codec-http2: Lazily translate cookies for HTTP/1 (#9251)

Motivation:

For HTTP/2 messages with multiple cookies HttpConversionUtil.addHttp2ToHttpHeaders spends a good portion of time creating throwaway StringBuilders.

Modification:

Handle cookies lazily by using a ThreadLocal StringBuilder and then converting it to the H1 header at the end.

Result:

Less allocations.

Try to mark child channel writable again once the parent channel becomes writable (#9254)

Motivation:

f945a071db4d499d21142d3aa321ce8070616665 decoupled the writability state from the flow controller but could lead to the situation of a lot of writability updates events were propagated to the child channels. This change ensure we only take into account if the parent channel becomes writable again before we try to set the child channels to writable.

Modifications:

Only listen for channel writability changes for if the parent channel becomes writable again.

Result:

Less writability updates.

Try to mark child channel writable again once the parent channel becomes writable (#9254)

Motivation:

f945a071db4d499d21142d3aa321ce8070616665 decoupled the writability state from the flow controller but could lead to the situation of a lot of writability updates events were propagated to the child channels. This change ensure we only take into account if the parent channel becomes writable again before we try to set the child channels to writable.

Modifications:

Only listen for channel writability changes for if the parent channel becomes writable again.

Result:

Less writability updates.

Try to mark child channel writable again once the parent channel becomes writable

Motivation:

f945a071db4d499d21142d3aa321ce8070616665 decoupled the writability state from the flow controller but could lead to the situation of a lot of writability updates events were propagated to the child channels. This change ensure we only take into account if the parent channel becomes writable again before we try to set the child channels to writable.

Modifications:

Only listen for channel writability changes for if the parent channel becomes writable again.

Result:

Less writability updates.

Try to mark child channel writable again once the parent channel becomes writable

Motivation:

f945a071db4d499d21142d3aa321ce8070616665 decoupled the writability state from the flow controller but could lead to the situation of a lot of writability updates events were propagated to the child channels. This change ensure we only take into account if the parent channel becomes writable again before we try to set the child channels to writable.

Modifications:

Only listen for channel writability changes for if the parent channel becomes writable again.

Result:

Less writability updates.

WebSocket is closed without an error on protocol violations (#9116)

Motivation:

Incorrect WebSockets closure affects our production system.

Enforced 'close socket on any protocol violation' prevents our custom termination sequence from execution.

Huge number of parameters is a nightmare both in usage and in support (decoders configuration).

Modification:

- Fix violations handling - send proper response codes.

- Fix for messages leak.

- Introduce decoder's option to disable default behavior (send close frame) on protocol violations.

- Encapsulate WebSocket response codes - WebSocketCloseStatus.

- Encapsulate decoder's configuration into a separate class - WebSocketDecoderConfig.

Result:

Fixes #8295.

  1. … 4 more files in changeset.