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

remm pushed a commit to branch 11.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit e866e6758fdd38e5683b70a19feaf0aa38ebbfb9
Author: remm <r...@apache.org>
AuthorDate: Sun Mar 16 22:47:51 2025 +0100

    Java 17 fixes
---
 java/org/apache/catalina/connector/Request.java    | 16 ++++++++--------
 java/org/apache/coyote/http2/Http2AsyncParser.java | 13 ++++++++-----
 2 files changed, 16 insertions(+), 13 deletions(-)

diff --git a/java/org/apache/catalina/connector/Request.java 
b/java/org/apache/catalina/connector/Request.java
index 8692695993..a53f7bc719 100644
--- a/java/org/apache/catalina/connector/Request.java
+++ b/java/org/apache/catalina/connector/Request.java
@@ -1036,7 +1036,7 @@ public class Request implements HttpServletRequest {
         }
 
         if (!locales.isEmpty()) {
-            return locales.getFirst();
+            return locales.get(0);
         }
 
         return defaultLocale;
@@ -1827,7 +1827,7 @@ public class Request implements HttpServletRequest {
             // is the protocol that must have been selected
             List<Upgrade> upgradeProtocols = 
Upgrade.parse(getHeaders(HTTP_UPGRADE_HEADER_NAME));
             if (upgradeProtocols != null && upgradeProtocols.size() == 1) {
-                result = upgradeProtocols.getFirst().toString();
+                result = upgradeProtocols.get(0).toString();
             }
         }
 
@@ -2413,12 +2413,12 @@ public class Request implements HttpServletRequest {
         parseParts();
 
         if (partsParseException != null) {
-            switch (partsParseException) {
-                case IOException ioException -> throw ioException;
-                case IllegalStateException illegalStateException -> throw 
illegalStateException;
-                case ServletException servletException -> throw 
servletException;
-                default -> {
-                }
+            if (partsParseException instanceof IOException) {
+                throw (IOException) partsParseException;
+            } else if (partsParseException instanceof IllegalStateException) {
+                throw (IllegalStateException) partsParseException;
+            } else if (partsParseException instanceof ServletException) {
+                throw (ServletException) partsParseException;
             }
         }
 
diff --git a/java/org/apache/coyote/http2/Http2AsyncParser.java 
b/java/org/apache/coyote/http2/Http2AsyncParser.java
index 5274374d0d..e1c8170765 100644
--- a/java/org/apache/coyote/http2/Http2AsyncParser.java
+++ b/java/org/apache/coyote/http2/Http2AsyncParser.java
@@ -152,11 +152,14 @@ class Http2AsyncParser extends Http2Parser {
         if (error != null) {
             Throwable error = this.error;
             this.error = null;
-            switch (error) {
-                case Http2Exception http2Exception -> throw http2Exception;
-                case IOException ioException -> throw ioException;
-                case RuntimeException runtimeException -> throw 
runtimeException;
-                case null, default -> throw new RuntimeException(error);
+            if (error instanceof Http2Exception) {
+                throw (Http2Exception) error;
+            } else if (error instanceof IOException) {
+                throw (IOException) error;
+            } else if (error instanceof RuntimeException) {
+                throw (RuntimeException) error;
+            } else {
+                throw new RuntimeException(error);
             }
         }
     }


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

Reply via email to