[Java][2.2.0]"Promise already completed" after migration to Play! 2.2.0

581 views
Skip to first unread message

pyled...@gmail.com

unread,
Feb 6, 2014, 9:46:30 AM2/6/14
to play-fr...@googlegroups.com
Hi,

I'm migrating a relatively large application from Play! 2.1.0 to 2.2.0. I followed the instructions supplied in the documentation.
All compiles fine but, at runtime, I get that :

java.lang.IllegalStateException: Promise already completed.
        at scala
.concurrent.Promise$class.complete(Promise.scala:55)
        at scala
.concurrent.impl.Promise$DefaultPromise.complete(Promise.scala:58)
        at scala
.concurrent.Promise$class.failure(Promise.scala:107)
        at scala
.concurrent.impl.Promise$DefaultPromise.failure(Promise.scala:58)
        at scala
.concurrent.Future$$anonfun$flatMap$1.apply(Future.scala:283)
        at scala
.concurrent.Future$$anonfun$flatMap$1.apply(Future.scala:274)
        at scala
.concurrent.impl.CallbackRunnable.run(Promise.scala:29)
        at play
.api.libs.iteratee.Execution$$anon$2.execute(Execution.scala:70)
        at scala
.concurrent.impl.CallbackRunnable.executeWithValue(Promise.scala:37)
        at scala
.concurrent.impl.Promise$DefaultPromise.tryComplete(Promise.scala:133)
        at scala
.concurrent.Promise$class.complete(Promise.scala:55)
        at scala
.concurrent.impl.Promise$DefaultPromise.complete(Promise.scala:58)
        at scala
.concurrent.impl.Future$PromiseCompletingRunnable.run(Future.scala:23)
        at akka
.dispatch.TaskInvocation.run(AbstractDispatcher.scala:42)
        at akka
.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(AbstractDispatcher.scala:386)
        at scala
.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
        at scala
.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
        at scala
.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
        at scala
.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)


I read some other posts dealing with this kind of issue but it didn't helped me.

I'm not sure that the problem comes from my code using Promise or from somewhere else.

In the class inheriting play.GlobalSettings, I overrode onError and onHandlerNotFound according this pattern :

    @Override
   
public F.Promise<SimpleResult> onHandlerNotFound(final RequestHeader request) {
       
return F.Promise.promise(new F.Function0<SimpleResult>() {

           
@Override
           
public SimpleResult apply() throws Throwable {
               
return notFound(views.html.errors.notFound.render(request.uri()));
           
}
       
});  
   
}

I use action composition with annotations which I overrode like that :

public F.Promise<SimpleResult> call(final Http.Context ctx) throws Throwable {

}




pyled...@gmail.com

unread,
Feb 6, 2014, 9:59:08 AM2/6/14
to play-fr...@googlegroups.com
Ooops, I didn't finished...

I use action composition with annotations which I rewrote like that :

public F.Promise<SimpleResult> call(final Http.Context ctx) throws Throwable {
    return delegate.call(ctx); // Which sends a F.Promise<SimpleResult> out of the box
}

And when I return anything else I use the same logic than above and I tried also :

return F.Promise.<SimpleResult> pure(forbidden("bla bla"));

I don't understand the problem. Someone can help me ?

pyled...@gmail.com

unread,
Feb 6, 2014, 10:51:33 AM2/6/14
to play-fr...@googlegroups.com
I have details :
With the Javascript debugger, I identified the incriminated routes and actions that produce the exception.
In debug mode, with breakpoints in the beginning of the actions, when I request the route, the exception is launched and the breakpoints are never reached.
Reply all
Reply to author
Forward
0 new messages