Netty

Clone Tools
  • last updated a few seconds ago
Constraints
Constraints: committers
 
Constraints: files
Constraints: dates
Fix compile error in test caused by 2d48ec4e3f2626fbfadf012b3b5184514f90d811

Remove spliceTo(...) support from native epoll transport

Motivation:

At some point we added spliceTo(...) support which was never really used and so we should better take the chance and remove it again now as part of the next major release

Modifications:

Remove spliceTo(...) related code

Result:

Less code to maintain

Call ctx.flush() when onStreamClosed(...) produces a window update frame (#9818)

Motivation:

We use the onStreamClosed(...) callback to return unconsumed bytes back to the window of the connection when needed. When this happens we will write a window update frame but not automatically call ctx.flush(). As the user has no insight into this it could in the worst case result in a "deadlock" as the frame is never written out ot the socket.

Modifications:

- If onStreamClosed(...) produces a window update frame call ctx.flush()

- Add unit test

Result:

No stales possible due unflushed window update frames produced by onStreamClosed(...) when not all bytes were consumed before the stream was closed

Use EmbeddedChannel.finishAndReleaseAll() to remove boiler-plate code (#9824)

Motivation:

We can make use of EmbeddedChannel.finishAndReleaseAll() and so remove some code

Modifications:

Use finishAndReleaseAll()

Result:

Less code to maintain

Don't send window update frame for unconsumed bytes when stream is already closed (#9816)

Motivation:

At the moment we send a window update frame for the connection + stream when a stream is closed and there are unconsumed bytes left. While we need to do this for the connection it makes no sense to write a window update frame for the stream itself as it is already closed

Modifications:

- Don't write the window update frame for the stream when the stream is closed

- Add unit test

Result:

Don't write the window frame for closed streams

Correctly set writerIndex when EpollChannelOption.MAX_DATAGRAM_PAYLOAD_SIZE is used in all cases (#9819)

Motivation:

Due a bug we did not correctly set the writerIndex of the ByteBuf when a

user specified EpollChannelOption.MAX_DATAGRAM_PAYLOAD_SIZE but we ended

up with a non scattering read.

Modifications:

- Set writerIndex to the correct value

- Add unit tests

Result:

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

Use latest maven release (#9820)

Motivation:

Apache Maven 3.6.3 was released

Modifications:

Update to latest version

Result:

Use latest version to build

    • -1
    • +1
    /.mvn/wrapper/maven-wrapper.properties
Fix compile error introduced by 2c3d263e23ae94e99d6f46ddd44a13c877a29c1c

Bugfix #9673: Origin header is always sent from WebSocket client (#9692)

Those who need 'Origin' or 'Sec-WebSocket-Origin' headers should provide them explicitly, like it is stated in WebSocket specs.

E.g. through custom headers:

HttpHeaders customHeaders = new DefaultHttpHeaders()

.add(HttpHeaderNames.ORIGIN, "http://localhost:8080");

new WebSocketClientProtocolHandler(

new URI("ws://localhost:1234/test"), WebSocketVersion.V13, subprotocol,

allowExtensions, customHeaders, maxFramePayloadLength, handshakeTimeoutMillis)

* Remove enforced origin headers.

* Update tests

Fixes #9673: Origin header is always sent from WebSocket client

Simplify Deflate* implementations by using EmbeddedChannel.finishAndReleaseAll() (#9808)

Motivation:

We can simplify the code by just using finishAndReleaseAll()

Modifications:

Remove some code and simplify

Result:

Cleaner code

Correctly guard against multiple RST frames for the same stream (#9811)

Motivation:

Http2ConnectionHandler tries to guard against sending multiple RST frames for the same stream. Unfortunally the code is not 100 % correct as it only updates the state after it calls write. This may lead to the situation of have an extra RST frame slip through if the second write for the RST frame is done from a listener that is attached to the promise.

Modifications:

- Update state before calling write

- Add unit test

Result:

Only ever send one RST frame per stream

Fix the transport-native-unix-common build on FreeBSD (#9814)

Motivation:

Modern versions of FreeBSD define IP_RECVORIGDSTADDR, but don't define

SOL_IP. This causes the build to fail.

Modifications:

The equivalent to SOL_IP on FreeBSD is IPPROTO_IP. Define SOL_IP as that

if SOL_IP is not defined and IPPROTO_IP is.

Result:

This allows a successful build on FreeBSD

    • -0
    • +3
    /transport-native-unix-common/src/main/c/netty_unix_socket.c
Support Passing KeyManager and TrustManager into SslContextBuilder (#9805) (#9786)

Motivation:

This is a PR to solve the problem described here: https://github.com/netty/netty/issues/9767

Basically this PR is to add two more APIs in SslContextBuilder, for users to directly specify

the KeyManager or TrustManager they want to use when building SslContext. This is very helpful

when users want to pass in some customized implementation of KeyManager or TrustManager.

Modification:

This PR takes the first approach in here:

https://github.com/netty/netty/issues/9767#issuecomment-551927994 (comment)

which is to immediately convert the managers into factories and let factories continue to pass

through Netty.

1. Add in SslContextBuilder the two APIs mentioned above

2. Create a KeyManagerFactoryWrapper and a TrustManagerFactoryWrapper, which take a KeyManager

and a TrustManager respectively. These are two simple wrappers that do the conversion from

XXXManager class to XXXManagerFactory class

3.Create a SimpleKeyManagerFactory class(and internally X509KeyManagerWrapper for compatibility),

which hides the unnecessary details such as KeyManagerFactorySpi. This serves the similar

functionalities with SimpleTrustManagerFactory, which was already inside Netty.

Result:

Easier usage.

Correctly only active not_x86_64 profile when using a non x86_64 platform (#9805)

Motivation:

21720e4a7865b77d252a4263271663d7ed462440 introduced a change which aimed to enable the not_x86_64 profile when building on a x86_64 platform. Unfortunaly it made an assemption which not holds true and so the profile was already enabled. This lead to the situation that native SSL tests were skipped if non boringssl impl was used.

Modifications:

Fix profile activation to work as expected

Result:

Correctly run aal native SSL tests

Log expected STREAM_CLOSED exceptions for already closed streams at DEBUG level (#9798)

Motivation:

There is an intrinsic race between a local session resetting a stream

and the peer no longer sending any frames. This can result in the

session receiving frames for a stream that the local peer no longer

tracks. This results in a StreamException being thrown which triggers a

RST_STREAM frame, which is a good thing, but also logging at level WARN,

which is noisy for an expected and benign condition.

Modification:

Change the log level to DEBUG when logging stream errors with code

STREAM_CLOSED. All others are more interesting and will continue to be

logged at level WARN.

Additionally, it was found that DATA frames for streams that could not

have existed only resulted in a StreamException when the spec is clear

that such a situation should be fatal to the connection, resulting in a

GOAWAY(PROTOCOL_ERROR).

Fixes #8025.

Remove dependency on GLIBC 2.12 by using syscalls directly (#9797)

Motivation:

394a1b3485000c211595aff7495c4f863972af29 introduced a hard dependency on GLIBC 2.12 which was not the case before. This had the effect of not be able to use the native epoll transports on platforms which ship with earlier versions of GLIBC.

To make things a backward compatible as possible we should not introduce such changes in a bugfix release.

Special thanks to @weissi with all the help to fix this.

Modifications:

- Use syscalls directly to remove dependency on GLIBC 2.12

- Make code consistent that needs newer GLIBC versions

- Adjust scattering read test to only run if recvmmsg syscall is supported

- Cleanup pom.xml as some stuff is not needed anymore after using syscalls.

Result:

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

    • -12
    • +32
    /transport-native-epoll/src/main/c/netty_epoll_native.c
Remove atomic usage in DefaultChannelHandlerContext as all pipeline operations are on the EventLoop (#9794)

Motivation:

In netty 5.x we changed to have all pipeline operations be executed on the EventLoop so there is no need to have an atomic operation involved anymore to update the handler state.

Modifications:

Remove atomic usage to handle the handler state

Result:

Simpler code and less overhead

Fix tests failures introduced by bad cherry-pick of 7ff8cde66f14d9582d78480c845406725b042344 (#9795)

Motivation:

7ff8cde66f14d9582d78480c845406725b042344 introduced some tests which needs some small adjustments for master.

Modifications:

Add explicit casts

Result:

master builds again without test failures

Update to latest JMH version (#9787)

Motivation

JMH 1.22 was released recently, we might as well use the latest when

running benchmarks.

Summary of changes:

https://mail.openjdk.java.net/pipermail/jmh-dev/2019-November/002879.html

Modifications

Update jmh dependencies in microbench module from version 1.21 to 1.22.

Result

Benchmarks run using latest JMH

Send close frame on channel close, when this frame was not send manually (#9745)

Motivation:

By default CloseWebSocketFrames are handled automatically.

However I need manually manage their sending both on client- and on server-sides.

Modification:

Send close frame on channel close automatically, when it was not send before explicitly.

Result:

No more messages like "Connection closed by remote peer" for normal close flows.

Update to latest recommended maven version (#9785)

Motivation:

Latest recommended maven version is 3.6.2 so we should use it

Modifications:

Update from 3.5.2 to 3.6.2

Result:

Use latest recommended maven version

    • -1
    • +1
    /.mvn/wrapper/maven-wrapper.properties
Add one new constructor with ThreadFactory / Executor only

Motivation:

In most cases, we want to use MultithreadEventLoopGroup without setting thread numbers but thread name only. We should simplify this for the user

Modifications:

Add a new constructor

Result:

User can only set ThreadFactory / Executor without setting the thread number to 0:

Enable generation of test JARs (#9774)

Motivation:

Netty currently doesn't build and distribute the test JARs. Having easy access to the test JARs would enable downstream projects (such as GraalVM) to integrate the Netty unit tests in their CI pipeline to ensure continous compatibility with Netty features. The alternative would be to build Netty from source every time to obtain the test jars, however, depending on the CI setup, that may not always be possible.

Modifications:

Modify `pom.xml` to enable generation of test JARs and corresponding source JARs.

Result:

Running the Maven build will create the test JARs and corresponding source JARs. This change was tested locally via `mvn install` and the test JARs are correctly copied under the Maven cache. The expectation is that running `mvn deploy` will also copy the additional JARs to the maven repository.

Improve java doc for MINIMAL_WAIT (#9779)

Motivation:

MINIMAL_WAIT is the key constant. Thus, When we see the constant, we must read more code logic to see if it is ms or ns. So improving java doc will be better.

Modifications:

Improve java doc by add "10ms" such as DEFAULT_CHECK_INTERVAL with "1s".

Result:

Easy to know it is ms and keep same java doc style with other constants such as DEFAULT_CHECK_INTERVAL.

Reduce ByteBuffer duplication when resizing pooled direct ByteBufs (#9765)

Motivation:

Currently when use of Unsafe is disabled and an internal reallocation is

performed for a direct PooledByteBuf, a one-off temporary duplicate is

made of the source and destination backing nio buffers so that the

copy can be done in a threadsafe manner.

The need for this can be reduced by sharing the temporary duplicate

buffer that is already stored in the corresponding destination

PooledByteBuf instance.

Modifications:

Have PoolArena#memoryCopy(...) take the destination PooledByteBuf

instead of the underlying mem reference and offset, and use

internalNioBuffer() to obtain/initialize a reusable duplicate of the

backing nio buffer.

Result:

Fewer temporary allocations when resizing direct pooled ByteBufs in the

non-Unsafe case

Add constants for fixed-header only MQTT messages (#9749)

Motivation:

Currently, the only way to create fixed-header only messages PINGREQ,

PINGRESP and DISCONNECT is to explicitly instantiate a `MqttFixedHeader` like:

```

MqttFixedHeader disconnectFixedHeader = new MqttFixedHeader(MqttMessageType.DISCONNECT,

false, MqttQoS.AT_MOST_ONCE, false, 0);

MqttMessage disconnectMessage = new MqttMessage(disconnectFixedHeader);

```

According to the MQTT spec

(http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html#_Toc398718077),

the fixed-header flags for these messages are reserved and must be set to zero, otherwise

the receiver must close the connection. It's easy to mess this up when

you're creating the header explicitly, for e.g by setting the QoS bit to

`AT_LEAST_ONCE`.

As such, provide static constants for PINGREQ, PINGRESP and

DISCONNECT messages that will set the flags correctly for the developer.

Modification:

Add static constants to MqttMessage class to construct PINGREQ, PINGRESP and

DISCONNECT messages that will set the fixed-header flags correctly to 0.

Result:

Easier usage.

Add test to check Connection-Specific headers are removed in HTTP/2 (by HttpConversionUtil.toHttp2Headers) (#9766)

Motivation:

To avoid regression regarding connection-specific headers[1], we should add a test.

[1] https://tools.ietf.org/html/rfc7540#section-8.1.2.2

Modification:

Add test that checks the following headers are removed.

- Connection

- Host

- Keep-Alive

- Proxy-Connection

- Transfer-Encoding

- Upgrade

Result:

There's no functional change.

Update to latest netty-tcnative release (#9763)

Motivation:

There is a new netty-tcnative release. We should use it.

Modifications:

Update to 2.0.27

Result:

Use latest netty-tcnative release

Don't cache key material if sun.security.ssl.X509KeyManagerImpl is used (#9762)

Motivation:

sun.security.ssl.X509KeyManagerImpl will not use "stable" aliases and so aliases may be changed during invocations. This means caching is useless. Because of this we should disable the cache if its used.

Modifications:

- Disable caching if sun.security.ssl.X509KeyManagerImpl is used

- Add tests

Result:

More protection against https://github.com/netty/netty/issues/9747.

At the moment the cache provided by OpenSslCachingKeyMaterialProvider… (#9759)

Motivation:

At the moment te cache is not bound and so lead to huge memory consumpation. We should ensure its bound by default.

Modifications:

Ensure cache is bound

Result:

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