Netty

Clone Tools
  • last updated a few seconds ago
Constraints
Constraints: committers
 
Constraints: files
Constraints: dates
Adding codeAsText to HttpResponseStatus.

Motivation:

I found myself writing AsciiString constants in my code for

response statuses and thought that perhaps it might be nice to have

them defined by Netty instead.

Modifications:

Adding codeAsText to HttpResponseStatus that returns the status code as

AsciiText.

In addition, added the 421 Misdirected Request response code from

https://tools.ietf.org/html/draft-ietf-httpbis-http2-15#section-9.1.2

This response header was renamed in draft 15:

https://tools.ietf.org/html/draft-ietf-httpbis-http2-15#appendix-A.1

But the code itself was not changed, and I thought using the latest would

be better.

Result:

It is now possible to specify a status like this:

new DefaultHttp2Headers().status(HttpResponseStatus.OK.codeAsText());

Disable SSLv3 (POODLE)

Related: #3131

Motivation:

To prevent users from accidentally enabling SSLv3 and making their

services vulnerable to POODLE, disable SSLv3 when SSLEngine is

instantiated via SslContext.

Modification:

- Disable SSLv3 for JdkSslContext and OpenSslServerContext

Result:

Saner default set of protocols

Prevent channel re-registration from firing channelActive

Motivation:

AbstractUnsafe considers two possibilities during channel registration. First,

the channel may be an outgoing connection, in which case it will be registered

before becoming active. Second, the channel may be an incoming connection in,

which case the channel will already be active when it is registered. To handle

the second case, AbstractUnsafe checks if the channel is active after

registration and calls ChannelPipeline.fireChannelActive() if so. However, if

an active channel is deregistered and then re-registered this logic causes a

second fireChannelActive() to be invoked. This is unexpected; it is reasonable

for handlers to assume that this method will only be invoked once per channel.

Modifications:

This change introduces a flag into AbstractUnsafe to recognize if this is the

first or a subsequent registration. ChannelPipeline.fireChannelActive() is only

possible for the first registration.

Result:

ChannelPipeline.fireChannelActive() is only called once.

Prevent channel re-registration from firing channelActive

Motivation:

AbstractUnsafe considers two possibilities during channel registration. First,

the channel may be an outgoing connection, in which case it will be registered

before becoming active. Second, the channel may be an incoming connection in,

which case the channel will already be active when it is registered. To handle

the second case, AbstractUnsafe checks if the channel is active after

registration and calls ChannelPipeline.fireChannelActive() if so. However, if

an active channel is deregistered and then re-registered this logic causes a

second fireChannelActive() to be invoked. This is unexpected; it is reasonable

for handlers to assume that this method will only be invoked once per channel.

Modifications:

This change introduces a flag into AbstractUnsafe to recognize if this is the

first or a subsequent registration. ChannelPipeline.fireChannelActive() is only

possible for the first registration.

Result:

ChannelPipeline.fireChannelActive() is only called once.

Prevent channel re-registration from firing channelActive

Motivation:

AbstractUnsafe considers two possibilities during channel registration. First,

the channel may be an outgoing connection, in which case it will be registered

before becoming active. Second, the channel may be an incoming connection in,

which case the channel will already be active when it is registered. To handle

the second case, AbstractUnsafe checks if the channel is active after

registration and calls ChannelPipeline.fireChannelActive() if so. However, if

an active channel is deregistered and then re-registered this logic causes a

second fireChannelActive() to be invoked. This is unexpected; it is reasonable

for handlers to assume that this method will only be invoked once per channel.

Modifications:

This change introduces a flag into AbstractUnsafe to recognize if this is the

first or a subsequent registration. ChannelPipeline.fireChannelActive() is only

possible for the first registration.

Result:

ChannelPipeline.fireChannelActive() is only called once.

Fix checkstyle

Fix checkstyle

Backport the new methods and bug fixes in NetUtil

Related:

- 37a6f5ed5dd56284ec37e14e0554e912f84426a1

Motivation:

Minimize the backport cost by synchronizing NetUtil between 3.9 and 4.x

Modifications:

- Backport the bug fixes in NetUtil

- Backport the new IP address methods in NetUtil

Result:

- New useful methods in NetUtil

- Easier to backport the future bug fixes

    • -174
    • +556
    /src/main/java/org/jboss/netty/util/NetUtil.java
Handle the interface name in IPv6 address correctly

Motivation:

NetUtil.isValidIpV6Address() handles the interface name in IPv6 address

incorrectly. For example, it returns false for the following addresses:

- ::1%lo

- ::1%_%_in_name_

Modifications:

- Strip the square brackets before validation for simplicity

- Strip the part after the percent sign completely before validation for

simplicity

- Simplify and reformat NetUtilTest

Result:

- The interface names in IPv6 addresses are handled correctly.

- NetUtilTest is cleaner

    • -145
    • +521
    /common/src/main/java/io/netty/util/NetUtil.java
Handle the interface name in IPv6 address correctly

Motivation:

NetUtil.isValidIpV6Address() handles the interface name in IPv6 address

incorrectly. For example, it returns false for the following addresses:

- ::1%lo

- ::1%_%_in_name_

Modifications:

- Strip the square brackets before validation for simplicity

- Strip the part after the percent sign completely before validation for

simplicity

- Simplify and reformat NetUtilTest

Result:

- The interface names in IPv6 addresses are handled correctly.

- NetUtilTest is cleaner

    • -66
    • +30
    /common/src/main/java/io/netty/util/NetUtil.java
Handle the interface name in IPv6 address correctly

Motivation:

NetUtil.isValidIpV6Address() handles the interface name in IPv6 address

incorrectly. For example, it returns false for the following addresses:

- ::1%lo

- ::1%_%_in_name_

Modifications:

- Strip the square brackets before validation for simplicity

- Strip the part after the percent sign completely before validation for

simplicity

- Simplify and reformat NetUtilTest

Result:

- The interface names in IPv6 addresses are handled correctly.

- NetUtilTest is cleaner

    • -66
    • +30
    /common/src/main/java/io/netty/util/NetUtil.java
Work around the Javadoc failure in JDK 8

Motivation:

Since JDK 1.8, javadoc has enabled a new feature called 'doclint', which

fails the build when javadoc has markup problems and more.

Modifications:

Do not fail the build until we fix our API documentation.

Result:

No more build failure because of malformed Javadoc

Allow DefaultHttp2Headers to be forced to lowercase.

Motivation:

I came across an issue when I was adding/setting headers and mistakenly

used an upper case header name. When using the http2 example that ships

with Netty this was not an issue. But when working with a browser that

supports http2, in my case I was using Firefox Nightly, I'm guessing

that it interprets the response as invalid in accordance with the

specifiction

https://tools.ietf.org/html/draft-ietf-httpbis-http2-14#section-8.1.2

"However, header field names MUST be converted to lowercase prior

to their encoding in HTTP/2. A request or response containing

uppercase header field names MUST be treated as malformed"

This PR suggests converting to lowercase to be the default.

Modifications:

Added a no-args constructor that defaults to forcing the key/name to

lowercase, and providing a second constructor to override this behaviour

if desired.

Result:

It is now possible to specify a header like this:

Http2Headers headers = new DefaultHttp2Headers(true)

.status(new AsciiString("200"))

.set(new AsciiString("Testing-Uppercase"), new AsciiString("some value"));

And the header written to the client will then become:

testing-uppercase:"some value"

Correctly shutdown wrapped Executor in PausableChannelEventExecutor.shutdown()

Motivation:

PausableChannelEventExecutor().shutdown() used to call unwrap().terminationFuture() instead of unwrap.shutdown().

This error was reported by @xfrag in a comment to a commit message [1]. Tyvm.

Modifications:

PausableChannelEventExecutor.shutdown() now correctly invokes unwrap().shutdown() instead of unwrap().terminationFuture().

Result:

Correct code.

[1] https://github.com/netty/netty/commit/220660e351b2a22112b19c4af45e403eab1f73ab#commitcomment-8489643

Cater for empty response bodies when performing response compression.

Motivation:

RFC 2616, 4.3 Message Body states that:

All 1xx (informational), 204 (no content), and 304 (not modified) responses MUST NOT include a

message-body. All other responses do include a message-body, although it MAY be of zero length.

Modifications:

HttpContentEncoder was previously modified to cater for HTTP 100 responses. This check is enhanced to

include HTTP 204 and 304 responses.

Result:

Empty response bodies will not be modified to include the compression footer. This footer messed with Chrome's

response parsing leading to "hanging" requests.

Cater for empty response bodies when performing response compression.

Motivation:

RFC 2616, 4.3 Message Body states that:

All 1xx (informational), 204 (no content), and 304 (not modified) responses MUST NOT include a

message-body. All other responses do include a message-body, although it MAY be of zero length.

Modifications:

HttpContentEncoder was previously modified to cater for HTTP 100 responses. This check is enhanced to

include HTTP 204 and 304 responses.

Result:

Empty response bodies will not be modified to include the compression footer. This footer messed with Chrome's

response parsing leading to "hanging" requests.

Cater for empty response bodies when performing response compression.

Motivation:

RFC 2616, 4.3 Message Body states that:

All 1xx (informational), 204 (no content), and 304 (not modified) responses MUST NOT include a

message-body. All other responses do include a message-body, although it MAY be of zero length.

Modifications:

HttpContentEncoder was previously modified to cater for HTTP 100 responses. This check is enhanced to

include HTTP 204 and 304 responses.

Result:

Empty response bodies will not be modified to include the compression footer. This footer messed with Chrome's

response parsing leading to "hanging" requests.

Fix bug in HTTP/2 outbound flow control

Motivation:

The outbound flow controller logic does not properly reset the allocated

bytes between successive invocations of the priority algorithm.

Modifications:

Updated the priority algorithm to reset the allocated bytes for each

stream.

Result:

Each call to the priority algorithm now starts with zero allocated bytes

for each stream.

Clean up code of HTTP/2 codec

Motivation:

Too many warnings from IntelliJ IDEA code inspector, PMD and FindBugs.

Modifications:

- Removed unnecessary casts, braces, modifiers, imports, throws on methods, etc.

- Added static modifiers where it is possible.

- Fixed incorrect links in javadoc.

Result:

Better code.

  1. … 23 more files in changeset.
Add logLevel property to enable different log levels for the examples.

Motivation:

When running the examples using the provided run-examples.sh script the

log level is 'info' level. It can be handy to be able to configure a

different level, for example 'debug', while learning and trying out the

the examples.

Modifications:

Added a dependency to logback-classic to the examples pom.xml, and also

added a logback configuration file. The log level can be configured by

setting the 'logLevel' system property, and if that property is not set

the default will be 'info' level.

The run-examples.sh was updated to show an example of using the system

property to set the log level to 'debug'

Result:

It is now possible to turn on debug logging by settnig a system property

on the command line.

    • -0
    • +11
    /example/src/main/resources/logback.xml
Add logLevel property to enable different log levels for the examples.

Motivation:

When running the examples using the provided run-examples.sh script the

log level is 'info' level. It can be handy to be able to configure a

different level, for example 'debug', while learning and trying out the

the examples.

Modifications:

Added a dependency to logback-classic to the examples pom.xml, and also

added a logback configuration file. The log level can be configured by

setting the 'logLevel' system property, and if that property is not set

the default will be 'info' level.

The run-examples.sh was updated to show an example of using the system

property to set the log level to 'debug'

Result:

It is now possible to turn on debug logging by settnig a system property

on the command line.

    • -0
    • +11
    /example/src/main/resources/logback.xml
Add logLevel property to enable different log levels for the examples.

Motivation:

When running the examples using the provided run-examples.sh script the

log level is 'info' level. It can be handy to be able to configure a

different level, for example 'debug', while learning and trying out the

the examples.

Modifications:

Added a dependency to logback-classic to the examples pom.xml, and also

added a logback configuration file. The log level can be configured by

setting the 'logLevel' system property, and if that property is not set

the default will be 'info' level.

The run-examples.sh was updated to show an example of using the system

property to set the log level to 'debug'

Result:

It is now possible to turn on debug logging by settnig a system property

on the command line.

    • -0
    • +11
    /example/src/main/resources/logback.xml
Small performance improvements

Motivation:

Found performance issues via FindBugs and PMD.

Modifications:

- Removed unnecessary boxing/unboxing operations in DefaultTextHeaders.convertToInt(CharSequence) and DefaultTextHeaders.convertToLong(CharSequence). A boxed primitive is created from a string, just to extract the unboxed primitive value.

- Added a static modifier for DefaultHttp2Connection.ParentChangedEvent class. This class is an inner class, but does not use its embedded reference to the object which created it. This reference makes the instances of the class larger, and may keep the reference to the creator object alive longer than necessary.

- Added a static compiled Pattern to avoid compile it each time it is used when we need to replace some part of authority.

- Improved using of StringBuilders.

Result:

Performance improvements.

  1. … 35 more files in changeset.
Small performance improvements

Motivation:

Found performance issues via FindBugs and PMD.

Modifications:

- Removed unnecessary boxing/unboxing operations in DefaultTextHeaders.convertToInt(CharSequence) and DefaultTextHeaders.convertToLong(CharSequence). A boxed primitive is created from a string, just to extract the unboxed primitive value.

- Added a static modifier for DefaultHttp2Connection.ParentChangedEvent class. This class is an inner class, but does not use its embedded reference to the object which created it. This reference makes the instances of the class larger, and may keep the reference to the creator object alive longer than necessary.

- Added a static compiled Pattern to avoid compile it each time it is used when we need to replace some part of authority.

- Improved using of StringBuilders.

Result:

Performance improvements.

  1. … 16 more files in changeset.
Small performance improvements

Motivation:

Found performance issues via FindBugs and PMD.

Modifications:

- Removed unnecessary boxing/unboxing operations in DefaultTextHeaders.convertToInt(CharSequence) and DefaultTextHeaders.convertToLong(CharSequence). A boxed primitive is created from a string, just to extract the unboxed primitive value.

- Added a static modifier for DefaultHttp2Connection.ParentChangedEvent class. This class is an inner class, but does not use its embedded reference to the object which created it. This reference makes the instances of the class larger, and may keep the reference to the creator object alive longer than necessary.

- Added a static compiled Pattern to avoid compile it each time it is used when we need to replace some part of authority.

- Improved using of StringBuilders.

Result:

Performance improvements.

  1. … 32 more files in changeset.
Allow to enable/disable protocols on the OpenSslEngine

Motivation:

To be compatible with SSLEngine we need to support enable / disable procols on the OpenSslEngine

Modifications:

Implement OpenSslEngine.getSupportedProtocols() , getEnabledProtocols() and setEnabledProtocols(...)

Result:

Better compability with SSLEngine

Allow to enable/disable protocols on the OpenSslEngine

Motivation:

To be compatible with SSLEngine we need to support enable / disable procols on the OpenSslEngine

Modifications:

Implement OpenSslEngine.getSupportedProtocols() , getEnabledProtocols() and setEnabledProtocols(...)

Result:

Better compability with SSLEngine

Allow to enable/disable protocols on the OpenSslEngine

Motivation:

To be compatible with SSLEngine we need to support enable / disable procols on the OpenSslEngine

Modifications:

Implement OpenSslEngine.getSupportedProtocols() , getEnabledProtocols() and setEnabledProtocols(...)

Result:

Better compability with SSLEngine

Benchmark for HttpRequestDecoder

Benchmark for HttpRequestDecoder