Description
In WildFly, we use Artemis HTTP upgrade to connect from the Artemis client to the server.
We also have an older version of Netty (4.0.35.Final) than the one used by Artemis (4.1.5.Final).
When I upgraded the version of Netty in WildFly to 4.1.5.Final, I found a regression that is causing a ClassCastException in ActiveMQChannelHandler#channelRead where I received a Netty's LastHttpContent.EMPTY_LAST_CONTENT instead of a ByteBuf.
After some bisect, we found that the actual regression happened with Netty 4.0.37.Final and this PR[1].
Before Netty 4.0.37.Final, the pipeline was updated in HttpUpgradeHandler#channelRead0 when the HttpResponse (corresponding to the HTTP Upgrade 101 header). Then the following LastHttpContent.EMPTY_LAST_CONTENT was also consumed by it (but we don't care, the handshake was complete and the latch was already countdown).
However, with Netty 4.0.37.Final, the LastHttpContent.EMPTY_LAST_CONTENT is now handled after the pipeline was updated and it now received by ActiveMQChannelHandler#channelRead. This causes the ClassCastException as this handler is only expecting ByteBuf.
The code in HttpUpgradeHandler#channelRead0 must be updated so that the pipeline is updated only when the HTTP ugprade handshake is successful and we consume the LastHttpContent.EMPTY_LAST_CONTENT that is added by Netty