This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 7.0.x in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/7.0.x by this push: new f054e0f Improve logging for failed WebSocket connections f054e0f is described below commit f054e0fb82ba692aaeece2d03a5f71ab386ac56a Author: Mark Thomas <ma...@apache.org> AuthorDate: Wed Jun 3 08:55:54 2020 +0100 Improve logging for failed WebSocket connections Primarily to help with debugging unit test failures. --- .../tomcat/websocket/LocalStrings.properties | 2 +- .../tomcat/websocket/WsWebSocketContainer.java | 24 +++++++--------------- webapps/docs/changelog.xml | 4 ++++ 3 files changed, 12 insertions(+), 18 deletions(-) diff --git a/java/org/apache/tomcat/websocket/LocalStrings.properties b/java/org/apache/tomcat/websocket/LocalStrings.properties index 273920d..00a409c 100644 --- a/java/org/apache/tomcat/websocket/LocalStrings.properties +++ b/java/org/apache/tomcat/websocket/LocalStrings.properties @@ -118,7 +118,7 @@ wsWebSocketContainer.asynchronousSocketChannelFail=Unable to open a connection t wsWebSocketContainer.defaultConfiguratorFail=Failed to create the default configurator wsWebSocketContainer.endpointCreateFail=Failed to create a local endpoint of type [{0}] wsWebSocketContainer.failedAuthentication=Failed to handle HTTP response code [{0}]. Authentication header was not accepted by server. -wsWebSocketContainer.httpRequestFailed=The HTTP request to initiate the WebSocket connection failed +wsWebSocketContainer.httpRequestFailed=The HTTP request to initiate the WebSocket connection to [{0}] failed wsWebSocketContainer.invalidExtensionParameters=The server responded with extension parameters the client is unable to support wsWebSocketContainer.invalidHeader=Unable to parse HTTP header as no colon is present to delimit header name and header value in [{0}]. The header has been skipped. wsWebSocketContainer.invalidStatus=The HTTP response from the server [{0}] did not permit the HTTP upgrade to WebSocket diff --git a/java/org/apache/tomcat/websocket/WsWebSocketContainer.java b/java/org/apache/tomcat/websocket/WsWebSocketContainer.java index c5f1e26..400a2b0 100644 --- a/java/org/apache/tomcat/websocket/WsWebSocketContainer.java +++ b/java/org/apache/tomcat/websocket/WsWebSocketContainer.java @@ -28,9 +28,6 @@ import java.net.SocketAddress; import java.net.URI; import java.net.URISyntaxException; import java.nio.ByteBuffer; -import java.nio.channels.AsynchronousChannelGroup; -import java.nio.channels.AsynchronousSocketChannel; -import java.nio.charset.StandardCharsets; import java.security.KeyStore; import java.util.ArrayList; import java.util.Arrays; @@ -522,26 +519,19 @@ public class WsWebSocketContainer success = true; } catch (ExecutionException e) { - throw new DeploymentException( - sm.getString("wsWebSocketContainer.httpRequestFailed"), e); + throw new DeploymentException(sm.getString("wsWebSocketContainer.httpRequestFailed", path), e); } catch (InterruptedException e) { - throw new DeploymentException( - sm.getString("wsWebSocketContainer.httpRequestFailed"), e); + throw new DeploymentException(sm.getString("wsWebSocketContainer.httpRequestFailed", path), e); } catch (AuthenticationException e) { - throw new DeploymentException( - sm.getString("wsWebSocketContainer.httpRequestFailed"), e); + throw new DeploymentException(sm.getString("wsWebSocketContainer.httpRequestFailed", path), e); } catch (SSLException e) { - throw new DeploymentException( - sm.getString("wsWebSocketContainer.httpRequestFailed"), e); + throw new DeploymentException(sm.getString("wsWebSocketContainer.httpRequestFailed", path), e); } catch (EOFException e) { - throw new DeploymentException( - sm.getString("wsWebSocketContainer.httpRequestFailed"), e); + throw new DeploymentException(sm.getString("wsWebSocketContainer.httpRequestFailed", path), e); } catch (TimeoutException e) { - throw new DeploymentException( - sm.getString("wsWebSocketContainer.httpRequestFailed"), e); + throw new DeploymentException(sm.getString("wsWebSocketContainer.httpRequestFailed", path), e); } catch (URISyntaxException e) { - throw new DeploymentException( - sm.getString("wsWebSocketContainer.httpRequestFailed"), e); + throw new DeploymentException(sm.getString("wsWebSocketContainer.httpRequestFailed", path), e); } finally { if (!success) { channel.close(); diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index 3c2bbee..0aa5c79 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -83,6 +83,10 @@ endpoint path is specified and catch invalid endpoint paths earlier. (markt) </fix> + <add> + Include the target URL in the log message when a WebSocket connection + fails. (markt) + </add> </changelog> </subsection> <subsection name="Other"> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org