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 7cbeace910 Fix BZ 69845 - Inflater/Deflater throw ISE rather than NPE 
from Java 25
7cbeace910 is described below

commit 7cbeace910dde8a3d7a8ea04c01fd45c3fba0108
Author: Mark Thomas <[email protected]>
AuthorDate: Wed Oct 8 16:36:10 2025 +0100

    Fix BZ 69845 - Inflater/Deflater throw ISE rather than NPE from Java 25
---
 java/org/apache/tomcat/websocket/PerMessageDeflate.java | 6 ++++--
 webapps/docs/changelog.xml                              | 7 +++++++
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/java/org/apache/tomcat/websocket/PerMessageDeflate.java 
b/java/org/apache/tomcat/websocket/PerMessageDeflate.java
index 803842b0c6..b541f29e1b 100644
--- a/java/org/apache/tomcat/websocket/PerMessageDeflate.java
+++ b/java/org/apache/tomcat/websocket/PerMessageDeflate.java
@@ -201,7 +201,8 @@ public class PerMessageDeflate implements Transformation {
                 written = inflater.inflate(dest.array(), dest.arrayOffset() + 
dest.position(), dest.remaining());
             } catch (DataFormatException e) {
                 throw new 
IOException(sm.getString("perMessageDeflate.deflateFailed"), e);
-            } catch (NullPointerException e) {
+            } catch (IllegalStateException | NullPointerException e) {
+                // As of Java 25, the JRE throws an ISE rather than an NPE
                 throw new 
IOException(sm.getString("perMessageDeflate.alreadyClosed"), e);
             }
             dest.position(dest.position() + written);
@@ -361,7 +362,8 @@ public class PerMessageDeflate implements Transformation {
                                 compressedPayload.arrayOffset() + 
compressedPayload.position(),
                                 compressedPayload.remaining(), flush);
                         
compressedPayload.position(compressedPayload.position() + written);
-                    } catch (NullPointerException e) {
+                    } catch (IllegalStateException | NullPointerException e) {
+                        // As of Java 25, the JRE throws an ISE rather than an 
NPE
                         throw new 
IOException(sm.getString("perMessageDeflate.alreadyClosed"), e);
                     }
 
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 78b6fe1571..34aed47c83 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -292,6 +292,13 @@
         port information. (markt)
       </add>
       <!-- Entries for backport and removal before 12.0.0-M1 below this line 
-->
+      <fix>
+        <bug>69845</bug>: When using <code>permessage-deflate</code> with Java
+        25 onwards, handle the underlying <code>Inflater</code> and/or
+        <code>Deflater</code> throwing <code>IllegalStateException</code>
+        when closed rather than <code>NullPointerException</code> as they do in
+        Java 24 and earlier. (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