Trigger log4j loading prior to context classloader (elastic/x-pack-elasticsearch#4355)
OpenSAML requires that the context classloader be set to the classloader that contains the opensaml jar files in order to initialise itself. However, sometimesrthis seems to cause the classloading for slf4j/log4j to take place while that context classloader is set, which fails. This change forces slf4j/log4j to be initialised prior to setting the context classloader. Original commit: elastic/x-pack-elasticsearch@85ed8eb488
This commit is contained in:
parent
fa44406cea
commit
7cd99d2f96
|
@ -52,8 +52,8 @@ import org.opensaml.core.xml.io.MarshallingException;
|
|||
import org.opensaml.core.xml.util.XMLObjectSupport;
|
||||
import org.opensaml.saml.common.SAMLObject;
|
||||
import org.opensaml.saml.saml2.core.Assertion;
|
||||
import org.opensaml.saml.saml2.core.NameID;
|
||||
import org.opensaml.saml.saml2.core.Response;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.bootstrap.DOMImplementationRegistry;
|
||||
import org.w3c.dom.ls.DOMImplementationLS;
|
||||
|
@ -81,6 +81,8 @@ public class SamlUtils {
|
|||
*/
|
||||
static void initialize(Logger logger) throws PrivilegedActionException {
|
||||
if (INITIALISED.compareAndSet(false, true)) {
|
||||
// We want to force these classes to be loaded _before_ we fiddle with the context classloader
|
||||
LoggerFactory.getLogger(InitializationService.class);
|
||||
SpecialPermission.check();
|
||||
AccessController.doPrivileged((PrivilegedExceptionAction<Void>) () -> {
|
||||
logger.debug("Initializing OpenSAML");
|
||||
|
|
Loading…
Reference in New Issue