You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2024/08/07 18:34:33 UTC
(tomcat) branch 10.1.x updated (4ef72f858b -> b1efcf9142)
This is an automated email from the ASF dual-hosted git repository.
markt pushed a change to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
from 4ef72f858b Update Javadoc links to reference Java 11
new 13587bbb80 Add trace logging for receipt of WebSocket session close message
new 41c425bed3 If a blocking message write times out, don't write again before throwing
new b1efcf9142 Encoding error on send should not automatically close the connection
The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
java/org/apache/tomcat/websocket/LocalStrings.properties | 1 +
.../tomcat/websocket/WsRemoteEndpointImplClient.java | 1 +
java/org/apache/tomcat/websocket/WsSession.java | 3 +++
.../apache/tomcat/websocket/pojo/LocalStrings.properties | 2 ++
.../tomcat/websocket/pojo/PojoMessageHandlerBase.java | 15 ++++++++++++++-
webapps/docs/changelog.xml | 14 ++++++++++++++
6 files changed, 35 insertions(+), 1 deletion(-)
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
(tomcat) 01/03: Add trace logging for receipt of WebSocket session close message
Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
commit 13587bbb80df5f3f874eece098d503d6024e3406
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Wed Aug 7 16:04:22 2024 +0100
Add trace logging for receipt of WebSocket session close message
---
java/org/apache/tomcat/websocket/LocalStrings.properties | 1 +
java/org/apache/tomcat/websocket/WsSession.java | 3 +++
2 files changed, 4 insertions(+)
diff --git a/java/org/apache/tomcat/websocket/LocalStrings.properties b/java/org/apache/tomcat/websocket/LocalStrings.properties
index 79b8472007..6948b7514d 100644
--- a/java/org/apache/tomcat/websocket/LocalStrings.properties
+++ b/java/org/apache/tomcat/websocket/LocalStrings.properties
@@ -116,6 +116,7 @@ wsSession.instanceCreateFailed=Endpoint instance creation failed
wsSession.instanceNew=Endpoint instance registration failed
wsSession.invalidHandlerTypePong=A pong message handler must implement MessageHandler.Whole
wsSession.messageFailed=Unable to write the complete message as the WebSocket connection has been closed
+wsSession.onClose.entry=Close message with reason [{0}] received for session [{1}] in state [{2}]
wsSession.removeHandlerFailed=Unable to remove the handler [{0}] as it was not registered with this session
wsSession.sendCloseFail=Failed to send close message for session [{0}] to remote endpoint
wsSession.timeout=The WebSocket session [{0}] idle timeout expired
diff --git a/java/org/apache/tomcat/websocket/WsSession.java b/java/org/apache/tomcat/websocket/WsSession.java
index 7b66df3374..f1ffbc2002 100644
--- a/java/org/apache/tomcat/websocket/WsSession.java
+++ b/java/org/apache/tomcat/websocket/WsSession.java
@@ -621,6 +621,9 @@ public class WsSession implements Session {
* @param closeReason The reason contained within the received close message.
*/
public void onClose(CloseReason closeReason) {
+ if (log.isTraceEnabled()) {
+ log.trace(sm.getString("wsSession.onClose.entry", closeReason, getId(), state));
+ }
if (state.compareAndSet(State.OPEN, State.CLOSING)) {
// Standard close.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
(tomcat) 03/03: Encoding error on send should not automatically close the connection
Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
commit b1efcf9142ced3b8f98adecd4372d69605275639
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Wed Aug 7 17:23:32 2024 +0100
Encoding error on send should not automatically close the connection
---
.../apache/tomcat/websocket/pojo/LocalStrings.properties | 2 ++
.../tomcat/websocket/pojo/PojoMessageHandlerBase.java | 15 ++++++++++++++-
webapps/docs/changelog.xml | 6 ++++++
3 files changed, 22 insertions(+), 1 deletion(-)
diff --git a/java/org/apache/tomcat/websocket/pojo/LocalStrings.properties b/java/org/apache/tomcat/websocket/pojo/LocalStrings.properties
index afefa8c8af..c9ef340cba 100644
--- a/java/org/apache/tomcat/websocket/pojo/LocalStrings.properties
+++ b/java/org/apache/tomcat/websocket/pojo/LocalStrings.properties
@@ -19,6 +19,8 @@ pojoEndpointBase.onError=No error handling configured for [{0}] and the followin
pojoEndpointBase.onErrorFail=Failed to call onError method of POJO end point for POJO of type [{0}]
pojoEndpointBase.onOpenFail=Failed to call onOpen method of POJO end point for POJO of type [{0}]
+pojoMessageHandlerBase.encodeFail=Encoding failed for POJO of tyoe [{0}] in session [{1}]
+
pojoMessageHandlerWhole.decodeIoFail=IO error while decoding message
pojoMessageHandlerWhole.maxBufferSize=The maximum supported message size for this implementation is Integer.MAX_VALUE
diff --git a/java/org/apache/tomcat/websocket/pojo/PojoMessageHandlerBase.java b/java/org/apache/tomcat/websocket/pojo/PojoMessageHandlerBase.java
index 99e1a1efd9..b52fbbba20 100644
--- a/java/org/apache/tomcat/websocket/pojo/PojoMessageHandlerBase.java
+++ b/java/org/apache/tomcat/websocket/pojo/PojoMessageHandlerBase.java
@@ -25,8 +25,12 @@ import jakarta.websocket.MessageHandler;
import jakarta.websocket.RemoteEndpoint;
import jakarta.websocket.Session;
+import org.apache.juli.logging.Log;
+import org.apache.juli.logging.LogFactory;
import org.apache.tomcat.util.ExceptionUtils;
+import org.apache.tomcat.util.res.StringManager;
import org.apache.tomcat.websocket.WrappedMessageHandler;
+import org.apache.tomcat.websocket.WsSession;
/**
* Common implementation code for the POJO message handlers.
@@ -35,6 +39,9 @@ import org.apache.tomcat.websocket.WrappedMessageHandler;
*/
public abstract class PojoMessageHandlerBase<T> implements WrappedMessageHandler {
+ private final Log log = LogFactory.getLog(PojoMessageHandlerBase.class); // must not be static
+ private static final StringManager sm = StringManager.getManager(PojoMessageHandlerBase.class);
+
protected final Object pojo;
protected final Method method;
protected final Session session;
@@ -110,7 +117,13 @@ public abstract class PojoMessageHandlerBase<T> implements WrappedMessageHandler
protected final void handlePojoMethodException(Throwable t) {
t = ExceptionUtils.unwrapInvocationTargetException(t);
ExceptionUtils.handleThrowable(t);
- if (t instanceof RuntimeException) {
+ if (t instanceof EncodeException) {
+ if (log.isDebugEnabled()) {
+ log.debug(sm.getString("pojoMessageHandlerBase.encodeFail", pojo.getClass().getName(), session.getId()),
+ t);
+ }
+ ((WsSession) session).getLocal().onError(session, t);
+ } else if (t instanceof RuntimeException) {
throw (RuntimeException) t;
} else {
throw new RuntimeException(t.getMessage(), t);
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index ecb625f525..2bf7fccf50 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -119,6 +119,12 @@
If a blocking message write exceeds the timeout, don't attempt the write
again before throwing the exception. (markt)
</fix>
+ <fix>
+ An EncodeException being thrown during a message write should not
+ automatically cause the connection to close. The application should
+ handle the exception and make the decision whether or not to close the
+ connection. (markt)
+ </fix>
</changelog>
</subsection>
<subsection name="Web applications">
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
(tomcat) 02/03: If a blocking message write times out, don't write again before throwing
Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
commit 41c425bed3df89b3c638c0b4207b9b8dd1474f09
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Wed Aug 7 16:14:33 2024 +0100
If a blocking message write times out, don't write again before throwing
---
java/org/apache/tomcat/websocket/WsRemoteEndpointImplClient.java | 1 +
webapps/docs/changelog.xml | 8 ++++++++
2 files changed, 9 insertions(+)
diff --git a/java/org/apache/tomcat/websocket/WsRemoteEndpointImplClient.java b/java/org/apache/tomcat/websocket/WsRemoteEndpointImplClient.java
index 5f0cc67fc3..a66e585ac9 100644
--- a/java/org/apache/tomcat/websocket/WsRemoteEndpointImplClient.java
+++ b/java/org/apache/tomcat/websocket/WsRemoteEndpointImplClient.java
@@ -56,6 +56,7 @@ public class WsRemoteEndpointImplClient extends WsRemoteEndpointImplBase {
if (timeout < 0) {
SendResult sr = new SendResult(new IOException(sm.getString("wsRemoteEndpoint.writeTimeout")));
handler.onResult(sr);
+ return;
}
}
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 18790f31e4..ecb625f525 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -113,6 +113,14 @@
</fix>
</changelog>
</subsection>
+ <subsection name="WebSocket">
+ <changelog>
+ <fix>
+ If a blocking message write exceeds the timeout, don't attempt the write
+ again before throwing the exception. (markt)
+ </fix>
+ </changelog>
+ </subsection>
<subsection name="Web applications">
<changelog>
<fix>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org