[ 
https://issues.apache.org/jira/browse/ARTEMIS-5711?focusedWorklogId=988225&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-988225
 ]

ASF GitHub Bot logged work on ARTEMIS-5711:
-------------------------------------------

                Author: ASF GitHub Bot
            Created on: 21/Oct/25 16:22
            Start Date: 21/Oct/25 16:22
    Worklog Time Spent: 10m 
      Work Description: gemmellr commented on code in PR #5993:
URL: https://github.com/apache/activemq-artemis/pull/5993#discussion_r2448943302


##########
artemis-commons/src/main/java/org/apache/activemq/artemis/utils/sm/SecurityManagerShim.java:
##########
@@ -0,0 +1,196 @@
+/*
+ * 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.activemq.artemis.utils.sm;
+
+import java.security.AccessControlContext;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+import java.util.Objects;
+import java.util.concurrent.Callable;
+import java.util.concurrent.CompletionException;
+
+import javax.security.auth.Subject;
+
+/*
+ * SecurityManager related shim.
+ * This specific class uses legacy methods toward usage on Java 17 - 23.
+ *
+ * The API of this class must be kept the same as the Java 24+ implementation
+ * variant of this class which can be found at:
+ * 
src/main/java24/org/apache/activemq/artemis/utils/sm/SecurityManagerShim.java

Review Comment:
   We definitely could yes but I just opted against it, since then we need the 
third file and also then need to create an instance of the classes and first 
get it from every location this is being used since the usages are all static. 
(Initially I was also like, oh can I use a static interface method for probably 
the first time?...then realised no, since it would just mean two copies of the 
interface :P)
   
   I don't see it being much of an issue to keep these in sync since, since I 
dont really see them actually being changed much at all, other than to 
eventually to remove the SecurityManager methods whenever we actually delete 
the usages of it, or remove the shim entirely, e.g with switch to a Java 25 
minimum (perhaps if using netty 5 eventually becomes a thing 
https://github.com/netty/netty/pull/15676).





Issue Time Tracking
-------------------

    Worklog Id:     (was: 988225)
    Time Spent: 50m  (was: 40m)

> Enable support for building and running on Java 25
> --------------------------------------------------
>
>                 Key: ARTEMIS-5711
>                 URL: https://issues.apache.org/jira/browse/ARTEMIS-5711
>             Project: ActiveMQ Artemis
>          Issue Type: Improvement
>    Affects Versions: 2.43.0
>            Reporter: Robbie Gemmell
>            Assignee: Robbie Gemmell
>            Priority: Major
>              Labels: pull-request-available
>             Fix For: 2.44.0
>
>          Time Spent: 50m
>  Remaining Estimate: 0h
>
> The Java SecurityManager was deprecated in Java 17 for removal, with no aim 
> to replace the functionality. The Subject class also uses parts of the 
> SecurityManager API, but it has its own usages beyond the SecurityManager 
> functionality, so replacement functionality for the affected methods were 
> added in Java 18 in the Subject.current() and Subject.callAs(..) methods.
> Java 23 began the process for removing the SecurityManager implementation, 
> reimplementing the Subject methods with both the old and newer behaviours, 
> and making Subject.getSubject(..) throw UnsupportedOperationException unless 
> an option flag is used to enable support for a SecurityManager (still without 
> actually needing to have an SM in use). [Java 24 actually removed the 
> SecurityManager implementation|https://openjdk.org/jeps/486] , and made 
> Subject.getSubject() always throw UnsupportedOperationException. As a result 
> of these changes, building and testing Artemis does not work on Java 23+ 
> currently, and there are issues running on Java 23+ without at least 
> disabling the AuditLogging functionality that uses Subject.getSubject(..). 
> These issues can be seen discussed in the referenced ARTEMIS-4975 and 
> ARTEMIS-5374. Though the other SecurityManager APIs are still present and 
> 'functional' (effectively passthroughs), the APIs will be removed in a future 
> JDK which will itself present another issue to building and running on those 
> JDKs
> This Jira seeks to enable building/testing and running on Java 25 and beyond 
> by addressing these issues. To achieve this, references to the 
> SecurityManager / Subject APIs affected will be contained to a wrapper shim, 
> with an implementation using the old methods targeting Java 17-23, and a 
> second shim implementation using the new Subject methods (and not using any 
> SecurityManager methods at all) targeting Java 24+ and thus enabling Java 25 
> support and avoiding issues when the old APIs are later removed. (NOTE: on 
> Java 23 this approach will still requiring either the flag to enable 
> SecurityManager support, or disabling the audit logging to avoid it calling 
> Subject.getSubject(..), if not just upgrading to e.g a supported Java 25 
> release)
> Whilst it will still be possible to run/build/test on Java 17+, a side effect 
> of this approach will be requiring that releases are created using Java 25, 
> which was [discussed and agreed on the mailing 
> lists|https://lists.apache.org/thread/7vspfpmfnfqd6fmvpjzm0kr59b5dm9j2].



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information, visit: https://activemq.apache.org/contact


Reply via email to