-
-
Notifications
You must be signed in to change notification settings - Fork 754
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
Interceptor not always called before atmosphere endpoint invocation #2168
Comments
@reda-alaoui Can you elaborate on that, and more important, can you do pull request with your fixes?
Interceptors will be called when a the My proposal is fix it (just call the method in |
@jfarcand, we found 3 'incorrect' paths. 2nd pathat MyRealtimeEndpoint.message(MyRealtimeEndpoint.java:114)
at sun.reflect.GeneratedMethodAccessor9997.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.atmosphere.config.managed.Invoker.invokeMethod(Invoker.java:49)
at org.atmosphere.config.managed.ManagedAtmosphereHandler.message(ManagedAtmosphereHandler.java:366)
at org.atmosphere.config.managed.ManagedAtmosphereHandler.onStateChange(ManagedAtmosphereHandler.java:233)
at org.atmosphere.cpr.DefaultBroadcaster.invokeOnStateChange(DefaultBroadcaster.java:1047)
at org.atmosphere.cpr.DefaultBroadcaster$WriteOperation.call(DefaultBroadcaster.java:1088)
at org.atmosphere.cpr.DefaultBroadcaster.prepareInvokeOnStateChange(DefaultBroadcaster.java:1062)
at org.atmosphere.cpr.DefaultBroadcaster.executeAsyncWrite(DefaultBroadcaster.java:872)
at org.atmosphere.cpr.DefaultBroadcaster$2.run(DefaultBroadcaster.java:474)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745) We corrected this one by wrapping the default atmosphere thread executors. 3rd pathI don't have the stack trace now, but it originates from WebSocket webSocket = AtmosphereResourceImpl.class.cast(r).webSocket();
if (webSocket != null) {
webSocket.close();
} else {
AsynchronousProcessor.class.cast(config.framework().getAsyncSupport()).endRequest(AtmosphereResourceImpl.class.cast(r), true);
} The Do you consider those 2 paths as eligible to interception? |
The 3rd path could be corrected by readjusting the order of interceptors call. I don't know if we are able to add easily interceptors to be called before default ones. |
@reda-alaoui I'm not convinced interceptor needs to be called on every scenario you describe, specially when you use the Broadcaster. That will kill the performance For the order, you can always set the priority using the InvokationOrder. Like I said if you can submit a PR with an option to enable what you want, I've no problem reviewing it and integrating it. |
@jfarcand, is it normal that when firing the broadcaster from the server, the server endpoint itself receives the broadcast? I will submit you a PR, but before that I want to be sure to understand the system. |
@reda-alaoui There is an issue on that where you broadcast the same object that maps against your resource (search issue) |
Is it #2051 ? |
@reda-alaoui yes |
I think it is more about #1620 |
Hello,
We have one interceptor which opens and closes thread local resources such as security context, jdbc connection and logging context.
We noticed that there is a few paths where @managedservice methods (@message and @disconnect) are not invoked through the configured interceptors.
We managed to correct almost all paths by replacing the default atmosphere executors to apply our interceptor behaviour.
Now, here is the stacktrace of the last noticed path - RealtimeEndpoint.disconnect is annotated @disconnect - where interceptors are not called before disconnect:
Should we consider the upper example as a bug?
Should we consider a bug the fact that any atmosphere endpoint method could be called without using the interceptors?
If not, is there an alternative provided by atmosphere to replicate the http filter behaviour and what is then the usecase of interceptors?
The text was updated successfully, but these errors were encountered: