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`
This commit is contained in:
Domenico Francesco Bruscino 2022-08-30 09:17:18 +02:00 committed by clebertsuconic
parent a220678552
commit 45a1245cb0
1 changed files with 3 additions and 2 deletions

View File

@ -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