ARTEMIS-4322 BundleFactory should use PrivilegedAction
This commit is contained in:
parent
dc4bf953e3
commit
950040b62b
|
@ -17,6 +17,8 @@
|
||||||
package org.apache.activemq.artemis.logs;
|
package org.apache.activemq.artemis.logs;
|
||||||
|
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
|
import java.security.AccessController;
|
||||||
|
import java.security.PrivilegedAction;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -29,6 +31,14 @@ public class BundleFactory {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T> T newBundle(final Class<T> type, String category) {
|
public static <T> T newBundle(final Class<T> type, String category) {
|
||||||
|
if (System.getSecurityManager() == null) {
|
||||||
|
return doNewBundle(type, category);
|
||||||
|
} else {
|
||||||
|
return AccessController.doPrivileged((PrivilegedAction<T>) () -> doNewBundle(type, category));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static <T> T doNewBundle(final Class<T> type, String category) {
|
||||||
final String implClassName = type.getName() + "_impl";
|
final String implClassName = type.getName() + "_impl";
|
||||||
|
|
||||||
final Class<? extends T> implClass;
|
final Class<? extends T> implClass;
|
||||||
|
|
Loading…
Reference in New Issue