Commits
Tarun Sukhani authored 10a37cb6aec
[PF-31] Netty 3.10 -> Netty 4.2 Stage A: dep swap + non-WebSocket HTTP path
Replaces the bundled netty-3.10.6.Final.jar with the modular Netty 4.2.12
artifacts (buffer, codec-base, codec-http, common, handler, resolver,
transport) and migrates the server-side glue to the Netty 4 API. WebSocket
support and large-body disk-spooling are intentionally stubbed in this
stage; PF-32 (Stage B) restores StreamChunkAggregator-style spooling and
PF-33 (Stage C) restores the full WebSocket handshake + frame handling.
Codec/transport migration:
- Server.java: ServerBootstrap now uses bossGroup/workerGroup
EventLoopGroups + NioServerSocketChannel.class (replaced the Netty 3
NioServerSocketChannelFactory + Executors pair). bind() now
syncUninterruptibly() so startup failures are surfaced.
childOption(TCP_NODELAY) replaces setOption("child.tcpNoDelay").
- HttpServerPipelineFactory / SslHttpServerPipelineFactory: now extend
ChannelInitializer<Channel> instead of implementing ChannelPipelineFactory.
Default pipeline switches play.server.StreamChunkAggregator for the stock
io.netty.handler.codec.http.HttpObjectAggregator (1 MB cap configurable
via play.netty.maxContentLength). Reflective handler construction
special-cases HttpObjectAggregator's int-arg ctor.
- PlayHandler: extends ChannelInboundHandlerAdapter (was
SimpleChannelUpstreamHandler). messageReceived(ctx, MessageEvent) ->
channelRead(ctx, Object) with refcount release in finally.
parseRequest signature now takes FullHttpRequest (HttpObjectAggregator
emits FullHttpRequest); body bytes are copied out of the refcounted
ByteBuf. writeResponse / serve404 / serve500 / serveStatic error fallback
build DefaultFullHttpResponse so content can travel with the response;
copyResponse keeps headers-only DefaultHttpResponse for the streaming
paths (file / InputStream / ChunkedInput) and now flushes a trailing
LastHttpContent.EMPTY_LAST_CONTENT to terminate the message.
ctx.getChannel/getPipeline -> ctx.channel/pipeline; channel.write ->
channel.writeAndFlush at terminal write sites; getStatus/getProtocolVersion/
getMethod/getUri -> status/protocolVersion/method/uri.
HttpHeaders.isKeepAlive -> HttpUtil.isKeepAlive.
HttpHeaders.Names.* -> HttpHeaderNames.*; HttpHeaders.Values.WEBSOCKET ->
HttpHeaderValues.WEBSOCKET. ChannelBuffers.copiedBuffer ->
Unpooled.copiedBuffer; ChannelBuffer -> ByteBuf.
- LazyChunkedInput: implements ChunkedInput<ByteBuf> with the new
readChunk(ByteBufAllocator) signature plus length()/progress(); legacy
hasNextChunk()/nextChunk() retired.
- SslPlayHandler: channelConnected(ctx, ChannelStateEvent) -> channelActive(ctx).
Stores the local socket address on a channel AttributeKey so SSLException
redirects can build a useful Location URL. setEnableRenegotiation removed
(renegotiation off by default in Netty 4). sslHandler.handshake() ->
sslHandler.handshakeFuture(); SslListener now implements
GenericFutureListener<Future<Channel>> to match handshakeFuture's type.
exceptionCaught(ctx, ExceptionEvent) -> exceptionCaught(ctx, Throwable cause).
- FileService: ByteRangeInput implements ChunkedInput<ByteBuf>; nextChunk ->
readChunk(ByteBufAllocator) returning a refcount-aware ByteBuf; trailing
LastHttpContent.EMPTY_LAST_CONTENT sent after the chunked body.
HttpHeaders.isKeepAlive -> HttpUtil.isKeepAlive; getStatus/getMethod/
getProtocolVersion -> status/method/protocolVersion.
- FileChannelBuffer + StreamChunkAggregator: deleted. They were tightly
coupled to Netty 3's ChannelBuffer + HttpChunk model; PF-32 will replace
the disk-spooling logic against Netty 4's HttpContent/LastHttpContent
message model.
- NettyPlayChannel: ctx.getChannel().setReadable(b) ->
ctx.channel().config().setAutoRead(b).
- Http, F: org.jboss.netty.* -> io.netty.* import swaps (single line each).
- application-skel/conf/application.conf: documented default pipeline
updated to the io.netty.* class names with HttpObjectAggregator.
Test:
- test-src/play/mvc/CookieDataCodecTest: org.jboss.netty.* -> io.netty.*
for Cookie / ServerCookieDecoder.
Stage A intentionally caps aggregated request bodies at 1 MB and disables
WebSockets (501 stub). PF-32 restores large-body support; PF-33 restores
WebSockets and retires the deprecated Http.Inbound(ChannelHandlerContext)
ctor.
Verified with `ant clean unittest`: 295 tests pass, 0 failures.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>