-
Notifications
You must be signed in to change notification settings - Fork 684
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(WIP) Migration to Netty 4 #1284
Comments
@tomparle great, thank you! I also wanted to upgrade to Netty 4, but failed even with compilation errors. So, you have achieved greater success :) I will try to run your version. No pull tequest is needed at the moment. |
Thanks @asolntsev for the kind message ! It motivates me to go further :-)
Let's discuss this more when you have some time to review the changes, and thanks again for your contribution ! |
Looks like the New and noteworthy in 4.0 should be carefully read and understand, and |
Hi @tomparle, I did the upgrade based on your work, and was able to start normally. For test I used the example from #1304. It starts up nicely:
And it starts serving the request too:
But after continuation it dies with
The |
I wanted to introduce the Netty4 library in 2+1 steps:
It seemed to be doable, as Netty 4 is now
They depend on At first sight I thought about new interface, based on Sure, Any thoughts? |
First, thank you very much @xabolcs for your contribution ! About the migration step : what would be the point to have both Netty 3 and 4 at the same time ? My opinion is that it would just bring up more problems. I would rather suggest to migrate to Netty 4 directly. Except for the test #1304, did you try an application of yours to see if you had the same IndexOutOfBoundsException error ? |
About the migration step: as you already know this is not just an average version bump, like the PostgreSQL or Hibernate. It's a major version bump. I didn't try other apps, will test later when I have progress. My quick & dirty work in progress solution is templating and registering the handlers, like: public class FullHttpRequestPlayHandler extends AbstractPlayHandler<FullHttpRequest> {
@Override
protected void messageReceived(ChannelHandlerContext ctx, FullHttpRequest msg) throws Exception {
messageReceivedDefault(ctx, msg);
}
} ... and: public abstract class AbstractPlayHandler<I> extends SimpleChannelInboundHandler<I> {
...
// TODO: Please keep in mind that this method will be renamed to messageReceived(ChannelHandlerContext, I) in 5.0.
@Override
protected final void channelRead0(ChannelHandlerContext ctx, I msg) throws Exception {
messageReceived(ctx, msg);
}
// TODO: Netty 5.0!
abstract protected void messageReceived(ChannelHandlerContext ctx, I msg) throws Exception;
protected final void messageReceivedDefault(final ChannelHandlerContext ctx, I msg) throws Exception {
if (Logger.isTraceEnabled()) {
// this is the plain old messageReceived, just renamed
Logger.trace("messageReceived: begin");
}
// Http request
if (msg instanceof FullHttpRequest) {
final FullHttpRequest nettyRequest = (FullHttpRequest) msg;
// Websocket upgrade
... |
I tested, and got the same Exception: 23:13:43,769 ERROR ~
@7f5co5bpl
Internal Server Error (500) for request GET /
Oops: IndexOutOfBoundsException
Unexpected error : Unexpected Error, caused by exception IndexOutOfBoundsException: index: 0, length: 3785 (expected: range(0, 256))
play.exceptions.UnexpectedException: Unexpected Error
at play.Invoker$Invocation.onException(Invoker.java:270)
at play.Invoker$Invocation.run(Invoker.java:334)
at play.netty4.server.AbstractPlayHandler$NettyInvocation.run(AbstractPlayHandler.java:271)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.IndexOutOfBoundsException: index: 0, length: 3785 (expected: range(0, 256))
at io.netty.buffer.AbstractByteBuf.checkRangeBounds(AbstractByteBuf.java:1425)
at io.netty.buffer.AbstractByteBuf.checkIndex0(AbstractByteBuf.java:1432)
at io.netty.buffer.AbstractByteBuf.checkIndex(AbstractByteBuf.java:1419)
at io.netty.buffer.AbstractByteBuf.checkSrcIndex(AbstractByteBuf.java:1437)
at io.netty.buffer.UnpooledHeapByteBuf.setBytes(UnpooledHeapByteBuf.java:260)
at io.netty.buffer.AbstractByteBuf.setBytes(AbstractByteBuf.java:631)
at play.netty4.server.AbstractPlayHandler.writeResponse(AbstractPlayHandler.java:405)
at play.netty4.server.AbstractPlayHandler.copyResponse(AbstractPlayHandler.java:516)
at play.netty4.server.AbstractPlayHandler$NettyInvocation.onSuccess(AbstractPlayHandler.java:303)
at play.Invoker$Invocation.run(Invoker.java:328)
... 8 more
23:13:43,770 ERROR ~ Error during the 500 response generation
java.lang.IndexOutOfBoundsException: index: 0, length: 2465 (expected: range(0, 256))
at io.netty.buffer.AbstractByteBuf.checkRangeBounds(AbstractByteBuf.java:1425)
at io.netty.buffer.AbstractByteBuf.checkIndex0(AbstractByteBuf.java:1432)
at io.netty.buffer.AbstractByteBuf.checkIndex(AbstractByteBuf.java:1419)
at io.netty.buffer.AbstractByteBuf.checkSrcIndex(AbstractByteBuf.java:1437)
at io.netty.buffer.UnpooledHeapByteBuf.setBytes(UnpooledHeapByteBuf.java:260)
at io.netty.buffer.AbstractByteBuf.setBytes(AbstractByteBuf.java:631)
at play.netty4.server.AbstractPlayHandler.serve500(AbstractPlayHandler.java:804)
at play.netty4.server.AbstractPlayHandler$NettyInvocation.run(AbstractPlayHandler.java:273)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
^C
Terminating Java process |
Looks like I reached your 2018 state! 😀 23:53:21,549 INFO ~ [play-thread-1] after await
23:53:21,559 TRACE ~ [play-thread-1] 2ms to render template {play}/framework/templates/tags/welcome_en.html
23:53:21,561 TRACE ~ [play-thread-1] 9ms to render template {play}/framework/templates/tags/welcome.html
23:53:21,562 TRACE ~ [play-thread-1] 12ms to render template /app/views/Application/index.html
23:53:21,567 TRACE ~ [play-thread-1] 5ms to render template /app/views/main.html
23:53:21,568 TRACE ~ [play-thread-1] copyResponse: begin
23:53:21,569 TRACE ~ [play-thread-1] writeResponse: begin
23:53:21,569 TRACE ~ [play-thread-1] writeResponse: content length [5743]
23:53:21,569 TRACE ~ [play-thread-1] writeResponse: end
23:53:21,569 TRACE ~ [play-thread-1] copyResponse: end
23:53:21,569 TRACE ~ [play-thread-1] execute: end
23:53:21,570 TRACE ~ [play-thread-1] run: end
|
I added @Override
public void channelReadComplete(ChannelHandlerContext ctx) throws Exception {
if (Logger.isTraceEnabled()) {
Logger.trace("channelReadComplete: begin");
}
ctx.flush();
super.channelReadComplete(ctx);
if (Logger.isTraceEnabled()) {
Logger.trace("channelReadComplete: end");
}
} |
@xabolcs, hi. Did you finish migration? Could you share your work? I didn't find its in your fork. |
Hi @aleksandy ! Sadly it was just abandoned, as it's equivalent to @tomparle's work. 😕
One must rethink Play!'s current integration with Netty 3! It's not portable to Netty 4 in it's current form. |
And first of all: one should write a test for "serving static resources"! |
Hi @tomparle and @aleksandy ! My Netty 4 contribution to the RePlay! fork was accepted. Feel free to check RePlay!'s code to get some hint! EDIT: Netty 4 still have problems with static resources: replay-framework/replay#157. 😞 |
Hi,
I wanted to migrate from old Netty 3.x to 4.1.x, which might offer some performance and memory enhancements, see https://netty.io/wiki/new-and-noteworthy-in-4.0.html and https://blog.twitter.com/engineering/en_us/a/2013/netty-4-at-twitter-reduced-gc-overhead.html.
It appears that the migration is tougher than I thought, and I cannot make it work : Play is stuck when starting the application.
Nevertheless, I think I still have done a big part of the work, replacing deprecated calls and updated new API calls. I removed all compilation errors and there is no error on startup. I guess I lack the necessary understanding to solve the remaining issues, so I just want to share the work in progress and welcome any help to finish the job !
The changes so far have been commited in this branch : https://github.com/tomparle/play1/tree/libupgrade . Tell me if it should be transformed in pull request or anything else.
The text was updated successfully, but these errors were encountered: