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

clebertsuconic pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git


The following commit(s) were added to refs/heads/main by this push:
     new 45a1245cb0 ARTEMIS-3963 Fix setting security roles via properties on 
OpenJ9 JDK 11
45a1245cb0 is described below

commit 45a1245cb0cf823495ef69df352e190dc94e10cd
Author: Domenico Francesco Bruscino <[email protected]>
AuthorDate: Tue Aug 30 09:17:18 2022 +0200

    ARTEMIS-3963 Fix setting security roles via properties on OpenJ9 JDK 11
    
    RoleSet.class.getMethods() returns the same methods on both OpenJDK 11 and
    OpenJ9 JDK 11 but the order is different. OpenJDK 11 returns
    `public void org.apache.activemq.artemis.core.config.impl.RoleSet.add` 
before
    `public boolean java.util.HashSet.add` while OpenJ9 JDK 11 returns
    `public boolean java.util.HashSet.add` before
    `public void org.apache.activemq.artemis.core.config.impl.RoleSet.add`
---
 .../apache/activemq/artemis/core/config/impl/ConfigurationImpl.java  | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git 
a/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/impl/ConfigurationImpl.java
 
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/impl/ConfigurationImpl.java
index 5e57058d94..e69e0eed0a 100644
--- 
a/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/impl/ConfigurationImpl.java
+++ 
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/impl/ConfigurationImpl.java
@@ -31,6 +31,7 @@ import java.io.StringWriter;
 import java.lang.reflect.Array;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
 import java.net.URI;
 import java.net.URL;
 import java.security.AccessController;
@@ -2967,9 +2968,9 @@ public class ConfigurationImpl implements Configuration, 
Serializable {
          }
 
          // we don't know the type, infer from add method add(X x) or 
add(String key, X x)
-         final Method[] methods = hostingBean.getClass().getMethods();
+         final Method[] methods = hostingBean.getClass().getDeclaredMethods();
          for (Method candidate : methods) {
-            if (candidate.getName().equals(addPropertyName) &&
+            if (Modifier.isPublic(candidate.getModifiers()) && 
candidate.getName().equals(addPropertyName) &&
                (candidate.getParameterCount() == 1 ||
                   (candidate.getParameterCount() == 2
                      // has a String key

Reply via email to