Reputation: 4823
I'm little bit lost. I'm experiencing weird behaviour in my app recently when it comes to multiple parallel ajax calls. They get mixed up by Play.
More precisely: I have two ajax calls A and B send at approx. the same time in the client side (with jQuery ajax()). In my Play app call A should be handled (and was handled without any problems since a couple of days ago) by action 1. In the same way call B should be handled by action 2.
What actually happens is that sometimes indeed call A is handled by action 1 and B by 2, but sometimes both A and B are handled by 1, or at other times both A and B are handled by 2. I couldn't find any pattern. Of course this behaviour confuses my client side completely.
I'm a little bit lost now. I didn't change anything in the routing, nor any other major code changes - I was mostly working on JavaScript and the GUI. So I want to ask here if any one else have ever experienced something similar with Play. I could post code if it's any help (I'd have to clean it up a little bit).
Upvotes: 0
Views: 51
Reputation: 4823
I found the reason - although I don't really understand why it happens. The cause is the class annotation @Singleton
from the Google Guice plugin on an action composition class.
@Singleton
public class AuthenticationAction extends Action<Authenticated> {
@With(AuthenticationAction.class)
@Target({ ElementType.TYPE, ElementType.METHOD })
@Retention(RetentionPolicy.RUNTIME)
public @interface Authenticated {
}
private final UserDao userDao;
@Inject
AuthenticationAction(UserDao userService) {
this.userDao = userService;
}
...
After I removed the @Singleton
annotation it works fine again, no more ajax call mixup. :)
Still it's quite a strange behavior.
Upvotes: 1