private Context createInitialContext()

in src/main/java/org/apache/sling/jcr/registration/impl/JndiRegistrationSupport.java [130:146]


    private Context createInitialContext(final Properties env) throws NamingException {
        try {
            return AccessController.doPrivileged((PrivilegedExceptionAction<Context>) () -> {
                Thread currentThread = Thread.currentThread();
                ClassLoader old = currentThread.getContextClassLoader();
                currentThread.setContextClassLoader(JndiRegistrationSupport.this.getClass().getClassLoader());
                try {
                    return new InitialContext(env);
                } finally {
                    currentThread.setContextClassLoader(old);
                }
            });
        } catch (PrivilegedActionException pae) {
            // we now that this method only throws a NamingException
            throw (NamingException) pae.getCause();
        }
    }