[tomcat] branch main updated: Add JreCompat for Java 22

2023-08-04 Thread remm
This is an automated email from the ASF dual-hosted git repository.

remm 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 7e6af38a62 Add JreCompat for Java 22
7e6af38a62 is described below

commit 7e6af38a62b6354869f979ac718a270b70e6ec4d
Author: remm 
AuthorDate: Fri Aug 4 09:13:16 2023 +0200

Add JreCompat for Java 22

Actually the one with the non preview Panama.
---
 .../org/apache/tomcat/util/compat/Jre22Compat.java | 54 ++
 java/org/apache/tomcat/util/compat/JreCompat.java  | 16 ++-
 .../tomcat/util/compat/LocalStrings.properties | 17 +++
 3 files changed, 86 insertions(+), 1 deletion(-)

diff --git a/java/org/apache/tomcat/util/compat/Jre22Compat.java 
b/java/org/apache/tomcat/util/compat/Jre22Compat.java
new file mode 100644
index 00..0b690164b6
--- /dev/null
+++ b/java/org/apache/tomcat/util/compat/Jre22Compat.java
@@ -0,0 +1,54 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.tomcat.util.compat;
+
+import java.lang.reflect.Method;
+
+import org.apache.juli.logging.Log;
+import org.apache.juli.logging.LogFactory;
+import org.apache.tomcat.util.res.StringManager;
+
+public class Jre22Compat extends JreCompat {
+
+private static final Log log = LogFactory.getLog(Jre22Compat.class);
+private static final StringManager sm = 
StringManager.getManager(Jre22Compat.class);
+
+private static final boolean hasPanama;
+
+
+static {
+Class c1 = null;
+Method m1 = null;
+
+try {
+c1 = Class.forName("java.lang.foreign.MemorySegment");
+m1 = c1.getMethod("getString", long.class);
+} catch (ClassNotFoundException e) {
+// Must be pre-Java 22
+log.debug(sm.getString("jre22Compat.javaPre22"), e);
+} catch (ReflectiveOperationException e) {
+// Should never happen
+log.error(sm.getString("jre22Compat.unexpected"), e);
+}
+hasPanama = (m1 != null);
+}
+
+static boolean isSupported() {
+return hasPanama;
+}
+
+}
diff --git a/java/org/apache/tomcat/util/compat/JreCompat.java 
b/java/org/apache/tomcat/util/compat/JreCompat.java
index 334115acc3..7273b0b233 100644
--- a/java/org/apache/tomcat/util/compat/JreCompat.java
+++ b/java/org/apache/tomcat/util/compat/JreCompat.java
@@ -25,6 +25,7 @@ public class JreCompat {
 
 private static final JreCompat instance;
 private static final boolean graalAvailable;
+private static final boolean jre22Available;
 
 static {
 boolean result = false;
@@ -39,7 +40,13 @@ public class JreCompat {
 graalAvailable = result || 
System.getProperty("org.graalvm.nativeimage.imagecode") != null;
 
 // This is Tomcat 11.0.x with a minimum Java version of Java 21.
-instance = new JreCompat();
+if (Jre22Compat.isSupported()) {
+instance = new Jre22Compat();
+jre22Available = true;
+} else {
+instance = new JreCompat();
+jre22Available = false;
+}
 }
 
 
@@ -51,4 +58,11 @@ public class JreCompat {
 public static boolean isGraalAvailable() {
 return graalAvailable;
 }
+
+
+public static boolean isJre22Available() {
+return jre22Available;
+}
+
+
 }
diff --git a/java/org/apache/tomcat/util/compat/LocalStrings.properties 
b/java/org/apache/tomcat/util/compat/LocalStrings.properties
new file mode 100644
index 00..e3bbf2b43b
--- /dev/null
+++ b/java/org/apache/tomcat/util/compat/LocalStrings.properties
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or 

[tomcat] branch 10.1.x updated: Add JreCompat for Java 22

2023-08-04 Thread remm
This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/10.1.x by this push:
 new 0726a5a581 Add JreCompat for Java 22
0726a5a581 is described below

commit 0726a5a581ec80e381e23eb36c021a50319fc9df
Author: remm 
AuthorDate: Fri Aug 4 09:20:18 2023 +0200

Add JreCompat for Java 22
---
 .../org/apache/tomcat/util/compat/Jre22Compat.java | 54 ++
 java/org/apache/tomcat/util/compat/JreCompat.java  | 18 +++-
 .../tomcat/util/compat/LocalStrings.properties |  3 ++
 3 files changed, 74 insertions(+), 1 deletion(-)

diff --git a/java/org/apache/tomcat/util/compat/Jre22Compat.java 
b/java/org/apache/tomcat/util/compat/Jre22Compat.java
new file mode 100644
index 00..486cc8a804
--- /dev/null
+++ b/java/org/apache/tomcat/util/compat/Jre22Compat.java
@@ -0,0 +1,54 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.tomcat.util.compat;
+
+import java.lang.reflect.Method;
+
+import org.apache.juli.logging.Log;
+import org.apache.juli.logging.LogFactory;
+import org.apache.tomcat.util.res.StringManager;
+
+public class Jre22Compat extends Jre21Compat {
+
+private static final Log log = LogFactory.getLog(Jre22Compat.class);
+private static final StringManager sm = 
StringManager.getManager(Jre22Compat.class);
+
+private static final boolean hasPanama;
+
+
+static {
+Class c1 = null;
+Method m1 = null;
+
+try {
+c1 = Class.forName("java.lang.foreign.MemorySegment");
+m1 = c1.getMethod("getString", long.class);
+} catch (ClassNotFoundException e) {
+// Must be pre-Java 22
+log.debug(sm.getString("jre22Compat.javaPre22"), e);
+} catch (ReflectiveOperationException e) {
+// Should never happen
+log.error(sm.getString("jre22Compat.unexpected"), e);
+}
+hasPanama = (m1 != null);
+}
+
+static boolean isSupported() {
+return hasPanama;
+}
+
+}
diff --git a/java/org/apache/tomcat/util/compat/JreCompat.java 
b/java/org/apache/tomcat/util/compat/JreCompat.java
index 79d6a15ed9..86f540bfec 100644
--- a/java/org/apache/tomcat/util/compat/JreCompat.java
+++ b/java/org/apache/tomcat/util/compat/JreCompat.java
@@ -35,6 +35,7 @@ public class JreCompat {
 private static final boolean jre16Available;
 private static final boolean jre19Available;
 private static final boolean jre21Available;
+private static final boolean jre22Available;
 private static final StringManager sm = 
StringManager.getManager(JreCompat.class);
 
 static {
@@ -51,23 +52,33 @@ public class JreCompat {
 
 // This is Tomcat 10.1.x with a minimum Java version of Java 11.
 // Look for the highest supported JVM first
-if (Jre21Compat.isSupported()) {
+if (Jre22Compat.isSupported()) {
+instance = new Jre22Compat();
+jre22Available = true;
+jre21Available = true;
+jre19Available = true;
+jre16Available = true;
+} else if (Jre21Compat.isSupported()) {
 instance = new Jre21Compat();
+jre22Available = false;
 jre21Available = true;
 jre19Available = true;
 jre16Available = true;
 } else if (Jre19Compat.isSupported()) {
 instance = new Jre19Compat();
+jre22Available = false;
 jre21Available = false;
 jre19Available = true;
 jre16Available = true;
 } else if (Jre16Compat.isSupported()) {
 instance = new Jre16Compat();
+jre22Available = false;
 jre21Available = false;
 jre19Available = false;
 jre16Available = true;
 } else {
 instance = new JreCompat();
+jre22Available = false;
 jre21Available = false;
 jre19Available = false;
 jre16Available = false;
@@ -100,6 +111,11 @@ public class JreCompat {
 }
 
 
+public static boolean isJre22Available

[tomcat] branch main updated: Pass through ciphers referring to an OpenSSL profile

2023-08-04 Thread remm
This is an automated email from the ASF dual-hosted git repository.

remm 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 becddcf60a Pass through ciphers referring to an OpenSSL profile
becddcf60a is described below

commit becddcf60a170e195ca0356a877b7227809b6a2f
Author: remm 
AuthorDate: Fri Aug 4 10:27:52 2023 +0200

Pass through ciphers referring to an OpenSSL profile

Avoids the error trying to parse it.
---
 java/org/apache/tomcat/util/net/SSLUtilBase.java | 16 +++-
 webapps/docs/changelog.xml   |  5 +
 2 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/java/org/apache/tomcat/util/net/SSLUtilBase.java 
b/java/org/apache/tomcat/util/net/SSLUtilBase.java
index 72161e9238..bdbf893f6a 100644
--- a/java/org/apache/tomcat/util/net/SSLUtilBase.java
+++ b/java/org/apache/tomcat/util/net/SSLUtilBase.java
@@ -122,11 +122,17 @@ public abstract class SSLUtilBase implements SSLUtil {
 
sslHostConfig.setTls13RenegotiationAvailable(isTls13RenegAuthAvailable());
 
 // Calculate the enabled ciphers
-List configuredCiphers = sslHostConfig.getJsseCipherNames();
-Set implementedCiphers = getImplementedCiphers();
-List enabledCiphers =
-getEnabled("ciphers", getLog(), false, configuredCiphers, 
implementedCiphers);
-this.enabledCiphers = enabledCiphers.toArray(new String[0]);
+if (sslHostConfig.getCiphers().startsWith("PROFILE=")) {
+// OpenSSL profiles
+// TODO: sslHostConfig can query that with Panama, but skip for now
+this.enabledCiphers = new String[0];
+} else {
+List configuredCiphers = 
sslHostConfig.getJsseCipherNames();
+Set implementedCiphers = getImplementedCiphers();
+List enabledCiphers =
+getEnabled("ciphers", getLog(), false, configuredCiphers, 
implementedCiphers);
+this.enabledCiphers = enabledCiphers.toArray(new String[0]);
+}
 }
 
 
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 6ee6b5de0e..031e7df7bf 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -155,6 +155,11 @@
 Refactor HTTP/2 implementation to reduce pinning when using virtual
 threads. (markt)
   
+  
+Pass through ciphers referring to an OpenSSL profile, such as
+PROFILE=SYSTEM instead of producing an error trying to
+parse it. (remm)
+  
 
   
   


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



[tomcat] branch 9.0.x updated: Add JreCompat for Java 22

2023-08-04 Thread remm
This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/9.0.x by this push:
 new 43bdf2f71c Add JreCompat for Java 22
43bdf2f71c is described below

commit 43bdf2f71cb904483d39b91f5955ae42344ff0d2
Author: remm 
AuthorDate: Fri Aug 4 09:28:32 2023 +0200

Add JreCompat for Java 22
---
 .../org/apache/tomcat/util/compat/Jre22Compat.java | 54 ++
 java/org/apache/tomcat/util/compat/JreCompat.java  | 20 +++-
 .../tomcat/util/compat/LocalStrings.properties |  3 ++
 3 files changed, 76 insertions(+), 1 deletion(-)

diff --git a/java/org/apache/tomcat/util/compat/Jre22Compat.java 
b/java/org/apache/tomcat/util/compat/Jre22Compat.java
new file mode 100644
index 00..486cc8a804
--- /dev/null
+++ b/java/org/apache/tomcat/util/compat/Jre22Compat.java
@@ -0,0 +1,54 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.tomcat.util.compat;
+
+import java.lang.reflect.Method;
+
+import org.apache.juli.logging.Log;
+import org.apache.juli.logging.LogFactory;
+import org.apache.tomcat.util.res.StringManager;
+
+public class Jre22Compat extends Jre21Compat {
+
+private static final Log log = LogFactory.getLog(Jre22Compat.class);
+private static final StringManager sm = 
StringManager.getManager(Jre22Compat.class);
+
+private static final boolean hasPanama;
+
+
+static {
+Class c1 = null;
+Method m1 = null;
+
+try {
+c1 = Class.forName("java.lang.foreign.MemorySegment");
+m1 = c1.getMethod("getString", long.class);
+} catch (ClassNotFoundException e) {
+// Must be pre-Java 22
+log.debug(sm.getString("jre22Compat.javaPre22"), e);
+} catch (ReflectiveOperationException e) {
+// Should never happen
+log.error(sm.getString("jre22Compat.unexpected"), e);
+}
+hasPanama = (m1 != null);
+}
+
+static boolean isSupported() {
+return hasPanama;
+}
+
+}
diff --git a/java/org/apache/tomcat/util/compat/JreCompat.java 
b/java/org/apache/tomcat/util/compat/JreCompat.java
index c0ac778ba2..0c1840c90b 100644
--- a/java/org/apache/tomcat/util/compat/JreCompat.java
+++ b/java/org/apache/tomcat/util/compat/JreCompat.java
@@ -51,6 +51,7 @@ public class JreCompat {
 private static final boolean jre16Available;
 private static final boolean jre19Available;
 private static final boolean jre21Available;
+private static final boolean jre22Available;
 private static final StringManager sm = 
StringManager.getManager(JreCompat.class);
 
 protected static final Method setApplicationProtocolsMethod;
@@ -70,32 +71,44 @@ public class JreCompat {
 
 // This is Tomcat 9 with a minimum Java version of Java 8.
 // Look for the highest supported JVM first
-if (Jre21Compat.isSupported()) {
+if (Jre22Compat.isSupported()) {
+instance = new Jre22Compat();
+jre22Available = true;
+jre21Available = true;
+jre19Available = true;
+jre16Available = true;
+jre9Available = true;
+} else if (Jre21Compat.isSupported()) {
 instance = new Jre21Compat();
+jre22Available = false;
 jre21Available = true;
 jre19Available = true;
 jre16Available = true;
 jre9Available = true;
 } else if (Jre19Compat.isSupported()) {
 instance = new Jre19Compat();
+jre22Available = false;
 jre21Available = false;
 jre19Available = true;
 jre16Available = true;
 jre9Available = true;
 } else if (Jre16Compat.isSupported()) {
 instance = new Jre16Compat();
+jre22Available = false;
 jre21Available = false;
 jre19Available = false;
 jre16Available = true;
 jre9Available = true;
 } else if (Jre9Compat.isSupported()) {
 instance = new Jre9Compat();
+jre22Available = fal

[tomcat] branch 10.1.x updated: Pass through ciphers referring to an OpenSSL profile

2023-08-04 Thread remm
This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/10.1.x by this push:
 new f90c70f11f Pass through ciphers referring to an OpenSSL profile
f90c70f11f is described below

commit f90c70f11f9efbe0d14c918a4df2f1e51404a9f6
Author: remm 
AuthorDate: Fri Aug 4 10:27:52 2023 +0200

Pass through ciphers referring to an OpenSSL profile

Avoids the error trying to parse it.
---
 java/org/apache/tomcat/util/net/SSLUtilBase.java | 16 +++-
 webapps/docs/changelog.xml   |  5 +
 2 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/java/org/apache/tomcat/util/net/SSLUtilBase.java 
b/java/org/apache/tomcat/util/net/SSLUtilBase.java
index 72161e9238..bdbf893f6a 100644
--- a/java/org/apache/tomcat/util/net/SSLUtilBase.java
+++ b/java/org/apache/tomcat/util/net/SSLUtilBase.java
@@ -122,11 +122,17 @@ public abstract class SSLUtilBase implements SSLUtil {
 
sslHostConfig.setTls13RenegotiationAvailable(isTls13RenegAuthAvailable());
 
 // Calculate the enabled ciphers
-List configuredCiphers = sslHostConfig.getJsseCipherNames();
-Set implementedCiphers = getImplementedCiphers();
-List enabledCiphers =
-getEnabled("ciphers", getLog(), false, configuredCiphers, 
implementedCiphers);
-this.enabledCiphers = enabledCiphers.toArray(new String[0]);
+if (sslHostConfig.getCiphers().startsWith("PROFILE=")) {
+// OpenSSL profiles
+// TODO: sslHostConfig can query that with Panama, but skip for now
+this.enabledCiphers = new String[0];
+} else {
+List configuredCiphers = 
sslHostConfig.getJsseCipherNames();
+Set implementedCiphers = getImplementedCiphers();
+List enabledCiphers =
+getEnabled("ciphers", getLog(), false, configuredCiphers, 
implementedCiphers);
+this.enabledCiphers = enabledCiphers.toArray(new String[0]);
+}
 }
 
 
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index d19f6b45e4..fd9df27fe5 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -134,6 +134,11 @@
 Refactor HTTP/2 implementation to reduce pinning when using virtual
 threads. (markt)
   
+  
+Pass through ciphers referring to an OpenSSL profile, such as
+PROFILE=SYSTEM instead of producing an error trying to
+parse it. (remm)
+  
 
   
   


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



[tomcat] branch 9.0.x updated: Pass through ciphers referring to an OpenSSL profile

2023-08-04 Thread remm
This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/9.0.x by this push:
 new 267e8d9270 Pass through ciphers referring to an OpenSSL profile
267e8d9270 is described below

commit 267e8d9270cabdd6596b981d8ae7ea029c3f05dd
Author: remm 
AuthorDate: Fri Aug 4 10:27:52 2023 +0200

Pass through ciphers referring to an OpenSSL profile

Avoids the error trying to parse it.
---
 java/org/apache/tomcat/util/net/SSLUtilBase.java | 16 +++-
 webapps/docs/changelog.xml   |  5 +
 2 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/java/org/apache/tomcat/util/net/SSLUtilBase.java 
b/java/org/apache/tomcat/util/net/SSLUtilBase.java
index 72161e9238..bdbf893f6a 100644
--- a/java/org/apache/tomcat/util/net/SSLUtilBase.java
+++ b/java/org/apache/tomcat/util/net/SSLUtilBase.java
@@ -122,11 +122,17 @@ public abstract class SSLUtilBase implements SSLUtil {
 
sslHostConfig.setTls13RenegotiationAvailable(isTls13RenegAuthAvailable());
 
 // Calculate the enabled ciphers
-List configuredCiphers = sslHostConfig.getJsseCipherNames();
-Set implementedCiphers = getImplementedCiphers();
-List enabledCiphers =
-getEnabled("ciphers", getLog(), false, configuredCiphers, 
implementedCiphers);
-this.enabledCiphers = enabledCiphers.toArray(new String[0]);
+if (sslHostConfig.getCiphers().startsWith("PROFILE=")) {
+// OpenSSL profiles
+// TODO: sslHostConfig can query that with Panama, but skip for now
+this.enabledCiphers = new String[0];
+} else {
+List configuredCiphers = 
sslHostConfig.getJsseCipherNames();
+Set implementedCiphers = getImplementedCiphers();
+List enabledCiphers =
+getEnabled("ciphers", getLog(), false, configuredCiphers, 
implementedCiphers);
+this.enabledCiphers = enabledCiphers.toArray(new String[0]);
+}
 }
 
 
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index e0b4ed7b94..d644398268 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -155,6 +155,11 @@
 Refactor HTTP/2 implementation to reduce pinning when using virtual
 threads. (markt)
   
+  
+Pass through ciphers referring to an OpenSSL profile, such as
+PROFILE=SYSTEM instead of producing an error trying to
+parse it. (remm)
+  
 
   
   


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



[Bug 66841] Memory leak from cancelled async http/2 streams

2023-08-04 Thread bugzilla
https://bz.apache.org/bugzilla/show_bug.cgi?id=66841

--- Comment #2 from Mark Thomas  ---
Thanks of the report and the research. That all makes sense.

While previous refactoring of error handling has improved things, there are
still aspects that I don't like and one of them is CoyoteResponse.setError()
returning a boolean value. It looks like that is going to have to be addressed
as part of the fix for this issue.

My plan is to proceed as follows:
- create a test case for this bug based on the description
- fix this bug by refactoring AsyncStateMachine.asyncError to be a NO-OP for
the second and subsequent calls within an async cycle (cycle == generation in
the code)

If time allows, I may complete so other refactoring I have in mind for error
handling.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



[Bug 66592] Support for HTTPS proxy in websocket client

2023-08-04 Thread bugzilla
https://bz.apache.org/bugzilla/show_bug.cgi?id=66592

--- Comment #7 from radhika.j...@veritas.com  ---
Hi Mark, Any update on this?

-- 
You are receiving this mail because:
You are the assignee for the bug.
-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



[tomcat] branch main updated (becddcf60a -> a33a493ef7)

2023-08-04 Thread markt
This is an automated email from the ASF dual-hosted git repository.

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


from becddcf60a Pass through ciphers referring to an OpenSSL profile
 new 082b325063 Fix BZ 66841 - ensure AsyncListener.onError is called after 
an error
 new 89675ba078 Mark method Deprecated that returns unused valid
 new a33a493ef7 Remove unused return value

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/catalina/connector/Response.java |   8 +-
 java/org/apache/coyote/AbstractProcessor.java|   4 +-
 java/org/apache/coyote/AsyncStateMachine.java|  22 +++
 java/org/apache/coyote/LocalStrings.properties   |   2 +
 java/org/apache/coyote/Response.java |   8 +-
 test/org/apache/coyote/http2/TestAsyncError.java | 170 +++
 6 files changed, 202 insertions(+), 12 deletions(-)
 create mode 100644 test/org/apache/coyote/http2/TestAsyncError.java


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



[tomcat] 02/03: Mark method Deprecated that returns unused valid

2023-08-04 Thread markt
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

commit 89675ba0782f9b6b55b83685d2441dc943c43244
Author: Mark Thomas 
AuthorDate: Fri Aug 4 14:55:28 2023 +0100

Mark method Deprecated that returns unused valid
---
 java/org/apache/catalina/connector/Response.java | 3 +++
 java/org/apache/coyote/Response.java | 3 +++
 2 files changed, 6 insertions(+)

diff --git a/java/org/apache/catalina/connector/Response.java 
b/java/org/apache/catalina/connector/Response.java
index 3fc3a982fb..6cf4893d0e 100644
--- a/java/org/apache/catalina/connector/Response.java
+++ b/java/org/apache/catalina/connector/Response.java
@@ -372,7 +372,10 @@ public class Response implements HttpServletResponse {
  * Set the error flag.
  *
  * @return false if the error flag was already set
+ *
+ * @deprecated This method will be changed to return void in Tomcat 11 
onwards
  */
+@Deprecated
 public boolean setError() {
 return getCoyoteResponse().setError();
 }
diff --git a/java/org/apache/coyote/Response.java 
b/java/org/apache/coyote/Response.java
index af26e5f6d9..64920c2993 100644
--- a/java/org/apache/coyote/Response.java
+++ b/java/org/apache/coyote/Response.java
@@ -307,7 +307,10 @@ public final class Response {
  * Set the error flag.
  *
  * @return false if the error flag was already set
+ *
+ * @deprecated This method will be changed to return void in Tomcat 11 
onwards
  */
+@Deprecated
 public boolean setError() {
 return errorState.compareAndSet(0, 1);
 }


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



[tomcat] 01/03: Fix BZ 66841 - ensure AsyncListener.onError is called after an error

2023-08-04 Thread markt
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

commit 082b32506311e84828c47460f32b632119a15133
Author: Mark Thomas 
AuthorDate: Fri Aug 4 14:53:56 2023 +0100

Fix BZ 66841 - ensure AsyncListener.onError is called after an error

https://bz.apache.org/bugzilla/show_bug.cgi?id=66841
---
 java/org/apache/coyote/AbstractProcessor.java|   4 +-
 java/org/apache/coyote/AsyncStateMachine.java|  22 +++
 java/org/apache/coyote/LocalStrings.properties   |   2 +
 test/org/apache/coyote/http2/TestAsyncError.java | 170 +++
 4 files changed, 196 insertions(+), 2 deletions(-)

diff --git a/java/org/apache/coyote/AbstractProcessor.java 
b/java/org/apache/coyote/AbstractProcessor.java
index 3ee6898fbd..804837232d 100644
--- a/java/org/apache/coyote/AbstractProcessor.java
+++ b/java/org/apache/coyote/AbstractProcessor.java
@@ -105,7 +105,7 @@ public abstract class AbstractProcessor extends 
AbstractProcessorLight implement
 }
 // Use the return value to avoid processing more than one async error
 // in a single async cycle.
-boolean setError = response.setError();
+response.setError();
 boolean blockIo = this.errorState.isIoAllowed() && 
!errorState.isIoAllowed();
 this.errorState = this.errorState.getMostSevere(errorState);
 // Don't change the status code for IOException since that is almost
@@ -117,7 +117,7 @@ public abstract class AbstractProcessor extends 
AbstractProcessorLight implement
 if (t != null) {
 request.setAttribute(RequestDispatcher.ERROR_EXCEPTION, t);
 }
-if (blockIo && isAsync() && setError) {
+if (blockIo && isAsync()) {
 if (asyncStateMachine.asyncError()) {
 processSocketEvent(SocketEvent.ERROR, true);
 }
diff --git a/java/org/apache/coyote/AsyncStateMachine.java 
b/java/org/apache/coyote/AsyncStateMachine.java
index 9368faa90b..81fa1fed12 100644
--- a/java/org/apache/coyote/AsyncStateMachine.java
+++ b/java/org/apache/coyote/AsyncStateMachine.java
@@ -182,6 +182,15 @@ class AsyncStateMachine {
  * ends badly: e.g. CVE-2018-8037.
  */
 private final AtomicLong generation = new AtomicLong(0);
+/*
+ * Error processing should only be triggered once per async generation. 
This field tracks the last generation of
+ * async processing for which error processing was triggered and is used 
to ensure that the second and subsequent
+ * attempts to trigger async error processing for a given generation are 
NO-OPs.
+ *
+ * Guarded by this
+ */
+private long lastErrorGeneration = -1;
+
 // Need this to fire listener on complete
 private AsyncContextCallback asyncCtxt = null;
 private final AbstractProcessor processor;
@@ -412,6 +421,19 @@ class AsyncStateMachine {
 
 
 synchronized boolean asyncError() {
+// Ensure this is only processed once per generation.
+if (lastErrorGeneration == getCurrentGeneration()) {
+if (log.isDebugEnabled()) {
+log.debug(sm.getString("asyncStateMachine.asyncError.skip"));
+}
+return false;
+}
+lastErrorGeneration = getCurrentGeneration();
+
+if (log.isDebugEnabled()) {
+log.debug(sm.getString("asyncStateMachine.asyncError.start"));
+}
+
 clearNonBlockingListeners();
 if (state == AsyncState.STARTING) {
 updateState(AsyncState.MUST_ERROR);
diff --git a/java/org/apache/coyote/LocalStrings.properties 
b/java/org/apache/coyote/LocalStrings.properties
index e06ffcd9a1..e99009cf3b 100644
--- a/java/org/apache/coyote/LocalStrings.properties
+++ b/java/org/apache/coyote/LocalStrings.properties
@@ -51,6 +51,8 @@ abstractProtocolHandler.setAttribute=Set attribute [{0}] with 
value [{1}]
 abstractProtocolHandler.start=Starting ProtocolHandler [{0}]
 abstractProtocolHandler.stop=Stopping ProtocolHandler [{0}]
 
+asyncStateMachine.asyncError.skip=Ignoring call to asyncError() as it has 
already been called since async processing started
+asyncStateMachine.asyncError.start=Starting to process call to asyncError()
 asyncStateMachine.invalidAsyncState=Calling [{0}] is not valid for a request 
with Async state [{1}]
 asyncStateMachine.stateChange=Changing async state from [{0}] to [{1}]
 
diff --git a/test/org/apache/coyote/http2/TestAsyncError.java 
b/test/org/apache/coyote/http2/TestAsyncError.java
new file mode 100644
index 00..176e410ded
--- /dev/null
+++ b/test/org/apache/coyote/http2/TestAsyncError.java
@@ -0,0 +1,170 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the

[tomcat] 03/03: Remove unused return value

2023-08-04 Thread markt
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

commit a33a493ef76a38d542e5c1060cbff8c534fe4e79
Author: Mark Thomas 
AuthorDate: Fri Aug 4 15:01:16 2023 +0100

Remove unused return value
---
 java/org/apache/catalina/connector/Response.java | 11 +++
 java/org/apache/coyote/Response.java | 11 +++
 2 files changed, 6 insertions(+), 16 deletions(-)

diff --git a/java/org/apache/catalina/connector/Response.java 
b/java/org/apache/catalina/connector/Response.java
index 6cf4893d0e..124a5d67bc 100644
--- a/java/org/apache/catalina/connector/Response.java
+++ b/java/org/apache/catalina/connector/Response.java
@@ -369,15 +369,10 @@ public class Response implements HttpServletResponse {
 
 
 /**
- * Set the error flag.
- *
- * @return false if the error flag was already set
- *
- * @deprecated This method will be changed to return void in Tomcat 11 
onwards
+ * Set the error flag if not already set.
  */
-@Deprecated
-public boolean setError() {
-return getCoyoteResponse().setError();
+public void setError() {
+getCoyoteResponse().setError();
 }
 
 
diff --git a/java/org/apache/coyote/Response.java 
b/java/org/apache/coyote/Response.java
index 64920c2993..6e4991ac30 100644
--- a/java/org/apache/coyote/Response.java
+++ b/java/org/apache/coyote/Response.java
@@ -304,15 +304,10 @@ public final class Response {
 
 
 /**
- * Set the error flag.
- *
- * @return false if the error flag was already set
- *
- * @deprecated This method will be changed to return void in Tomcat 11 
onwards
+ * Set the error flag if not already set.
  */
-@Deprecated
-public boolean setError() {
-return errorState.compareAndSet(0, 1);
+public void setError() {
+errorState.compareAndSet(0, 1);
 }
 
 


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



[tomcat] branch main updated: Update changelog

2023-08-04 Thread markt
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 5972c56e56 Update changelog
5972c56e56 is described below

commit 5972c56e562a04cce558530cd4c3659f0d36eaef
Author: Mark Thomas 
AuthorDate: Fri Aug 4 15:57:59 2023 +0100

Update changelog
---
 webapps/docs/changelog.xml | 5 +
 1 file changed, 5 insertions(+)

diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 031e7df7bf..993af03a15 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -160,6 +160,11 @@
 PROFILE=SYSTEM instead of producing an error trying to
 parse it. (remm)
   
+  
+66841: Ensure that AsyncListener.onError() is
+called after an error during asynchronous processing with HTTP/2.
+(markt)
+  
 
   
   


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



Buildbot failure in on tomcat-11.0.x

2023-08-04 Thread buildbot
Build status: BUILD FAILED: failed compile (failure)
Worker used: bb_worker2_ubuntu
URL: https://ci2.apache.org/#builders/112/builds/513
Blamelist: Mark Thomas 
Build Text: failed compile (failure)
Status Detected: new failure
Build Source Stamp: [branch main] 5972c56e562a04cce558530cd4c3659f0d36eaef


Steps:

  worker_preparation: 0

  git: 0

  shell: 0

  shell_1: 0

  shell_2: 0

  shell_3: 0

  shell_4: 0

  shell_5: 0

  compile: 1

  shell_6: 0

  shell_7: 0

  shell_8: 0

  shell_9: 0

  Rsync docs to nightlies.apache.org: 0

  shell_10: 0

  Rsync RAT to nightlies.apache.org: 0

  compile_1: 2

  shell_11: 0

  Rsync Logs to nightlies.apache.org: 0


-- ASF Buildbot


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



Re: Buildbot failure in on tomcat-11.0.x

2023-08-04 Thread Mark Thomas
This is my fault. I know what I did wrong - I missed one case in the fix 
for BZ 66841. Working on a fix now...


Mark


On 04/08/2023 16:51, build...@apache.org wrote:

Build status: BUILD FAILED: failed compile (failure)
Worker used: bb_worker2_ubuntu
URL: https://ci2.apache.org/#builders/112/builds/513
Blamelist: Mark Thomas 
Build Text: failed compile (failure)
Status Detected: new failure
Build Source Stamp: [branch main] 5972c56e562a04cce558530cd4c3659f0d36eaef


Steps:

   worker_preparation: 0

   git: 0

   shell: 0

   shell_1: 0

   shell_2: 0

   shell_3: 0

   shell_4: 0

   shell_5: 0

   compile: 1

   shell_6: 0

   shell_7: 0

   shell_8: 0

   shell_9: 0

   Rsync docs to nightlies.apache.org: 0

   shell_10: 0

   Rsync RAT to nightlies.apache.org: 0

   compile_1: 2

   shell_11: 0

   Rsync Logs to nightlies.apache.org: 0


-- ASF Buildbot


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



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



[tomcat] branch main updated: Fix regression in fix for BZ 66841

2023-08-04 Thread markt
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 231c282685 Fix regression in fix for BZ 66841
231c282685 is described below

commit 231c282685d1fa9945f577e845a18d18bcabe5b1
Author: Mark Thomas 
AuthorDate: Fri Aug 4 19:11:04 2023 +0100

Fix regression in fix for BZ 66841
---
 java/org/apache/coyote/AsyncStateMachine.java | 30 +++
 1 file changed, 21 insertions(+), 9 deletions(-)

diff --git a/java/org/apache/coyote/AsyncStateMachine.java 
b/java/org/apache/coyote/AsyncStateMachine.java
index 81fa1fed12..04270925a3 100644
--- a/java/org/apache/coyote/AsyncStateMachine.java
+++ b/java/org/apache/coyote/AsyncStateMachine.java
@@ -183,13 +183,14 @@ class AsyncStateMachine {
  */
 private final AtomicLong generation = new AtomicLong(0);
 /*
- * Error processing should only be triggered once per async generation. 
This field tracks the last generation of
- * async processing for which error processing was triggered and is used 
to ensure that the second and subsequent
+ * Error processing should only be triggered once per async generation. 
These fields track the last generation of
+ * async processing for which error processing was triggered and are used 
to ensure that the second and subsequent
  * attempts to trigger async error processing for a given generation are 
NO-OPs.
  *
  * Guarded by this
  */
 private long lastErrorGeneration = -1;
+private long lastErrorGenerationMust = -1;
 
 // Need this to fire listener on complete
 private AsyncContextCallback asyncCtxt = null;
@@ -421,14 +422,25 @@ class AsyncStateMachine {
 
 
 synchronized boolean asyncError() {
-// Ensure this is only processed once per generation.
+Request request = processor.getRequest();
+boolean containerThread = (request != null && 
request.isRequestThread());
+
+// Ensure the error processing is only started once per generation
 if (lastErrorGeneration == getCurrentGeneration()) {
-if (log.isDebugEnabled()) {
-log.debug(sm.getString("asyncStateMachine.asyncError.skip"));
+if (state == AsyncState.MUST_ERROR && containerThread && 
lastErrorGenerationMust != getCurrentGeneration()) {
+// This is the first container thread call after state was set 
to MUST_ERROR so don't skip
+lastErrorGenerationMust = getCurrentGeneration();
+} else {
+// Duplicate call. Skip.
+if (log.isDebugEnabled()) {
+
log.debug(sm.getString("asyncStateMachine.asyncError.skip"));
+}
+return false;
 }
-return false;
+} else {
+// First call for this generation, don't skip.
+lastErrorGeneration = getCurrentGeneration();
 }
-lastErrorGeneration = getCurrentGeneration();
 
 if (log.isDebugEnabled()) {
 log.debug(sm.getString("asyncStateMachine.asyncError.start"));
@@ -447,8 +459,8 @@ class AsyncStateMachine {
 updateState(AsyncState.ERROR);
 }
 
-Request request = processor.getRequest();
-return request == null || !request.isRequestThread();
+// Return true for non-container threads to trigger a dispatch
+return !containerThread;
 }
 
 


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



[tomcat] 02/02: Mark method Deprecated that returns unused valid

2023-08-04 Thread markt
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 3a60055ac90b2cd55d7399aa0a9adb381b0b04af
Author: Mark Thomas 
AuthorDate: Fri Aug 4 14:55:28 2023 +0100

Mark method Deprecated that returns unused valid
---
 java/org/apache/catalina/connector/Response.java | 3 +++
 java/org/apache/coyote/Response.java | 3 +++
 2 files changed, 6 insertions(+)

diff --git a/java/org/apache/catalina/connector/Response.java 
b/java/org/apache/catalina/connector/Response.java
index 29d94efe55..f512ca0fd2 100644
--- a/java/org/apache/catalina/connector/Response.java
+++ b/java/org/apache/catalina/connector/Response.java
@@ -377,7 +377,10 @@ public class Response implements HttpServletResponse {
  * Set the error flag.
  *
  * @return false if the error flag was already set
+ *
+ * @deprecated This method will be changed to return void in Tomcat 11 
onwards
  */
+@Deprecated
 public boolean setError() {
 return getCoyoteResponse().setError();
 }
diff --git a/java/org/apache/coyote/Response.java 
b/java/org/apache/coyote/Response.java
index ed2b1de1a0..5eae29558d 100644
--- a/java/org/apache/coyote/Response.java
+++ b/java/org/apache/coyote/Response.java
@@ -311,7 +311,10 @@ public final class Response {
  * Set the error flag.
  *
  * @return false if the error flag was already set
+ *
+ * @deprecated This method will be changed to return void in Tomcat 11 
onwards
  */
+@Deprecated
 public boolean setError() {
 return errorState.compareAndSet(0, 1);
 }


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



[tomcat] 01/02: Fix BZ 66841 - ensure AsyncListener.onError is called after an error

2023-08-04 Thread markt
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 5554cadc88b9ba72f05675ade0bdb11c2a25fd03
Author: Mark Thomas 
AuthorDate: Fri Aug 4 14:53:56 2023 +0100

Fix BZ 66841 - ensure AsyncListener.onError is called after an error

https://bz.apache.org/bugzilla/show_bug.cgi?id=66841
---
 java/org/apache/coyote/AbstractProcessor.java|   4 +-
 java/org/apache/coyote/AsyncStateMachine.java|  38 -
 java/org/apache/coyote/LocalStrings.properties   |   2 +
 test/org/apache/coyote/http2/TestAsyncError.java | 170 +++
 webapps/docs/changelog.xml   |   5 +
 5 files changed, 215 insertions(+), 4 deletions(-)

diff --git a/java/org/apache/coyote/AbstractProcessor.java 
b/java/org/apache/coyote/AbstractProcessor.java
index ece5a6abda..b63eeae02e 100644
--- a/java/org/apache/coyote/AbstractProcessor.java
+++ b/java/org/apache/coyote/AbstractProcessor.java
@@ -105,7 +105,7 @@ public abstract class AbstractProcessor extends 
AbstractProcessorLight implement
 }
 // Use the return value to avoid processing more than one async error
 // in a single async cycle.
-boolean setError = response.setError();
+response.setError();
 boolean blockIo = this.errorState.isIoAllowed() && 
!errorState.isIoAllowed();
 this.errorState = this.errorState.getMostSevere(errorState);
 // Don't change the status code for IOException since that is almost
@@ -117,7 +117,7 @@ public abstract class AbstractProcessor extends 
AbstractProcessorLight implement
 if (t != null) {
 request.setAttribute(RequestDispatcher.ERROR_EXCEPTION, t);
 }
-if (blockIo && isAsync() && setError) {
+if (blockIo && isAsync()) {
 if (asyncStateMachine.asyncError()) {
 processSocketEvent(SocketEvent.ERROR, true);
 }
diff --git a/java/org/apache/coyote/AsyncStateMachine.java 
b/java/org/apache/coyote/AsyncStateMachine.java
index d2bcae1b0d..c81f93735c 100644
--- a/java/org/apache/coyote/AsyncStateMachine.java
+++ b/java/org/apache/coyote/AsyncStateMachine.java
@@ -185,6 +185,16 @@ class AsyncStateMachine {
  * ends badly: e.g. CVE-2018-8037.
  */
 private final AtomicLong generation = new AtomicLong(0);
+/*
+ * Error processing should only be triggered once per async generation. 
These fields track the last generation of
+ * async processing for which error processing was triggered and are used 
to ensure that the second and subsequent
+ * attempts to trigger async error processing for a given generation are 
NO-OPs.
+ *
+ * Guarded by this
+ */
+private long lastErrorGeneration = -1;
+private long lastErrorGenerationMust = -1;
+
 // Need this to fire listener on complete
 private AsyncContextCallback asyncCtxt = null;
 private final AbstractProcessor processor;
@@ -409,6 +419,30 @@ class AsyncStateMachine {
 
 
 synchronized boolean asyncError() {
+Request request = processor.getRequest();
+boolean containerThread = (request != null && 
request.isRequestThread());
+
+// Ensure the error processing is only started once per generation
+if (lastErrorGeneration == getCurrentGeneration()) {
+if (state == AsyncState.MUST_ERROR && containerThread && 
lastErrorGenerationMust != getCurrentGeneration()) {
+// This is the first container thread call after state was set 
to MUST_ERROR so don't skip
+lastErrorGenerationMust = getCurrentGeneration();
+} else {
+// Duplicate call. Skip.
+if (log.isDebugEnabled()) {
+
log.debug(sm.getString("asyncStateMachine.asyncError.skip"));
+}
+return false;
+}
+} else {
+// First call for this generation, don't skip.
+lastErrorGeneration = getCurrentGeneration();
+}
+
+if (log.isDebugEnabled()) {
+log.debug(sm.getString("asyncStateMachine.asyncError.start"));
+}
+
 clearNonBlockingListeners();
 if (state == AsyncState.STARTING) {
 updateState(AsyncState.MUST_ERROR);
@@ -422,8 +456,8 @@ class AsyncStateMachine {
 updateState(AsyncState.ERROR);
 }
 
-Request request = processor.getRequest();
-return request == null || !request.isRequestThread();
+// Return true for non-container threads to trigger a dispatch
+return !containerThread;
 }
 
 
diff --git a/java/org/apache/coyote/LocalStrings.properties 
b/java/org/apache/coyote/LocalStrings.properties
index b708730f45..74adeeaceb 100644
--- a/java/org/apache/coyote/LocalStrings.properties
+++ b/java/org/apache/coyote/LocalStrings.properties
@@ -51,6 +51,8 @@ abstractProtocolHandler.setAt

[tomcat] branch 10.1.x updated (f90c70f11f -> 3a60055ac9)

2023-08-04 Thread markt
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 f90c70f11f Pass through ciphers referring to an OpenSSL profile
 new 5554cadc88 Fix BZ 66841 - ensure AsyncListener.onError is called after 
an error
 new 3a60055ac9 Mark method Deprecated that returns unused valid

The 2 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/catalina/connector/Response.java |   3 +
 java/org/apache/coyote/AbstractProcessor.java|   4 +-
 java/org/apache/coyote/AsyncStateMachine.java|  38 -
 java/org/apache/coyote/LocalStrings.properties   |   2 +
 java/org/apache/coyote/Response.java |   3 +
 test/org/apache/coyote/http2/TestAsyncError.java | 170 +++
 webapps/docs/changelog.xml   |   5 +
 7 files changed, 221 insertions(+), 4 deletions(-)
 create mode 100644 test/org/apache/coyote/http2/TestAsyncError.java


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



[tomcat] branch 9.0.x updated (267e8d9270 -> bf63a6e40b)

2023-08-04 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a change to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


from 267e8d9270 Pass through ciphers referring to an OpenSSL profile
 new c86506b9a0 Fix BZ 66841 - ensure AsyncListener.onError is called after 
an error
 new bf63a6e40b Mark method Deprecated that returns unused valid

The 2 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/catalina/connector/Response.java |   3 +
 java/org/apache/coyote/AbstractProcessor.java|   4 +-
 java/org/apache/coyote/AsyncStateMachine.java|  38 -
 java/org/apache/coyote/LocalStrings.properties   |   2 +
 java/org/apache/coyote/Response.java |   3 +
 test/org/apache/coyote/http2/TestAsyncError.java | 170 +++
 webapps/docs/changelog.xml   |   5 +
 7 files changed, 221 insertions(+), 4 deletions(-)
 create mode 100644 test/org/apache/coyote/http2/TestAsyncError.java


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



[tomcat] 01/02: Fix BZ 66841 - ensure AsyncListener.onError is called after an error

2023-08-04 Thread markt
This is an automated email from the ASF dual-hosted git repository.

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

commit c86506b9a0c82a89f79cf2b5ba23de9b62a24a19
Author: Mark Thomas 
AuthorDate: Fri Aug 4 14:53:56 2023 +0100

Fix BZ 66841 - ensure AsyncListener.onError is called after an error

https://bz.apache.org/bugzilla/show_bug.cgi?id=66841
---
 java/org/apache/coyote/AbstractProcessor.java|   4 +-
 java/org/apache/coyote/AsyncStateMachine.java|  38 -
 java/org/apache/coyote/LocalStrings.properties   |   2 +
 test/org/apache/coyote/http2/TestAsyncError.java | 170 +++
 webapps/docs/changelog.xml   |   5 +
 5 files changed, 215 insertions(+), 4 deletions(-)

diff --git a/java/org/apache/coyote/AbstractProcessor.java 
b/java/org/apache/coyote/AbstractProcessor.java
index a49bc921cf..bbc3838ed4 100644
--- a/java/org/apache/coyote/AbstractProcessor.java
+++ b/java/org/apache/coyote/AbstractProcessor.java
@@ -104,7 +104,7 @@ public abstract class AbstractProcessor extends 
AbstractProcessorLight implement
 }
 // Use the return value to avoid processing more than one async error
 // in a single async cycle.
-boolean setError = response.setError();
+response.setError();
 boolean blockIo = this.errorState.isIoAllowed() && 
!errorState.isIoAllowed();
 this.errorState = this.errorState.getMostSevere(errorState);
 // Don't change the status code for IOException since that is almost
@@ -116,7 +116,7 @@ public abstract class AbstractProcessor extends 
AbstractProcessorLight implement
 if (t != null) {
 request.setAttribute(RequestDispatcher.ERROR_EXCEPTION, t);
 }
-if (blockIo && isAsync() && setError) {
+if (blockIo && isAsync()) {
 if (asyncStateMachine.asyncError()) {
 processSocketEvent(SocketEvent.ERROR, true);
 }
diff --git a/java/org/apache/coyote/AsyncStateMachine.java 
b/java/org/apache/coyote/AsyncStateMachine.java
index d2bcae1b0d..c81f93735c 100644
--- a/java/org/apache/coyote/AsyncStateMachine.java
+++ b/java/org/apache/coyote/AsyncStateMachine.java
@@ -185,6 +185,16 @@ class AsyncStateMachine {
  * ends badly: e.g. CVE-2018-8037.
  */
 private final AtomicLong generation = new AtomicLong(0);
+/*
+ * Error processing should only be triggered once per async generation. 
These fields track the last generation of
+ * async processing for which error processing was triggered and are used 
to ensure that the second and subsequent
+ * attempts to trigger async error processing for a given generation are 
NO-OPs.
+ *
+ * Guarded by this
+ */
+private long lastErrorGeneration = -1;
+private long lastErrorGenerationMust = -1;
+
 // Need this to fire listener on complete
 private AsyncContextCallback asyncCtxt = null;
 private final AbstractProcessor processor;
@@ -409,6 +419,30 @@ class AsyncStateMachine {
 
 
 synchronized boolean asyncError() {
+Request request = processor.getRequest();
+boolean containerThread = (request != null && 
request.isRequestThread());
+
+// Ensure the error processing is only started once per generation
+if (lastErrorGeneration == getCurrentGeneration()) {
+if (state == AsyncState.MUST_ERROR && containerThread && 
lastErrorGenerationMust != getCurrentGeneration()) {
+// This is the first container thread call after state was set 
to MUST_ERROR so don't skip
+lastErrorGenerationMust = getCurrentGeneration();
+} else {
+// Duplicate call. Skip.
+if (log.isDebugEnabled()) {
+
log.debug(sm.getString("asyncStateMachine.asyncError.skip"));
+}
+return false;
+}
+} else {
+// First call for this generation, don't skip.
+lastErrorGeneration = getCurrentGeneration();
+}
+
+if (log.isDebugEnabled()) {
+log.debug(sm.getString("asyncStateMachine.asyncError.start"));
+}
+
 clearNonBlockingListeners();
 if (state == AsyncState.STARTING) {
 updateState(AsyncState.MUST_ERROR);
@@ -422,8 +456,8 @@ class AsyncStateMachine {
 updateState(AsyncState.ERROR);
 }
 
-Request request = processor.getRequest();
-return request == null || !request.isRequestThread();
+// Return true for non-container threads to trigger a dispatch
+return !containerThread;
 }
 
 
diff --git a/java/org/apache/coyote/LocalStrings.properties 
b/java/org/apache/coyote/LocalStrings.properties
index b708730f45..74adeeaceb 100644
--- a/java/org/apache/coyote/LocalStrings.properties
+++ b/java/org/apache/coyote/LocalStrings.properties
@@ -51,6 +51,8 @@ abstractProtocolHandler.setAtt

[tomcat] 02/02: Mark method Deprecated that returns unused valid

2023-08-04 Thread markt
This is an automated email from the ASF dual-hosted git repository.

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

commit bf63a6e40bbd98bb7c5e4dd64321b6ea4a36147b
Author: Mark Thomas 
AuthorDate: Fri Aug 4 14:55:28 2023 +0100

Mark method Deprecated that returns unused valid
---
 java/org/apache/catalina/connector/Response.java | 3 +++
 java/org/apache/coyote/Response.java | 3 +++
 2 files changed, 6 insertions(+)

diff --git a/java/org/apache/catalina/connector/Response.java 
b/java/org/apache/catalina/connector/Response.java
index 3f5e2a0b45..e3c2c27339 100644
--- a/java/org/apache/catalina/connector/Response.java
+++ b/java/org/apache/catalina/connector/Response.java
@@ -400,7 +400,10 @@ public class Response implements HttpServletResponse {
  * Set the error flag.
  *
  * @return false if the error flag was already set
+ *
+ * @deprecated This method will be changed to return void in Tomcat 11 
onwards
  */
+@Deprecated
 public boolean setError() {
 return getCoyoteResponse().setError();
 }
diff --git a/java/org/apache/coyote/Response.java 
b/java/org/apache/coyote/Response.java
index 29c3f52623..290c042682 100644
--- a/java/org/apache/coyote/Response.java
+++ b/java/org/apache/coyote/Response.java
@@ -301,7 +301,10 @@ public final class Response {
  * Set the error flag.
  *
  * @return false if the error flag was already set
+ *
+ * @deprecated This method will be changed to return void in Tomcat 11 
onwards
  */
+@Deprecated
 public boolean setError() {
 return errorState.compareAndSet(0, 1);
 }


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



[tomcat] branch 10.1.x updated: Fix back-port

2023-08-04 Thread markt
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


The following commit(s) were added to refs/heads/10.1.x by this push:
 new 63b9fa9904 Fix back-port
63b9fa9904 is described below

commit 63b9fa990486607b14cddca8160a362c1dc2e682
Author: Mark Thomas 
AuthorDate: Fri Aug 4 19:21:46 2023 +0100

Fix back-port
---
 test/org/apache/coyote/http2/TestAsyncError.java | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/test/org/apache/coyote/http2/TestAsyncError.java 
b/test/org/apache/coyote/http2/TestAsyncError.java
index 176e410ded..a741bbd256 100644
--- a/test/org/apache/coyote/http2/TestAsyncError.java
+++ b/test/org/apache/coyote/http2/TestAsyncError.java
@@ -19,7 +19,6 @@ package org.apache.coyote.http2;
 import java.io.IOException;
 import java.io.PrintWriter;
 import java.nio.ByteBuffer;
-import java.nio.charset.StandardCharsets;
 import java.util.concurrent.atomic.AtomicInteger;
 
 import jakarta.servlet.AsyncContext;
@@ -120,7 +119,7 @@ public class TestAsyncError extends Http2TestBase {
 public void run() {
 try {
 resp.setContentType("text/plain");
-resp.setCharacterEncoding(StandardCharsets.UTF_8);
+resp.setCharacterEncoding("UTF-8");
 PrintWriter pw = resp.getWriter();
 
 while (true) {


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



[tomcat] branch 9.0.x updated: Fix back-port

2023-08-04 Thread markt
This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/9.0.x by this push:
 new fefdd5b1a8 Fix back-port
fefdd5b1a8 is described below

commit fefdd5b1a86789e8c0870952b2b4786e625db2f6
Author: Mark Thomas 
AuthorDate: Fri Aug 4 19:23:14 2023 +0100

Fix back-port
---
 test/org/apache/coyote/http2/TestAsyncError.java | 17 -
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/test/org/apache/coyote/http2/TestAsyncError.java 
b/test/org/apache/coyote/http2/TestAsyncError.java
index 176e410ded..d04f839605 100644
--- a/test/org/apache/coyote/http2/TestAsyncError.java
+++ b/test/org/apache/coyote/http2/TestAsyncError.java
@@ -19,16 +19,15 @@ package org.apache.coyote.http2;
 import java.io.IOException;
 import java.io.PrintWriter;
 import java.nio.ByteBuffer;
-import java.nio.charset.StandardCharsets;
 import java.util.concurrent.atomic.AtomicInteger;
 
-import jakarta.servlet.AsyncContext;
-import jakarta.servlet.AsyncEvent;
-import jakarta.servlet.AsyncListener;
-import jakarta.servlet.ServletException;
-import jakarta.servlet.http.HttpServlet;
-import jakarta.servlet.http.HttpServletRequest;
-import jakarta.servlet.http.HttpServletResponse;
+import javax.servlet.AsyncContext;
+import javax.servlet.AsyncEvent;
+import javax.servlet.AsyncListener;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
 
 import org.junit.Assert;
 import org.junit.Test;
@@ -120,7 +119,7 @@ public class TestAsyncError extends Http2TestBase {
 public void run() {
 try {
 resp.setContentType("text/plain");
-resp.setCharacterEncoding(StandardCharsets.UTF_8);
+resp.setCharacterEncoding("UTF-8");
 PrintWriter pw = resp.getWriter();
 
 while (true) {


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



[tomcat] branch 8.5.x updated: Fix BZ 66841 - ensure AsyncListener.onError is called after an error

2023-08-04 Thread markt
This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/8.5.x by this push:
 new b1a337b9b1 Fix BZ 66841 - ensure AsyncListener.onError is called after 
an error
b1a337b9b1 is described below

commit b1a337b9b1a5eb397b0203f92923642a07d44496
Author: Mark Thomas 
AuthorDate: Fri Aug 4 14:53:56 2023 +0100

Fix BZ 66841 - ensure AsyncListener.onError is called after an error

https://bz.apache.org/bugzilla/show_bug.cgi?id=66841
---
 java/org/apache/coyote/AbstractProcessor.java|   4 +-
 java/org/apache/coyote/AsyncStateMachine.java|  38 -
 java/org/apache/coyote/LocalStrings.properties   |   2 +
 test/org/apache/coyote/http2/TestAsyncError.java | 169 +++
 webapps/docs/changelog.xml   |   5 +
 5 files changed, 214 insertions(+), 4 deletions(-)

diff --git a/java/org/apache/coyote/AbstractProcessor.java 
b/java/org/apache/coyote/AbstractProcessor.java
index 2a28d683ed..1d24fb9707 100644
--- a/java/org/apache/coyote/AbstractProcessor.java
+++ b/java/org/apache/coyote/AbstractProcessor.java
@@ -106,7 +106,7 @@ public abstract class AbstractProcessor extends 
AbstractProcessorLight implement
 }
 // Use the return value to avoid processing more than one async error
 // in a single async cycle.
-boolean setError = response.setError();
+response.setError();
 boolean blockIo = this.errorState.isIoAllowed() && 
!errorState.isIoAllowed();
 this.errorState = this.errorState.getMostSevere(errorState);
 // Don't change the status code for IOException since that is almost
@@ -118,7 +118,7 @@ public abstract class AbstractProcessor extends 
AbstractProcessorLight implement
 if (t != null) {
 request.setAttribute(RequestDispatcher.ERROR_EXCEPTION, t);
 }
-if (blockIo && isAsync() && setError) {
+if (blockIo && isAsync()) {
 if (asyncStateMachine.asyncError()) {
 processSocketEvent(SocketEvent.ERROR, true);
 }
diff --git a/java/org/apache/coyote/AsyncStateMachine.java 
b/java/org/apache/coyote/AsyncStateMachine.java
index 3c08c0f7a9..fcac6102f3 100644
--- a/java/org/apache/coyote/AsyncStateMachine.java
+++ b/java/org/apache/coyote/AsyncStateMachine.java
@@ -185,6 +185,16 @@ public class AsyncStateMachine {
  * ends badly: e.g. CVE-2018-8037.
  */
 private final AtomicLong generation = new AtomicLong(0);
+/*
+ * Error processing should only be triggered once per async generation. 
These fields track the last generation of
+ * async processing for which error processing was triggered and are used 
to ensure that the second and subsequent
+ * attempts to trigger async error processing for a given generation are 
NO-OPs.
+ *
+ * Guarded by this
+ */
+private long lastErrorGeneration = -1;
+private long lastErrorGenerationMust = -1;
+
 // Need this to fire listener on complete
 private AsyncContextCallback asyncCtxt = null;
 private final AbstractProcessor processor;
@@ -409,6 +419,30 @@ public class AsyncStateMachine {
 
 
 public synchronized boolean asyncError() {
+Request request = processor.getRequest();
+boolean containerThread = (request != null && 
request.isRequestThread());
+
+// Ensure the error processing is only started once per generation
+if (lastErrorGeneration == getCurrentGeneration()) {
+if (state == AsyncState.MUST_ERROR && containerThread && 
lastErrorGenerationMust != getCurrentGeneration()) {
+// This is the first container thread call after state was set 
to MUST_ERROR so don't skip
+lastErrorGenerationMust = getCurrentGeneration();
+} else {
+// Duplicate call. Skip.
+if (log.isDebugEnabled()) {
+
log.debug(sm.getString("asyncStateMachine.asyncError.skip"));
+}
+return false;
+}
+} else {
+// First call for this generation, don't skip.
+lastErrorGeneration = getCurrentGeneration();
+}
+
+if (log.isDebugEnabled()) {
+log.debug(sm.getString("asyncStateMachine.asyncError.start"));
+}
+
 clearNonBlockingListeners();
 if (state == AsyncState.STARTING) {
 updateState(AsyncState.MUST_ERROR);
@@ -422,8 +456,8 @@ public class AsyncStateMachine {
 updateState(AsyncState.ERROR);
 }
 
-Request request = processor.getRequest();
-return request == null || !request.isRequestThread();
+// Return true for non-container threads to trigger a dispatch
+return !containerThread;
 }
 
 
diff --git a/java/org/apache/coyote/LocalStrings.properties 
b/java/org/apache/co

[tomcat] branch 10.1.x updated: Silence deprecation warnings

2023-08-04 Thread markt
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


The following commit(s) were added to refs/heads/10.1.x by this push:
 new 4150fc00c5 Silence deprecation warnings
4150fc00c5 is described below

commit 4150fc00c555ec40e7c3de96a3aca4958d18ab73
Author: Mark Thomas 
AuthorDate: Fri Aug 4 19:29:35 2023 +0100

Silence deprecation warnings
---
 java/org/apache/catalina/connector/CoyoteAdapter.java   | 1 +
 java/org/apache/catalina/core/AsyncContextImpl.java | 1 +
 java/org/apache/catalina/core/StandardHostValve.java| 1 +
 java/org/apache/catalina/core/StandardWrapperValve.java | 1 +
 java/org/apache/coyote/AbstractProcessor.java   | 2 ++
 java/org/apache/coyote/http2/Stream.java| 3 +++
 6 files changed, 9 insertions(+)

diff --git a/java/org/apache/catalina/connector/CoyoteAdapter.java 
b/java/org/apache/catalina/connector/CoyoteAdapter.java
index 4242f34fc0..b4f28fbffb 100644
--- a/java/org/apache/catalina/connector/CoyoteAdapter.java
+++ b/java/org/apache/catalina/connector/CoyoteAdapter.java
@@ -553,6 +553,7 @@ public class CoyoteAdapter implements Adapter {
  * @throws IOException  If there is insufficient space in a buffer 
while processing headers
  * @throws ServletException If the supported methods of the target servlet 
cannot be determined
  */
+@SuppressWarnings("deprecation")
 protected boolean postParseRequest(org.apache.coyote.Request req, Request 
request, org.apache.coyote.Response res,
 Response response) throws IOException, ServletException {
 
diff --git a/java/org/apache/catalina/core/AsyncContextImpl.java 
b/java/org/apache/catalina/core/AsyncContextImpl.java
index 53b6024315..cceddd1e6a 100644
--- a/java/org/apache/catalina/core/AsyncContextImpl.java
+++ b/java/org/apache/catalina/core/AsyncContextImpl.java
@@ -517,6 +517,7 @@ public class AsyncContextImpl implements AsyncContext, 
AsyncContextCallback {
 this.coyoteRequest = coyoteRequest;
 }
 
+@SuppressWarnings("deprecation")
 @Override
 public void run() {
 ClassLoader oldCL = context.bind(Globals.IS_SECURITY_ENABLED, 
null);
diff --git a/java/org/apache/catalina/core/StandardHostValve.java 
b/java/org/apache/catalina/core/StandardHostValve.java
index 458b1a2f19..3b3b316dae 100644
--- a/java/org/apache/catalina/core/StandardHostValve.java
+++ b/java/org/apache/catalina/core/StandardHostValve.java
@@ -241,6 +241,7 @@ final class StandardHostValve extends ValveBase {
  * @param response  The response being generated
  * @param throwable The exception that occurred (which possibly wraps a 
root cause exception
  */
+@SuppressWarnings("deprecation")
 protected void throwable(Request request, Response response, Throwable 
throwable) {
 Context context = request.getContext();
 if (context == null) {
diff --git a/java/org/apache/catalina/core/StandardWrapperValve.java 
b/java/org/apache/catalina/core/StandardWrapperValve.java
index bbbda3ca8a..35a2acba84 100644
--- a/java/org/apache/catalina/core/StandardWrapperValve.java
+++ b/java/org/apache/catalina/core/StandardWrapperValve.java
@@ -270,6 +270,7 @@ final class StandardWrapperValve extends ValveBase {
  * @param response  The response being generated
  * @param exception The exception that occurred (which possibly wraps a 
root cause exception
  */
+@SuppressWarnings("deprecation")
 private void exception(Request request, Response response, Throwable 
exception) {
 request.setAttribute(RequestDispatcher.ERROR_EXCEPTION, exception);
 response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
diff --git a/java/org/apache/coyote/AbstractProcessor.java 
b/java/org/apache/coyote/AbstractProcessor.java
index b63eeae02e..bb79a58091 100644
--- a/java/org/apache/coyote/AbstractProcessor.java
+++ b/java/org/apache/coyote/AbstractProcessor.java
@@ -99,6 +99,7 @@ public abstract class AbstractProcessor extends 
AbstractProcessorLight implement
  * @param errorState The error status details
  * @param t  The error which occurred
  */
+@SuppressWarnings("deprecation")
 protected void setErrorState(ErrorState errorState, Throwable t) {
 if (getLog().isDebugEnabled()) {
 getLog().debug(sm.getString("abstractProcessor.setErrorState", 
errorState), t);
@@ -1003,6 +1004,7 @@ public abstract class AbstractProcessor extends 
AbstractProcessorLight implement
 protected abstract SocketState dispatchEndRequest() throws IOException;
 
 
+@SuppressWarnings("deprecation")
 @Override
 protected final void logAccess(SocketWrapperBase socketWrapper) throws 
IOException {
 // Set the socket wrapper so the access log can read the socket related
diff --git a/java/org/apache/coyote/http2/Stream.java 
b/java/org/apache/coyote/h

[tomcat] branch 9.0.x updated: Silence deprecation warnings

2023-08-04 Thread markt
This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/9.0.x by this push:
 new b330d82960 Silence deprecation warnings
b330d82960 is described below

commit b330d82960811662072d013b52741c467303f147
Author: Mark Thomas 
AuthorDate: Fri Aug 4 19:31:15 2023 +0100

Silence deprecation warnings
---
 java/org/apache/catalina/connector/CoyoteAdapter.java   | 1 +
 java/org/apache/catalina/core/AsyncContextImpl.java | 1 +
 java/org/apache/catalina/core/StandardHostValve.java| 1 +
 java/org/apache/catalina/core/StandardWrapperValve.java | 1 +
 java/org/apache/coyote/AbstractProcessor.java   | 2 ++
 java/org/apache/coyote/http2/Stream.java| 3 +++
 6 files changed, 9 insertions(+)

diff --git a/java/org/apache/catalina/connector/CoyoteAdapter.java 
b/java/org/apache/catalina/connector/CoyoteAdapter.java
index c0eb3307cd..28bf20ead7 100644
--- a/java/org/apache/catalina/connector/CoyoteAdapter.java
+++ b/java/org/apache/catalina/connector/CoyoteAdapter.java
@@ -555,6 +555,7 @@ public class CoyoteAdapter implements Adapter {
  * @throws IOException  If there is insufficient space in a buffer 
while processing headers
  * @throws ServletException If the supported methods of the target servlet 
cannot be determined
  */
+@SuppressWarnings("deprecation")
 protected boolean postParseRequest(org.apache.coyote.Request req, Request 
request, org.apache.coyote.Response res,
 Response response) throws IOException, ServletException {
 
diff --git a/java/org/apache/catalina/core/AsyncContextImpl.java 
b/java/org/apache/catalina/core/AsyncContextImpl.java
index c7a8f1d878..56ef57ae44 100644
--- a/java/org/apache/catalina/core/AsyncContextImpl.java
+++ b/java/org/apache/catalina/core/AsyncContextImpl.java
@@ -516,6 +516,7 @@ public class AsyncContextImpl implements AsyncContext, 
AsyncContextCallback {
 this.coyoteRequest = coyoteRequest;
 }
 
+@SuppressWarnings("deprecation")
 @Override
 public void run() {
 ClassLoader oldCL = context.bind(Globals.IS_SECURITY_ENABLED, 
null);
diff --git a/java/org/apache/catalina/core/StandardHostValve.java 
b/java/org/apache/catalina/core/StandardHostValve.java
index 3b50dfefee..b7aaad0dd1 100644
--- a/java/org/apache/catalina/core/StandardHostValve.java
+++ b/java/org/apache/catalina/core/StandardHostValve.java
@@ -256,6 +256,7 @@ final class StandardHostValve extends ValveBase {
  * @param response  The response being generated
  * @param throwable The exception that occurred (which possibly wraps a 
root cause exception
  */
+@SuppressWarnings("deprecation")
 protected void throwable(Request request, Response response, Throwable 
throwable) {
 Context context = request.getContext();
 if (context == null) {
diff --git a/java/org/apache/catalina/core/StandardWrapperValve.java 
b/java/org/apache/catalina/core/StandardWrapperValve.java
index 4ed7d22e1a..80da74e13a 100644
--- a/java/org/apache/catalina/core/StandardWrapperValve.java
+++ b/java/org/apache/catalina/core/StandardWrapperValve.java
@@ -271,6 +271,7 @@ final class StandardWrapperValve extends ValveBase {
  * @param response  The response being generated
  * @param exception The exception that occurred (which possibly wraps a 
root cause exception
  */
+@SuppressWarnings("deprecation")
 private void exception(Request request, Response response, Throwable 
exception) {
 request.setAttribute(RequestDispatcher.ERROR_EXCEPTION, exception);
 response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
diff --git a/java/org/apache/coyote/AbstractProcessor.java 
b/java/org/apache/coyote/AbstractProcessor.java
index bbc3838ed4..6db9347af8 100644
--- a/java/org/apache/coyote/AbstractProcessor.java
+++ b/java/org/apache/coyote/AbstractProcessor.java
@@ -98,6 +98,7 @@ public abstract class AbstractProcessor extends 
AbstractProcessorLight implement
  * @param errorState The error status details
  * @param t  The error which occurred
  */
+@SuppressWarnings("deprecation")
 protected void setErrorState(ErrorState errorState, Throwable t) {
 if (getLog().isDebugEnabled()) {
 getLog().debug(sm.getString("abstractProcessor.setErrorState", 
errorState), t);
@@ -1012,6 +1013,7 @@ public abstract class AbstractProcessor extends 
AbstractProcessorLight implement
 protected abstract SocketState dispatchEndRequest() throws IOException;
 
 
+@SuppressWarnings("deprecation")
 @Override
 protected final void logAccess(SocketWrapperBase socketWrapper) throws 
IOException {
 // Set the socket wrapper so the access log can read the socket related
diff --git a/java/org/apache/coyote/http2/Stream.java 
b/java/org/apache/coyote/htt

Re: [tomcat] branch main updated: Add JreCompat for Java 22

2023-08-04 Thread Mark Thomas

On 04/08/2023 08:13, r...@apache.org wrote:

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

remm 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 7e6af38a62 Add JreCompat for Java 22
7e6af38a62 is described below

commit 7e6af38a62b6354869f979ac718a270b70e6ec4d
Author: remm 
AuthorDate: Fri Aug 4 09:13:16 2023 +0200

 Add JreCompat for Java 22


This isn't working quite right.

The class is present in Java 21 (it is still visible even though it is 
preview) and the method is "getUtf8String" (I think).


Not sure on the bets way to handle this. Ideally, we want a class that 
is only present in Java 22. There must be one somewhere. Just need to 
find it...


Mark


 
 Actually the one with the non preview Panama.

---
  .../org/apache/tomcat/util/compat/Jre22Compat.java | 54 ++
  java/org/apache/tomcat/util/compat/JreCompat.java  | 16 ++-
  .../tomcat/util/compat/LocalStrings.properties | 17 +++
  3 files changed, 86 insertions(+), 1 deletion(-)

diff --git a/java/org/apache/tomcat/util/compat/Jre22Compat.java 
b/java/org/apache/tomcat/util/compat/Jre22Compat.java
new file mode 100644
index 00..0b690164b6
--- /dev/null
+++ b/java/org/apache/tomcat/util/compat/Jre22Compat.java
@@ -0,0 +1,54 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.tomcat.util.compat;
+
+import java.lang.reflect.Method;
+
+import org.apache.juli.logging.Log;
+import org.apache.juli.logging.LogFactory;
+import org.apache.tomcat.util.res.StringManager;
+
+public class Jre22Compat extends JreCompat {
+
+private static final Log log = LogFactory.getLog(Jre22Compat.class);
+private static final StringManager sm = 
StringManager.getManager(Jre22Compat.class);
+
+private static final boolean hasPanama;
+
+
+static {
+Class c1 = null;
+Method m1 = null;
+
+try {
+c1 = Class.forName("java.lang.foreign.MemorySegment");
+m1 = c1.getMethod("getString", long.class);
+} catch (ClassNotFoundException e) {
+// Must be pre-Java 22
+log.debug(sm.getString("jre22Compat.javaPre22"), e);
+} catch (ReflectiveOperationException e) {
+// Should never happen
+log.error(sm.getString("jre22Compat.unexpected"), e);
+}
+hasPanama = (m1 != null);
+}
+
+static boolean isSupported() {
+return hasPanama;
+}
+
+}
diff --git a/java/org/apache/tomcat/util/compat/JreCompat.java 
b/java/org/apache/tomcat/util/compat/JreCompat.java
index 334115acc3..7273b0b233 100644
--- a/java/org/apache/tomcat/util/compat/JreCompat.java
+++ b/java/org/apache/tomcat/util/compat/JreCompat.java
@@ -25,6 +25,7 @@ public class JreCompat {
  
  private static final JreCompat instance;

  private static final boolean graalAvailable;
+private static final boolean jre22Available;
  
  static {

  boolean result = false;
@@ -39,7 +40,13 @@ public class JreCompat {
  graalAvailable = result || 
System.getProperty("org.graalvm.nativeimage.imagecode") != null;
  
  // This is Tomcat 11.0.x with a minimum Java version of Java 21.

-instance = new JreCompat();
+if (Jre22Compat.isSupported()) {
+instance = new Jre22Compat();
+jre22Available = true;
+} else {
+instance = new JreCompat();
+jre22Available = false;
+}
  }
  
  
@@ -51,4 +58,11 @@ public class JreCompat {

  public static boolean isGraalAvailable() {
  return graalAvailable;
  }
+
+
+public static boolean isJre22Available() {
+return jre22Available;
+}
+
+
  }
diff --git a/java/org/apache/tomcat/util/compat/LocalStrings.properties 
b/java/org/apache/tomcat/util/compat/LocalStrings.properties
new file mode 100644
index 00..e3bbf2b43b
--- /dev/null
+++ b/java/org/apache/tomcat/util/compat/LocalStrings.properties
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the

Re: [tomcat] branch main updated: Add JreCompat for Java 22

2023-08-04 Thread Rémy Maucherat
On Fri, Aug 4, 2023 at 8:47 PM Mark Thomas  wrote:
>
> On 04/08/2023 08:13, r...@apache.org wrote:
> > This is an automated email from the ASF dual-hosted git repository.
> >
> > remm 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 7e6af38a62 Add JreCompat for Java 22
> > 7e6af38a62 is described below
> >
> > commit 7e6af38a62b6354869f979ac718a270b70e6ec4d
> > Author: remm 
> > AuthorDate: Fri Aug 4 09:13:16 2023 +0200
> >
> >  Add JreCompat for Java 22
>
> This isn't working quite right.
>
> The class is present in Java 21 (it is still visible even though it is

Yes, the class is present, but only with the preview flag.

> preview) and the method is "getUtf8String" (I think).

It just got changed to "getString" in the panama branch, so this is
not an accident and this will detect the final API. However, I will
tone down the log (it is an error).

> Not sure on the bets way to handle this. Ideally, we want a class that
> is only present in Java 22. There must be one somewhere. Just need to
> find it...

Right now there are no unique new classes in "22" for Panama, only
some method changes.

Rémy

> Mark
>
>
> >
> >  Actually the one with the non preview Panama.
> > ---
> >   .../org/apache/tomcat/util/compat/Jre22Compat.java | 54 
> > ++
> >   java/org/apache/tomcat/util/compat/JreCompat.java  | 16 ++-
> >   .../tomcat/util/compat/LocalStrings.properties | 17 +++
> >   3 files changed, 86 insertions(+), 1 deletion(-)
> >
> > diff --git a/java/org/apache/tomcat/util/compat/Jre22Compat.java 
> > b/java/org/apache/tomcat/util/compat/Jre22Compat.java
> > new file mode 100644
> > index 00..0b690164b6
> > --- /dev/null
> > +++ b/java/org/apache/tomcat/util/compat/Jre22Compat.java
> > @@ -0,0 +1,54 @@
> > +/*
> > + *  Licensed to the Apache Software Foundation (ASF) under one or more
> > + *  contributor license agreements.  See the NOTICE file distributed with
> > + *  this work for additional information regarding copyright ownership.
> > + *  The ASF licenses this file to You under the Apache License, Version 2.0
> > + *  (the "License"); you may not use this file except in compliance with
> > + *  the License.  You may obtain a copy of the License at
> > + *
> > + *  http://www.apache.org/licenses/LICENSE-2.0
> > + *
> > + *  Unless required by applicable law or agreed to in writing, software
> > + *  distributed under the License is distributed on an "AS IS" BASIS,
> > + *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 
> > implied.
> > + *  See the License for the specific language governing permissions and
> > + *  limitations under the License.
> > + */
> > +package org.apache.tomcat.util.compat;
> > +
> > +import java.lang.reflect.Method;
> > +
> > +import org.apache.juli.logging.Log;
> > +import org.apache.juli.logging.LogFactory;
> > +import org.apache.tomcat.util.res.StringManager;
> > +
> > +public class Jre22Compat extends JreCompat {
> > +
> > +private static final Log log = LogFactory.getLog(Jre22Compat.class);
> > +private static final StringManager sm = 
> > StringManager.getManager(Jre22Compat.class);
> > +
> > +private static final boolean hasPanama;
> > +
> > +
> > +static {
> > +Class c1 = null;
> > +Method m1 = null;
> > +
> > +try {
> > +c1 = Class.forName("java.lang.foreign.MemorySegment");
> > +m1 = c1.getMethod("getString", long.class);
> > +} catch (ClassNotFoundException e) {
> > +// Must be pre-Java 22
> > +log.debug(sm.getString("jre22Compat.javaPre22"), e);
> > +} catch (ReflectiveOperationException e) {
> > +// Should never happen
> > +log.error(sm.getString("jre22Compat.unexpected"), e);
> > +}
> > +hasPanama = (m1 != null);
> > +}
> > +
> > +static boolean isSupported() {
> > +return hasPanama;
> > +}
> > +
> > +}
> > diff --git a/java/org/apache/tomcat/util/compat/JreCompat.java 
> > b/java/org/apache/tomcat/util/compat/JreCompat.java
> > index 334115acc3..7273b0b233 100644
> > --- a/java/org/apache/tomcat/util/compat/JreCompat.java
> > +++ b/java/org/apache/tomcat/util/compat/JreCompat.java
> > @@ -25,6 +25,7 @@ public class JreCompat {
> >
> >   private static final JreCompat instance;
> >   private static final boolean graalAvailable;
> > +private static final boolean jre22Available;
> >
> >   static {
> >   boolean result = false;
> > @@ -39,7 +40,13 @@ public class JreCompat {
> >   graalAvailable = result || 
> > System.getProperty("org.graalvm.nativeimage.imagecode") != null;
> >
> >   // This is Tomcat 11.0.x with a minimum Java version of Java 21.
> > -instance = new JreCompat();
> > +if (Jre22Compat.isSupported()) {
> > +instance = 

[tomcat] branch main updated: Explain the check and tone down the log

2023-08-04 Thread remm
This is an automated email from the ASF dual-hosted git repository.

remm 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 ca7bfdb610 Explain the check and tone down the log
ca7bfdb610 is described below

commit ca7bfdb6109c42ddbd193c022cc36d6af246db6a
Author: remm 
AuthorDate: Fri Aug 4 20:59:59 2023 +0200

Explain the check and tone down the log
---
 java/org/apache/tomcat/util/compat/Jre22Compat.java | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/java/org/apache/tomcat/util/compat/Jre22Compat.java 
b/java/org/apache/tomcat/util/compat/Jre22Compat.java
index 0b690164b6..4d40da80c8 100644
--- a/java/org/apache/tomcat/util/compat/Jre22Compat.java
+++ b/java/org/apache/tomcat/util/compat/Jre22Compat.java
@@ -41,8 +41,8 @@ public class Jre22Compat extends JreCompat {
 // Must be pre-Java 22
 log.debug(sm.getString("jre22Compat.javaPre22"), e);
 } catch (ReflectiveOperationException e) {
-// Should never happen
-log.error(sm.getString("jre22Compat.unexpected"), e);
+// Likely a previous API version
+log.debug(sm.getString("jre22Compat.unexpected"), e);
 }
 hasPanama = (m1 != null);
 }


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



[tomcat] branch 10.1.x updated: Explain the check and tone down the log

2023-08-04 Thread remm
This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/10.1.x by this push:
 new 9973320cb6 Explain the check and tone down the log
9973320cb6 is described below

commit 9973320cb69dc5812535121caaa567bf9294abd5
Author: remm 
AuthorDate: Fri Aug 4 20:59:59 2023 +0200

Explain the check and tone down the log
---
 java/org/apache/tomcat/util/compat/Jre22Compat.java | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/java/org/apache/tomcat/util/compat/Jre22Compat.java 
b/java/org/apache/tomcat/util/compat/Jre22Compat.java
index 486cc8a804..7520310400 100644
--- a/java/org/apache/tomcat/util/compat/Jre22Compat.java
+++ b/java/org/apache/tomcat/util/compat/Jre22Compat.java
@@ -41,8 +41,8 @@ public class Jre22Compat extends Jre21Compat {
 // Must be pre-Java 22
 log.debug(sm.getString("jre22Compat.javaPre22"), e);
 } catch (ReflectiveOperationException e) {
-// Should never happen
-log.error(sm.getString("jre22Compat.unexpected"), e);
+// Likely a previous API version
+log.debug(sm.getString("jre22Compat.unexpected"), e);
 }
 hasPanama = (m1 != null);
 }


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



[tomcat] branch 9.0.x updated: Explain the check and tone down the log

2023-08-04 Thread remm
This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/9.0.x by this push:
 new 53f8a89711 Explain the check and tone down the log
53f8a89711 is described below

commit 53f8a897111f78a1a24bc6fdd066cc122fbd906e
Author: remm 
AuthorDate: Fri Aug 4 20:59:59 2023 +0200

Explain the check and tone down the log
---
 java/org/apache/tomcat/util/compat/Jre22Compat.java | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/java/org/apache/tomcat/util/compat/Jre22Compat.java 
b/java/org/apache/tomcat/util/compat/Jre22Compat.java
index 486cc8a804..7520310400 100644
--- a/java/org/apache/tomcat/util/compat/Jre22Compat.java
+++ b/java/org/apache/tomcat/util/compat/Jre22Compat.java
@@ -41,8 +41,8 @@ public class Jre22Compat extends Jre21Compat {
 // Must be pre-Java 22
 log.debug(sm.getString("jre22Compat.javaPre22"), e);
 } catch (ReflectiveOperationException e) {
-// Should never happen
-log.error(sm.getString("jre22Compat.unexpected"), e);
+// Likely a previous API version
+log.debug(sm.getString("jre22Compat.unexpected"), e);
 }
 hasPanama = (m1 != null);
 }


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



Buildbot success in on tomcat-11.0.x

2023-08-04 Thread buildbot
Build status: Build succeeded!
Worker used: bb_worker2_ubuntu
URL: https://ci2.apache.org/#builders/112/builds/514
Blamelist: Mark Thomas 
Build Text: build successful
Status Detected: restored build
Build Source Stamp: [branch main] 231c282685d1fa9945f577e845a18d18bcabe5b1


Steps:

  worker_preparation: 0

  git: 0

  shell: 0

  shell_1: 0

  shell_2: 0

  shell_3: 0

  shell_4: 0

  shell_5: 0

  compile: 1

  shell_6: 0

  shell_7: 0

  shell_8: 0

  shell_9: 0

  Rsync docs to nightlies.apache.org: 0

  shell_10: 0

  Rsync RAT to nightlies.apache.org: 0

  compile_1: 1

  shell_11: 0

  Rsync Logs to nightlies.apache.org: 0


-- ASF Buildbot


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



Re: [tomcat] branch main updated: Add JreCompat for Java 22

2023-08-04 Thread Mark Thomas

On 04/08/2023 19:56, Rémy Maucherat wrote:

On Fri, Aug 4, 2023 at 8:47 PM Mark Thomas  wrote:


On 04/08/2023 08:13, r...@apache.org wrote:

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

remm 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 7e6af38a62 Add JreCompat for Java 22
7e6af38a62 is described below

commit 7e6af38a62b6354869f979ac718a270b70e6ec4d
Author: remm 
AuthorDate: Fri Aug 4 09:13:16 2023 +0200

  Add JreCompat for Java 22


This isn't working quite right.

The class is present in Java 21 (it is still visible even though it is


Yes, the class is present, but only with the preview flag.


It is visible to Class.forName whether preview is enabled or not. That 
makes the first error message not quite right.



preview) and the method is "getUtf8String" (I think).


It just got changed to "getString" in the panama branch, so this is
not an accident and this will detect the final API. However, I will
tone down the log (it is an error).


Ah, that makes sense.

Is it worth switching to checking for Console.isTerminal() or 
Thread.countStackFrames() to determine if we are running on Java 22?


Mark




Not sure on the bets way to handle this. Ideally, we want a class that
is only present in Java 22. There must be one somewhere. Just need to
find it...


Right now there are no unique new classes in "22" for Panama, only
some method changes.

Rémy


Mark




  Actually the one with the non preview Panama.
---
   .../org/apache/tomcat/util/compat/Jre22Compat.java | 54 
++
   java/org/apache/tomcat/util/compat/JreCompat.java  | 16 ++-
   .../tomcat/util/compat/LocalStrings.properties | 17 +++
   3 files changed, 86 insertions(+), 1 deletion(-)

diff --git a/java/org/apache/tomcat/util/compat/Jre22Compat.java 
b/java/org/apache/tomcat/util/compat/Jre22Compat.java
new file mode 100644
index 00..0b690164b6
--- /dev/null
+++ b/java/org/apache/tomcat/util/compat/Jre22Compat.java
@@ -0,0 +1,54 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.tomcat.util.compat;
+
+import java.lang.reflect.Method;
+
+import org.apache.juli.logging.Log;
+import org.apache.juli.logging.LogFactory;
+import org.apache.tomcat.util.res.StringManager;
+
+public class Jre22Compat extends JreCompat {
+
+private static final Log log = LogFactory.getLog(Jre22Compat.class);
+private static final StringManager sm = 
StringManager.getManager(Jre22Compat.class);
+
+private static final boolean hasPanama;
+
+
+static {
+Class c1 = null;
+Method m1 = null;
+
+try {
+c1 = Class.forName("java.lang.foreign.MemorySegment");
+m1 = c1.getMethod("getString", long.class);
+} catch (ClassNotFoundException e) {
+// Must be pre-Java 22
+log.debug(sm.getString("jre22Compat.javaPre22"), e);
+} catch (ReflectiveOperationException e) {
+// Should never happen
+log.error(sm.getString("jre22Compat.unexpected"), e);
+}
+hasPanama = (m1 != null);
+}
+
+static boolean isSupported() {
+return hasPanama;
+}
+
+}
diff --git a/java/org/apache/tomcat/util/compat/JreCompat.java 
b/java/org/apache/tomcat/util/compat/JreCompat.java
index 334115acc3..7273b0b233 100644
--- a/java/org/apache/tomcat/util/compat/JreCompat.java
+++ b/java/org/apache/tomcat/util/compat/JreCompat.java
@@ -25,6 +25,7 @@ public class JreCompat {

   private static final JreCompat instance;
   private static final boolean graalAvailable;
+private static final boolean jre22Available;

   static {
   boolean result = false;
@@ -39,7 +40,13 @@ public class JreCompat {
   graalAvailable = result || 
System.getProperty("org.graalvm.nativeimage.imagecode") != null;

   // This is Tomcat 11.0.x with a minimum Java version of Java 21.
-instance = new JreCompat();
+if (Jre22Compat.isSupported()) {
+instance = new Jre22Compat();
+jre22Available = true;
+} else {
+in

Re: [tomcat] branch main updated: Add JreCompat for Java 22

2023-08-04 Thread Rémy Maucherat
On Fri, Aug 4, 2023 at 9:04 PM Mark Thomas  wrote:
>
> On 04/08/2023 19:56, Rémy Maucherat wrote:
> > On Fri, Aug 4, 2023 at 8:47 PM Mark Thomas  wrote:
> >>
> >> On 04/08/2023 08:13, r...@apache.org wrote:
> >>> This is an automated email from the ASF dual-hosted git repository.
> >>>
> >>> remm 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 7e6af38a62 Add JreCompat for Java 22
> >>> 7e6af38a62 is described below
> >>>
> >>> commit 7e6af38a62b6354869f979ac718a270b70e6ec4d
> >>> Author: remm 
> >>> AuthorDate: Fri Aug 4 09:13:16 2023 +0200
> >>>
> >>>   Add JreCompat for Java 22
> >>
> >> This isn't working quite right.
> >>
> >> The class is present in Java 21 (it is still visible even though it is
> >
> > Yes, the class is present, but only with the preview flag.
>
> It is visible to Class.forName whether preview is enabled or not. That
> makes the first error message not quite right.
>
> >> preview) and the method is "getUtf8String" (I think).
> >
> > It just got changed to "getString" in the panama branch, so this is
> > not an accident and this will detect the final API. However, I will
> > tone down the log (it is an error).
>
> Ah, that makes sense.
>
> Is it worth switching to checking for Console.isTerminal() or
> Thread.countStackFrames() to determine if we are running on Java 22?

Yes, I'll change the first check then. I'll keep the second one for
now though if you don't mind since it would detect the non preview API
(the JVM must be from https://github.com/openjdk/panama-foreign ).

Rémy

> Mark
>
> >
> >> Not sure on the bets way to handle this. Ideally, we want a class that
> >> is only present in Java 22. There must be one somewhere. Just need to
> >> find it...
> >
> > Right now there are no unique new classes in "22" for Panama, only
> > some method changes.
> >
> > Rémy
> >
> >> Mark
> >>
> >>
> >>>
> >>>   Actually the one with the non preview Panama.
> >>> ---
> >>>.../org/apache/tomcat/util/compat/Jre22Compat.java | 54 
> >>> ++
> >>>java/org/apache/tomcat/util/compat/JreCompat.java  | 16 ++-
> >>>.../tomcat/util/compat/LocalStrings.properties | 17 +++
> >>>3 files changed, 86 insertions(+), 1 deletion(-)
> >>>
> >>> diff --git a/java/org/apache/tomcat/util/compat/Jre22Compat.java 
> >>> b/java/org/apache/tomcat/util/compat/Jre22Compat.java
> >>> new file mode 100644
> >>> index 00..0b690164b6
> >>> --- /dev/null
> >>> +++ b/java/org/apache/tomcat/util/compat/Jre22Compat.java
> >>> @@ -0,0 +1,54 @@
> >>> +/*
> >>> + *  Licensed to the Apache Software Foundation (ASF) under one or more
> >>> + *  contributor license agreements.  See the NOTICE file distributed with
> >>> + *  this work for additional information regarding copyright ownership.
> >>> + *  The ASF licenses this file to You under the Apache License, Version 
> >>> 2.0
> >>> + *  (the "License"); you may not use this file except in compliance with
> >>> + *  the License.  You may obtain a copy of the License at
> >>> + *
> >>> + *  http://www.apache.org/licenses/LICENSE-2.0
> >>> + *
> >>> + *  Unless required by applicable law or agreed to in writing, software
> >>> + *  distributed under the License is distributed on an "AS IS" BASIS,
> >>> + *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 
> >>> implied.
> >>> + *  See the License for the specific language governing permissions and
> >>> + *  limitations under the License.
> >>> + */
> >>> +package org.apache.tomcat.util.compat;
> >>> +
> >>> +import java.lang.reflect.Method;
> >>> +
> >>> +import org.apache.juli.logging.Log;
> >>> +import org.apache.juli.logging.LogFactory;
> >>> +import org.apache.tomcat.util.res.StringManager;
> >>> +
> >>> +public class Jre22Compat extends JreCompat {
> >>> +
> >>> +private static final Log log = LogFactory.getLog(Jre22Compat.class);
> >>> +private static final StringManager sm = 
> >>> StringManager.getManager(Jre22Compat.class);
> >>> +
> >>> +private static final boolean hasPanama;
> >>> +
> >>> +
> >>> +static {
> >>> +Class c1 = null;
> >>> +Method m1 = null;
> >>> +
> >>> +try {
> >>> +c1 = Class.forName("java.lang.foreign.MemorySegment");
> >>> +m1 = c1.getMethod("getString", long.class);
> >>> +} catch (ClassNotFoundException e) {
> >>> +// Must be pre-Java 22
> >>> +log.debug(sm.getString("jre22Compat.javaPre22"), e);
> >>> +} catch (ReflectiveOperationException e) {
> >>> +// Should never happen
> >>> +log.error(sm.getString("jre22Compat.unexpected"), e);
> >>> +}
> >>> +hasPanama = (m1 != null);
> >>> +}
> >>> +
> >>> +static boolean isSupported() {
> >>> +return hasPanama;
> >>> +}
> >>> +
> >>> +}
> >>> diff --git a/java/org

[tomcat] branch main updated: Improve and add a todo

2023-08-04 Thread remm
This is an automated email from the ASF dual-hosted git repository.

remm 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 132597fd40 Improve and add a todo
132597fd40 is described below

commit 132597fd405e49ebdeccf8096eb0a905bb112479
Author: remm 
AuthorDate: Fri Aug 4 22:04:01 2023 +0200

Improve and add a todo
---
 java/org/apache/tomcat/util/compat/Jre22Compat.java | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/java/org/apache/tomcat/util/compat/Jre22Compat.java 
b/java/org/apache/tomcat/util/compat/Jre22Compat.java
index 4d40da80c8..6e5416694c 100644
--- a/java/org/apache/tomcat/util/compat/Jre22Compat.java
+++ b/java/org/apache/tomcat/util/compat/Jre22Compat.java
@@ -31,17 +31,21 @@ public class Jre22Compat extends JreCompat {
 
 
 static {
+// FIXME: Improve check using a new class in 22 later
 Class c1 = null;
+Class c2 = null;
 Method m1 = null;
 
 try {
 c1 = Class.forName("java.lang.foreign.MemorySegment");
+c2 = Class.forName("java.io.Console");
 m1 = c1.getMethod("getString", long.class);
+c2.getMethod("isTerminal");
 } catch (ClassNotFoundException e) {
 // Must be pre-Java 22
 log.debug(sm.getString("jre22Compat.javaPre22"), e);
 } catch (ReflectiveOperationException e) {
-// Likely a previous API version
+// Likely a previous Panama API version
 log.debug(sm.getString("jre22Compat.unexpected"), e);
 }
 hasPanama = (m1 != null);


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



[tomcat] branch 10.1.x updated: Improve and add a todo

2023-08-04 Thread remm
This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/10.1.x by this push:
 new d9b3c63906 Improve and add a todo
d9b3c63906 is described below

commit d9b3c63906238f06276f99a57536f82364a47802
Author: remm 
AuthorDate: Fri Aug 4 22:04:01 2023 +0200

Improve and add a todo
---
 java/org/apache/tomcat/util/compat/Jre22Compat.java | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/java/org/apache/tomcat/util/compat/Jre22Compat.java 
b/java/org/apache/tomcat/util/compat/Jre22Compat.java
index 7520310400..d685cd56ec 100644
--- a/java/org/apache/tomcat/util/compat/Jre22Compat.java
+++ b/java/org/apache/tomcat/util/compat/Jre22Compat.java
@@ -31,17 +31,21 @@ public class Jre22Compat extends Jre21Compat {
 
 
 static {
+// FIXME: Improve check using a new class in 22 later
 Class c1 = null;
+Class c2 = null;
 Method m1 = null;
 
 try {
 c1 = Class.forName("java.lang.foreign.MemorySegment");
+c2 = Class.forName("java.io.Console");
 m1 = c1.getMethod("getString", long.class);
+c2.getMethod("isTerminal");
 } catch (ClassNotFoundException e) {
 // Must be pre-Java 22
 log.debug(sm.getString("jre22Compat.javaPre22"), e);
 } catch (ReflectiveOperationException e) {
-// Likely a previous API version
+// Likely a previous Panama API version
 log.debug(sm.getString("jre22Compat.unexpected"), e);
 }
 hasPanama = (m1 != null);


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



[tomcat] branch 9.0.x updated: Improve and add a todo

2023-08-04 Thread remm
This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/9.0.x by this push:
 new aa77cb2cc3 Improve and add a todo
aa77cb2cc3 is described below

commit aa77cb2cc39225a805f9be47bd8b992b62c4f2e7
Author: remm 
AuthorDate: Fri Aug 4 22:04:01 2023 +0200

Improve and add a todo
---
 java/org/apache/tomcat/util/compat/Jre22Compat.java | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/java/org/apache/tomcat/util/compat/Jre22Compat.java 
b/java/org/apache/tomcat/util/compat/Jre22Compat.java
index 7520310400..d685cd56ec 100644
--- a/java/org/apache/tomcat/util/compat/Jre22Compat.java
+++ b/java/org/apache/tomcat/util/compat/Jre22Compat.java
@@ -31,17 +31,21 @@ public class Jre22Compat extends Jre21Compat {
 
 
 static {
+// FIXME: Improve check using a new class in 22 later
 Class c1 = null;
+Class c2 = null;
 Method m1 = null;
 
 try {
 c1 = Class.forName("java.lang.foreign.MemorySegment");
+c2 = Class.forName("java.io.Console");
 m1 = c1.getMethod("getString", long.class);
+c2.getMethod("isTerminal");
 } catch (ClassNotFoundException e) {
 // Must be pre-Java 22
 log.debug(sm.getString("jre22Compat.javaPre22"), e);
 } catch (ReflectiveOperationException e) {
-// Likely a previous API version
+// Likely a previous Panama API version
 log.debug(sm.getString("jre22Compat.unexpected"), e);
 }
 hasPanama = (m1 != null);


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