-
-
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
Encoders are populated only with the encoders specified with @Message #1487
Comments
@aleksandarn Can you attach a test I can play with? For this issue and the other one you created. Thanks |
I need time to prepare stand alone example, but this code snippet below @ManagedService( path="/pubsub")
public class ProtocolHandler{
@Ready(encoders = {JacksonEncoder.class})
public GenericMessage onReady(final AtmosphereResource r) {
return new GenericMessage( "connect", "User connected");
}
/*
* This is here to prevent the NPE. Without it, the encoders are not
populated
*/
/*
@Message(encoders = {JacksonEncoder.class}, decoders =
{JacksonDecoder.class})
public GenericMessage authorMessage(GenericMessage message) {
return null;
}
*/
}
class GenericMessage{
public String type;
public String data;
public GenericMessage(final String t, finalString d){
type = t;
data=d;
}
} Classes JaxonEncode and JacksonDecoder are the same found in the chat On Mon, 03 Mar 2014 17:46:48 +0200, Jeanfrancois Arcand
Using Opera's mail client: http://www.opera.com/mail/ |
Here is a small project to reproduce issues #1487 and #1488 https://www.dropbox.com/sh/us976u6fzoxhisj/go7TziAvn_ Steps how to reproduce on Glassfish 3.1.2.2 Reproducing #1487
Working around #1487 Reproducing #1488
|
The error is java.lang.NullPointerException: null
at org.atmosphere.config.managed.Invoker.matchEncoder(Invoker.java:118) ~[atmosphere-runtime-2.1.1-SNAPSHOT.jar:2.1.1-SNAPSHOT]
at org.atmosphere.config.managed.Invoker.encode(Invoker.java:68) ~[atmosphere-runtime-2.1.1-SNAPSHOT.jar:2.1.1-SNAPSHOT]
at org.atmosphere.config.managed.Invoker.all(Invoker.java:93) ~[atmosphere-runtime-2.1.1-SNAPSHOT.jar:2.1.1-SNAPSHOT]
at org.atmosphere.config.managed.ManagedAtmosphereHandler.message(ManagedAtmosphereHandler.java:350) ~[atmosphere-runtime-2.1.1-SNAPSHOT.jar:2.1.1-SNAPSHOT]
at org.atmosphere.config.managed.ManagedAtmosphereHandler.processReady(ManagedAtmosphereHandler.java:361) ~[atmosphere-runtime-2.1.1-SNAPSHOT.jar:2.1.1-SNAPSHOT]
at org.atmosphere.config.managed.ManagedAtmosphereHandler$1.onSuspend(ManagedAtmosphereHandler.java:118) ~[atmosphere-runtime-2.1.1-SNAPSHOT.jar:2.1.1-SNAPSHOT]
at org.atmosphere.cpr.AtmosphereResourceImpl.onSuspend(AtmosphereResourceImpl.java:640) [atmosphere-runtime-2.1.1-SNAPSHOT.jar:2.1.1-SNAPSHOT]
at org.atmosphere.cpr.AtmosphereResourceImpl.notifyListeners(AtmosphereResourceImpl.java:587) [atmosphere-runtime-2.1.1-SNAPSHOT.jar:2.1.1-SNAPSHOT]
at org.atmosphere.cpr.AtmosphereResourceImpl.notifyListeners(AtmosphereResourceImpl.java:564) [atmosphere-runtime-2.1.1-SNAPSHOT.jar:2.1.1-SNAPSHOT]
at org.atmosphere.cpr.AtmosphereResourceImpl.suspend(AtmosphereResourceImpl.java:383) [atmosphere-runtime-2.1.1-SNAPSHOT.jar:2.1.1-SNAPSHOT]
at org.atmosphere.interceptor.AtmosphereResourceLifecycleInterceptor.postInspect(AtmosphereResourceLifecycleInterceptor.java:119) [atmosphere-runtime-2.1.1-SNAPSHOT.jar:2.1.1-SNAPSHOT]
at org.atmosphere.cpr.AsynchronousProcessor.postInterceptors(AsynchronousProcessor.java:310) [atmosphere-runtime-2.1.1-SNAPSHOT.jar:2.1.1-SNAPSHOT]
at org.atmosphere.cpr.AsynchronousProcessor.action(AsynchronousProcessor.java:181) [atmosphere-runtime-2.1.1-SNAPSHOT.jar:2.1.1-SNAPSHOT]
at org.atmosphere.cpr.AsynchronousProcessor.suspended(AsynchronousProcessor.java:95) [atmosphere-runtime-2.1.1-SNAPSHOT.jar:2.1.1-SNAPSHOT]
at org.atmosphere.container.Jetty9AsyncSupportWithWebSocket.service(Jetty9AsyncSupportWithWebSocket.java:179) [atmosphere-runtime-2.1.1-SNAPSHOT.jar:2.1.1-SNAPSHOT]
at org.atmosphere.cpr.AtmosphereFramework.doCometSupport(AtmosphereFramework.java:1782) [atmosphere-runtime-2.1.1-SNAPSHOT.jar:2.1.1-SNAPSHOT]
at org.atmosphere.websocket.DefaultWebSocketProcessor.dispatch(DefaultWebSocketProcessor.java:421) [atmosphere-runtime-2.1.1-SNAPSHOT.jar:2.1.1-SNAPSHOT]
at org.atmosphere.websocket.DefaultWebSocketProcessor.open(DefaultWebSocketProcessor.java:175) [atmosphere-runtime-2.1.1-SNAPSHOT.jar:2.1.1-SNAPSHOT]
at org.atmosphere.container.Jetty9WebSocketHandler.onWebSocketConnect(Jetty9WebSocketHandler.java:62) [atmosphere-runtime-2.1.1-SNAPSHOT.jar:2.1.1-SNAPSHOT]
at org.eclipse.jetty.websocket.common.events.JettyListenerEventDriver.onConnect(JettyListenerEventDriver.java:86) [websocket-common-9.1.2.v20140210.jar:9.1.2.v20140210]
at org.eclipse.jetty.websocket.common.events.AbstractEventDriver.openSession(AbstractEventDriver.java:227) [websocket-common-9.1.2.v20140210.jar:9.1.2.v20140210]
at org.eclipse.jetty.websocket.common.WebSocketSession.open(WebSocketSession.java:406) [websocket-common-9.1.2.v20140210.jar:9.1.2.v20140210]
at org.eclipse.jetty.websocket.server.WebSocketServerFactory.sessionOpened(WebSocketServerFactory.java:443) [websocket-server-9.1.2.v20140210.jar:9.1.2.v20140210]
at org.eclipse.jetty.websocket.server.WebSocketServerConnection.onOpen(WebSocketServerConnection.java:73) [websocket-server-9.1.2.v20140210.jar:9.1.2.v20140210]
at org.eclipse.jetty.server.HttpConnection.completed(HttpConnection.java:318) [jetty-server-9.1.2.v20140210.jar:9.1.2.v20140210]
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:406) [jetty-server-9.1.2.v20140210.jar:9.1.2.v20140210]
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:232) [jetty-server-9.1.2.v20140210.jar:9.1.2.v20140210]
at org.eclipse.jetty.io.AbstractConnection$1.run(AbstractConnection.java:505) [jetty-io-9.1.2.v20140210.jar:9.1.2.v20140210]
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:607) [jetty-util-9.1.2.v20140210.jar:9.1.2.v20140210]
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:536) [jetty-util-9.1.2.v20140210.jar:9.1.2.v20140210]
at java.lang.Thread.run(Thread.java:744) [na:1.7.0_45] |
If you create a @managedservice and implement and annotate only @ready method and you specify some encoders - you will receive NPE because when atmosphere tries to encode the return value of the @ready method the list of encoders is null.
The reason for that is because the encoders list is populated only with the encoders declared with @message annotation, which is visible in https://github.com/Atmosphere/atmosphere/blob/master/modules/cpr/src/main/java/org/atmosphere/config/managed/ManagedAtmosphereHandler.java#L100
The populateEncoders() method correctly parses @message and @ready annotations, but is only called if at least one @message annotation is present.
The text was updated successfully, but these errors were encountered: