On 25/07/2024 11:31, Michael Osipov wrote:
On 2024/07/25 08:42:52 ma...@apache.org wrote:
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 a2384804c527c64290cfae1fa988f1f394890e91
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Wed Jul 24 17:51:24 2024 +0100

     Add JreCompat support for Subject.callAs()
With the changes coming in Java 23 we need to move away from
     Subject.doAs() but the replacement isn't available in Java 17. Hence use
     JreCompat.
---
  .../org/apache/tomcat/util/compat/Jre18Compat.java | 71 ++++++++++++++++++++++
  .../org/apache/tomcat/util/compat/Jre19Compat.java |  2 +-
  java/org/apache/tomcat/util/compat/JreCompat.java  | 39 ++++++++++++
  .../tomcat/util/compat/LocalStrings.properties     |  1 +
  4 files changed, 112 insertions(+), 1 deletion(-)

diff --git a/java/org/apache/tomcat/util/compat/Jre18Compat.java 
b/java/org/apache/tomcat/util/compat/Jre18Compat.java
new file mode 100644
index 0000000000..b83999f179
--- /dev/null
+++ b/java/org/apache/tomcat/util/compat/Jre18Compat.java
@@ -0,0 +1,71 @@
+/*
+ *  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.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.concurrent.Callable;
+import java.util.concurrent.CompletionException;
+
+import javax.security.auth.Subject;
+
+import org.apache.juli.logging.Log;
+import org.apache.juli.logging.LogFactory;
+import org.apache.tomcat.util.res.StringManager;
+
+public class Jre18Compat extends JreCompat {
+
+    private static final Log log = LogFactory.getLog(Jre18Compat.class);
+    private static final StringManager sm = 
StringManager.getManager(Jre18Compat.class);
+
+    private static final Method callAsMethod;
+
+    static {
+        Method m1 = null;
+
+        try {
+            m1 = Subject.class.getMethod("classAS", Subject.class, 
Callable.class);

Am I stupid or isn't the method called "callAs"?

https://docs.oracle.com/en/java/javase/21/docs/api/java.base/javax/security/auth/Subject.html#callAs(javax.security.auth.Subject,java.util.concurrent.Callable)

My typo. Not sure how I managed to get from "callAs" to that. I'm in the middle of updating my test environment so I could check that commit. I'll fix that now. I don't plan to back-port until I confirm everything is working as expected.

Mark

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

Reply via email to