开发者

Play Framework await() causes UnexpectedException

I upgraded to Play 1.2.1 this morning so I could make use of their new asynchronous programming with HTTP features.

When 开发者_如何学编程I use the example below, from the Play documentation ( * I am using a different method name * ), I receive an UnexpectedException error.

public static void loopWithoutBlocking() {
    for(int i=0; i<=10; i++) {
        Logger.info(i);
        await("1s");
    }
    renderText("Loop finished");
}

The error is as follows:

Oops: UnexpectedException

An unexpected error occured caused by exception UnexpectedException:
While applying class play.classloading.enhancers.ContinuationEnhancer
on controllers.Application

The example method above is placed within the Application controller and I have included the play.libs.F library.

Does the method using the await() call need to be nested within something deeper?


Just in case anybody encounters this same issue (it seems to have been reported by others as well) I thought I had best summarise how I resolved this issue (although it might not be viewed as an 'answer'):

As pointed out by @Codemwnci and Julien Tournay @ Play-framework google group. The code included within the question does actually run.

The actual cause of the error was some 'unrelated' code in the Application class that seemed to conflict with the await() call. After locating the offending method, I tidied up the code, which resulted in the error resolving itself - but I was not able to identify the actual cause of the issue (and trust me, I did look).

So, the answer you ask?

It is not the await() method, it is something else in your code...so comment out everything except the method containing the await() call and locate the code that breaks it.

Have fun finding that!


It appears that many bugs regarding await has been fixed after the 1.2.4 release (current one when I'm writting this answer).

So many problems aren't still fixed and I faced the same kind of issues.

But there is an alternate repos, located at : https://github.com/mbknor/play/tree/1.2.4-mbknor-custom-release

that contains the 1.2.4 version of Play with some critical updates/fixes, including those with await.

I tried it and for my problem, it now fixed.

Maybe it will for you.

Now, if Play 1.2.5 is released when you'll read those line, it shouldn't be a problem for you.


I've stumbled upon this problem today and I noticed that it was actually caused by length of a method. Yes, that is correct, there was one too long method in the same class that was causing the problem, after extracting part of it as another method, the problem is gone! So be sure to check your code for that.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜