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

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


The following commit(s) were added to refs/heads/main by this push:
     new 24f1d72bab Partial fix for BZ 69920. Writer and OutputStream.
24f1d72bab is described below

commit 24f1d72bab72e4d2ab4126c1f0c1badeeb0048d1
Author: Mark Thomas <[email protected]>
AuthorDate: Wed Jan 14 08:06:35 2026 +0000

    Partial fix for BZ 69920. Writer and OutputStream.
    
    Javadoc for Writer is clear IOException is thrown if called when closed
    Javadoc for OutputStream suggests throwing IOE if used when closed. Switch
    OutputStream to IOE for consistency with Writer.
    
    https://bz.apache.org/bugzilla/show_bug.cgi?id=69920
---
 java/org/apache/tomcat/websocket/WsRemoteEndpointImplBase.java | 8 ++++----
 webapps/docs/changelog.xml                                     | 7 +++++++
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/java/org/apache/tomcat/websocket/WsRemoteEndpointImplBase.java 
b/java/org/apache/tomcat/websocket/WsRemoteEndpointImplBase.java
index 1b1b45bb51..a277aa6a0e 100644
--- a/java/org/apache/tomcat/websocket/WsRemoteEndpointImplBase.java
+++ b/java/org/apache/tomcat/websocket/WsRemoteEndpointImplBase.java
@@ -1048,9 +1048,9 @@ public abstract class WsRemoteEndpointImplBase implements 
RemoteEndpoint {
             doWrite(true);
         }
 
-        private void checkOpen() {
+        private void checkOpen() throws IOException {
             if (closed) {
-                throw new 
IllegalStateException(sm.getString("wsRemoteEndpoint.closedOutputStream"));
+                throw new 
IOException(sm.getString("wsRemoteEndpoint.closedOutputStream"));
             }
         }
 
@@ -1126,9 +1126,9 @@ public abstract class WsRemoteEndpointImplBase implements 
RemoteEndpoint {
             doWrite(true);
         }
 
-        private void checkOpen() {
+        private void checkOpen() throws IOException {
             if (closed) {
-                throw new 
IllegalStateException(sm.getString("wsRemoteEndpoint.closedWriter"));
+                throw new 
IOException(sm.getString("wsRemoteEndpoint.closedWriter"));
             }
         }
 
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index ac2a4372e2..25f40205aa 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -374,6 +374,13 @@
         port information. (markt)
       </add>
       <!-- Entries for backport and removal before 12.0.0-M1 below this line 
-->
+      <fix>
+        <bug>69920</bug>: When attempting to write to a closed
+        <code>Writer</code> or <code>OutputStream</code> obtained from a
+        WebSocket session, throw an <code>IOException</code> rather than an
+        <code>IllegalStateExcpetion</code> as required by <code>Writer</code>
+        and strongly suggested by <code>OutputStream</code>. (markt)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Web applications">


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to