This is an automated email from the ASF dual-hosted git repository.
mattrpav pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/activemq.git
The following commit(s) were added to refs/heads/main by this push:
new 7c81d73d8a [AMQ-9563] Remove usage of java.security.AccessController
where possible. Document JDK 21 refactor TODO
7c81d73d8a is described below
commit 7c81d73d8a04cad9407e58edf53a1d28a6fed370
Author: Matt Pavlovich <[email protected]>
AuthorDate: Tue Sep 3 10:01:40 2024 -0500
[AMQ-9563] Remove usage of java.security.AccessController where possible.
Document JDK 21 refactor TODO
---
.../apache/activemq/broker/jmx/AnnotatedMBean.java | 1 +
.../apache/activemq/ActiveMQConnectionFactory.java | 38 +++++-----------------
2 files changed, 10 insertions(+), 29 deletions(-)
diff --git
a/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/AnnotatedMBean.java
b/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/AnnotatedMBean.java
index dfae72bf10..51c135ddf5 100644
---
a/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/AnnotatedMBean.java
+++
b/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/AnnotatedMBean.java
@@ -205,6 +205,7 @@ public class AnnotatedMBean extends StandardMBean {
objects = (objects == null) ? new Object[]{} : objects;
JMXAuditLogEntry entry = null;
if (audit != OFF) {
+ // [AMQ-9563] TODO: JDK 21 use Subject.current() instead
Subject subject =
Subject.getSubject(AccessController.getContext());
String caller = "anonymous";
if (subject != null) {
diff --git
a/activemq-client/src/main/java/org/apache/activemq/ActiveMQConnectionFactory.java
b/activemq-client/src/main/java/org/apache/activemq/ActiveMQConnectionFactory.java
index 8c68d5ee65..54969f39ce 100644
---
a/activemq-client/src/main/java/org/apache/activemq/ActiveMQConnectionFactory.java
+++
b/activemq-client/src/main/java/org/apache/activemq/ActiveMQConnectionFactory.java
@@ -19,8 +19,6 @@ package org.apache.activemq;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
import java.util.*;
import java.util.concurrent.RejectedExecutionHandler;
@@ -67,23 +65,12 @@ public class ActiveMQConnectionFactory extends
JNDIBaseStorable implements Conne
String host = null;
String port = null;
try {
- host = AccessController.doPrivileged(new
PrivilegedAction<String>() {
- @Override
- public String run() {
- String result =
System.getProperty("org.apache.activemq.AMQ_HOST");
- result = (result==null||result.isEmpty()) ?
System.getProperty("AMQ_HOST","localhost") : result;
- return result;
- }
- });
- port = AccessController.doPrivileged(new
PrivilegedAction<String>() {
- @Override
- public String run() {
- String result =
System.getProperty("org.apache.activemq.AMQ_PORT");
- result = (result==null||result.isEmpty()) ?
System.getProperty("AMQ_PORT","61616") : result;
- return result;
- }
- });
- }catch(Throwable e){
+ host = System.getProperty("org.apache.activemq.AMQ_HOST");
+ host = (host==null||host.isBlank()) ?
System.getProperty("AMQ_HOST","localhost") : host;
+
+ port = System.getProperty("org.apache.activemq.AMQ_PORT");
+ port = (port==null||port.isBlank()) ?
System.getProperty("AMQ_PORT","61616") : port;
+ } catch(Throwable e){
LOG.debug("Failed to look up System properties for host and
port",e);
}
host = (host == null || host.isEmpty()) ? "localhost" : host;
@@ -92,7 +79,6 @@ public class ActiveMQConnectionFactory extends
JNDIBaseStorable implements Conne
DEFAULT_BROKER_PORT = Integer.parseInt(port);
}
-
public static final String DEFAULT_BROKER_BIND_URL;
static{
@@ -100,15 +86,9 @@ public class ActiveMQConnectionFactory extends
JNDIBaseStorable implements Conne
String bindURL = null;
try {
- bindURL = AccessController.doPrivileged(new
PrivilegedAction<String>() {
- @Override
- public String run() {
- String result =
System.getProperty("org.apache.activemq.BROKER_BIND_URL");
- result = (result==null||result.isEmpty()) ?
System.getProperty("BROKER_BIND_URL",defaultURL) : result;
- return result;
- }
- });
- }catch(Throwable e){
+ bindURL =
System.getProperty("org.apache.activemq.BROKER_BIND_URL");
+ bindURL = (bindURL==null||bindURL.isEmpty()) ?
System.getProperty("BROKER_BIND_URL",defaultURL) : bindURL;
+ } catch(Throwable e){
LOG.debug("Failed to look up System properties for host and
port",e);
}
bindURL = (bindURL == null || bindURL.isEmpty()) ? defaultURL :
bindURL;
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information, visit: https://activemq.apache.org/contact