This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 3ecb6633ff958812635f36a0d1274adba5b0ef1b
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 a6a376a..1de8916 100644
--- a/java/org/apache/tomcat/util/net/LocalStrings.properties
+++ b/java/org/apache/tomcat/util/net/LocalStrings.properties
@@ -154,6 +154,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 ad7d1e3..06fea5f 100644
--- a/java/org/apache/tomcat/util/net/SocketWrapperBase.java
+++ b/java/org/apache/tomcat/util/net/SocketWrapperBase.java
@@ -1395,13 +1395,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;
                     }
@@ -1411,12 +1411,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 f5adf81..a2414ab 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -112,6 +112,10 @@
         the NIO poller thread to exit. This is a regression caused when
         the Poller.events method was refactored. (remm)
       </fix>
+      <add>
+        Provide messages for some <code>SocketTimeoutException</code> instances
+        that did not have one. (markt)
+      </add>
     </changelog>
   </subsection>
   <subsection name="Jasper">


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to