Skip to content
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

Defer creating logger in StandardWebSocketHandlerAdapter #25428

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -42,7 +42,6 @@
*/
public class StandardWebSocketHandlerAdapter extends Endpoint {

private static final Log logger = LogFactory.getLog(StandardWebSocketHandlerAdapter.class);

private final WebSocketHandler handler;

Expand Down Expand Up @@ -104,7 +103,7 @@ public void onMessage(javax.websocket.PongMessage message) {
this.handler.afterConnectionEstablished(this.wsSession);
}
catch (Exception ex) {
ExceptionWebSocketHandlerDecorator.tryCloseWithError(this.wsSession, ex, logger);
ExceptionWebSocketHandlerDecorator.tryCloseWithError(this.wsSession, ex, LogFactory.getLog(getClass()));
}
}

Expand All @@ -114,7 +113,7 @@ private void handleTextMessage(javax.websocket.Session session, String payload,
this.handler.handleMessage(this.wsSession, textMessage);
}
catch (Exception ex) {
ExceptionWebSocketHandlerDecorator.tryCloseWithError(this.wsSession, ex, logger);
ExceptionWebSocketHandlerDecorator.tryCloseWithError(this.wsSession, ex, LogFactory.getLog(getClass()));
}
}

Expand All @@ -124,7 +123,7 @@ private void handleBinaryMessage(javax.websocket.Session session, ByteBuffer pay
this.handler.handleMessage(this.wsSession, binaryMessage);
}
catch (Exception ex) {
ExceptionWebSocketHandlerDecorator.tryCloseWithError(this.wsSession, ex, logger);
ExceptionWebSocketHandlerDecorator.tryCloseWithError(this.wsSession, ex, LogFactory.getLog(getClass()));
}
}

Expand All @@ -134,7 +133,7 @@ private void handlePongMessage(javax.websocket.Session session, ByteBuffer paylo
this.handler.handleMessage(this.wsSession, pongMessage);
}
catch (Exception ex) {
ExceptionWebSocketHandlerDecorator.tryCloseWithError(this.wsSession, ex, logger);
ExceptionWebSocketHandlerDecorator.tryCloseWithError(this.wsSession, ex, LogFactory.getLog(getClass()));
}
}

Expand All @@ -145,6 +144,7 @@ public void onClose(javax.websocket.Session session, CloseReason reason) {
this.handler.afterConnectionClosed(this.wsSession, closeStatus);
}
catch (Exception ex) {
Log logger = LogFactory.getLog(getClass());
if (logger.isWarnEnabled()) {
logger.warn("Unhandled on-close exception for " + this.wsSession, ex);
}
Expand All @@ -157,7 +157,7 @@ public void onError(javax.websocket.Session session, Throwable exception) {
this.handler.handleTransportError(this.wsSession, exception);
}
catch (Exception ex) {
ExceptionWebSocketHandlerDecorator.tryCloseWithError(this.wsSession, ex, logger);
ExceptionWebSocketHandlerDecorator.tryCloseWithError(this.wsSession, ex, LogFactory.getLog(getClass()));
}
}

Expand Down