Skip to content

Commit

Permalink
Change the log message and add some information about the returned va…
Browse files Browse the repository at this point in the history
…lue, which might be null
  • Loading branch information
jfarcand committed Aug 27, 2012
1 parent de949eb commit bb2477f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,11 @@ public WebSocket webSocket() {
@Override
public void close(int closeCode) {
logger.trace("WebSocket closed with {}", closeCode);
// A message might be in the process of being processed and the websocket gets closed. In that corner
// case the webSocket.resource will be set to false and that might cause NPE in some WebSocketProcol implementation
// We could potentially synchronize on webSocket but since it is a rare case, it is better to not synchronize.
// synchronized (webSocket) {

notifyListener(new WebSocketEventListener.WebSocketEvent("", CLOSE, webSocket));
AtmosphereResourceImpl resource = (AtmosphereResourceImpl) webSocket.resource();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ public WebSocket resource(AtmosphereResource r) {
}

/**
* Return the an {@link AtmosphereResource} used by this WebSocket
* Return the an {@link AtmosphereResource} used by this WebSocket, or null if the WebSocket has been closed
* before the WebSocket message has been processed.
*
* @return {@link AtmosphereResource}
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public void configure(AtmosphereConfig config) {
public List<AtmosphereRequest> onMessage(WebSocket webSocket, String d) {
AtmosphereResourceImpl resource = (AtmosphereResourceImpl) webSocket.resource();
if (resource == null) {
logger.error("Invalid state. No AtmosphereResource has been suspended");
logger.trace("The WebSocket has been closed before the message was processed.");
return null;
}
String pathInfo = resource.getRequest().getPathInfo();
Expand Down

0 comments on commit bb2477f

Please sign in to comment.