This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 8.5.x in repository https://gitbox.apache.org/repos/asf/tomcat.git
commit 18cfff56a0ca945c0bc43b033deb8f2480f03301 Author: Mark Thomas <ma...@apache.org> AuthorDate: Thu Oct 29 14:44:23 2020 +0000 Provide exception messages for SocketTimeoutException --- java/org/apache/tomcat/util/net/LocalStrings.properties | 3 +++ java/org/apache/tomcat/util/net/SocketWrapperBase.java | 15 +++++++++++++-- webapps/docs/changelog.xml | 4 ++++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/java/org/apache/tomcat/util/net/LocalStrings.properties b/java/org/apache/tomcat/util/net/LocalStrings.properties index b6d7861..17c3309 100644 --- a/java/org/apache/tomcat/util/net/LocalStrings.properties +++ b/java/org/apache/tomcat/util/net/LocalStrings.properties @@ -132,6 +132,9 @@ socket.apr.write.error=Unexpected error [{0}] writing data to the APR/native soc socket.closed=The socket associated with this connection has been closed. socket.sslreneg=Exception re-negotiating SSL connection +socketWrapper.readTimeout=Read timeout +socketWrapper.writeTimeout=Write timeout + sslHostConfig.certificate.notype=Multiple certificates were specified and at least one is missing the required attribute type sslHostConfig.certificateVerificationInvalid=The certificate verification value [{0}] is not recognised sslHostConfig.fileNotFound=Configured file [{0}] does not exist diff --git a/java/org/apache/tomcat/util/net/SocketWrapperBase.java b/java/org/apache/tomcat/util/net/SocketWrapperBase.java index d044a47..dd1da55 100644 --- a/java/org/apache/tomcat/util/net/SocketWrapperBase.java +++ b/java/org/apache/tomcat/util/net/SocketWrapperBase.java @@ -1407,13 +1407,13 @@ public abstract class SocketWrapperBase<E> { state.wait(unit.toMillis(timeout)); if (state.state == CompletionState.PENDING) { if (handler != null && state.callHandler.compareAndSet(true, false)) { - handler.failed(new SocketTimeoutException(), attachment); + handler.failed(new SocketTimeoutException(getTimeoutMsg(read)), attachment); } return CompletionState.ERROR; } } catch (InterruptedException e) { if (handler != null && state.callHandler.compareAndSet(true, false)) { - handler.failed(new SocketTimeoutException(), attachment); + handler.failed(new SocketTimeoutException(getTimeoutMsg(read)), attachment); } return CompletionState.ERROR; } @@ -1423,12 +1423,23 @@ public abstract class SocketWrapperBase<E> { return state.state; } + + private String getTimeoutMsg(boolean read) { + if (read) { + return sm.getString("socketWrapper.readTimeout"); + } else { + return sm.getString("socketWrapper.writeTimeout"); + } + } + + protected abstract <A> OperationState<A> newOperationState(boolean read, ByteBuffer[] buffers, int offset, int length, BlockingMode block, long timeout, TimeUnit unit, A attachment, CompletionCheck check, CompletionHandler<Long, ? super A> handler, Semaphore semaphore, VectoredIOCompletionHandler<A> completion); + // --------------------------------------------------------- Utility methods protected static int transfer(byte[] from, int offset, int length, ByteBuffer to) { diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index 606603d..7f7caf8 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -91,6 +91,10 @@ <bug>63362</bug>: Add collection of statistics for HTTP/2, WebSocket and connections upgraded via the HTTP upgrade mechanism. (markt) </fix> + <add> + Provide messages for some <code>SocketTimeoutException</code> instances + that did not have one. (markt) + </add> </changelog> </subseciton> <subsection name="Web applications"> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org