diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/adapter/jetty/JettyWebSocketHandlerAdapter.java b/spring-websocket/src/main/java/org/springframework/web/socket/adapter/jetty/JettyWebSocketHandlerAdapter.java index 6b16b5897c4..af3413d4109 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/adapter/jetty/JettyWebSocketHandlerAdapter.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/adapter/jetty/JettyWebSocketHandlerAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -119,8 +119,8 @@ public class JettyWebSocketHandlerAdapter { this.webSocketHandler.afterConnectionClosed(this.wsSession, closeStatus); } catch (Throwable ex) { - if (logger.isErrorEnabled()) { - logger.error("Unhandled error for " + this.wsSession, ex); + if (logger.isWarnEnabled()) { + logger.warn("Unhandled exception after connection closed for " + this, ex); } } } diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/adapter/standard/StandardWebSocketHandlerAdapter.java b/spring-websocket/src/main/java/org/springframework/web/socket/adapter/standard/StandardWebSocketHandlerAdapter.java index 2a22c40f025..b3258215006 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/adapter/standard/StandardWebSocketHandlerAdapter.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/adapter/standard/StandardWebSocketHandlerAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -141,8 +141,8 @@ public class StandardWebSocketHandlerAdapter extends Endpoint { this.handler.afterConnectionClosed(this.wsSession, closeStatus); } catch (Throwable ex) { - if (logger.isErrorEnabled()) { - logger.error("Unhandled error for " + this.wsSession, ex); + if (logger.isWarnEnabled()) { + logger.warn("Unhandled on-close exception for " + this.wsSession, ex); } } } diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/handler/ExceptionWebSocketHandlerDecorator.java b/spring-websocket/src/main/java/org/springframework/web/socket/handler/ExceptionWebSocketHandlerDecorator.java index 5e0ea0b8637..a5712138a95 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/handler/ExceptionWebSocketHandlerDecorator.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/handler/ExceptionWebSocketHandlerDecorator.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -78,8 +78,8 @@ public class ExceptionWebSocketHandlerDecorator extends WebSocketHandlerDecorato getDelegate().afterConnectionClosed(session, closeStatus); } catch (Throwable ex) { - if (logger.isErrorEnabled()) { - logger.error("Unhandled error for " + this, ex); + if (logger.isWarnEnabled()) { + logger.warn("Unhandled exception after connection closed for " + this, ex); } } } diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/messaging/SubProtocolWebSocketHandler.java b/spring-websocket/src/main/java/org/springframework/web/socket/messaging/SubProtocolWebSocketHandler.java index ce6923aed2b..e5856585d3b 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/messaging/SubProtocolWebSocketHandler.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/messaging/SubProtocolWebSocketHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -59,6 +59,7 @@ import org.springframework.web.socket.sockjs.transport.session.StreamingSockJsSe * sub-protocol handler to send messages from the application back to the client. * * @author Rossen Stoyanchev + * @author Juergen Hoeller * @author Andy Wilkinson * @author Artem Bilan * @since 4.0 @@ -150,8 +151,8 @@ public class SubProtocolWebSocketHandler for (String protocol : protocols) { SubProtocolHandler replaced = this.protocolHandlerLookup.put(protocol, handler); if (replaced != null && replaced != handler) { - throw new IllegalStateException("Can't map " + handler + - " to protocol '" + protocol + "'. Already mapped to " + replaced + "."); + throw new IllegalStateException("Cannot map " + handler + + " to protocol '" + protocol + "': already mapped to " + replaced + "."); } } this.protocolHandlers.add(handler); @@ -257,8 +258,8 @@ public class SubProtocolWebSocketHandler holder.getSession().close(CloseStatus.GOING_AWAY); } catch (Throwable ex) { - if (logger.isErrorEnabled()) { - logger.error("Failed to close '" + holder.getSession() + "': " + ex); + if (logger.isWarnEnabled()) { + logger.warn("Failed to close '" + holder.getSession() + "': " + ex); } } } @@ -318,7 +319,7 @@ public class SubProtocolWebSocketHandler String sessionId = resolveSessionId(message); if (sessionId == null) { if (logger.isErrorEnabled()) { - logger.error("Couldn't find session id in " + message); + logger.error("Could not find session id in " + message); } return; } @@ -397,8 +398,8 @@ public class SubProtocolWebSocketHandler } catch (Exception ex) { // Shouldn't happen - logger.error("Failed to obtain session.getAcceptedProtocol(). " + - "Will use the default protocol handler (if configured).", ex); + logger.error("Failed to obtain session.getAcceptedProtocol(): " + + "will use the default protocol handler (if configured).", ex); } SubProtocolHandler handler; @@ -465,8 +466,8 @@ public class SubProtocolWebSocketHandler continue; } WebSocketSession session = holder.getSession(); - if (logger.isErrorEnabled()) { - logger.error("No messages received after " + timeSinceCreated + " ms. " + + if (logger.isInfoEnabled()) { + logger.info("No messages received after " + timeSinceCreated + " ms. " + "Closing " + holder.getSession() + "."); } try { @@ -474,8 +475,8 @@ public class SubProtocolWebSocketHandler session.close(CloseStatus.SESSION_NOT_RELIABLE); } catch (Throwable ex) { - if (logger.isErrorEnabled()) { - logger.error("Failure while closing " + session, ex); + if (logger.isWarnEnabled()) { + logger.warn("Failed to close unreliable " + session, ex); } } }