LOGGER.error("Unable to locate or load configured ThreadContextMap {}", provider.getThreadContextMap(), e); result = createDefaultThreadContextMap(); result = createDefaultThreadContextMap();
/** * <em>Consider private, used for testing.</em> */ static void init() { ThreadContextMapFactory.init(); contextMap = null; final PropertiesUtil managerProps = PropertiesUtil.getProperties(); disableAll = managerProps.getBooleanProperty(DISABLE_ALL); useStack = !(managerProps.getBooleanProperty(DISABLE_STACK) || disableAll); useMap = !(managerProps.getBooleanProperty(DISABLE_MAP) || disableAll); contextStack = new DefaultThreadContextStack(useStack); if (!useMap) { contextMap = new NoOpThreadContextMap(); } else { contextMap = ThreadContextMapFactory.createThreadContextMap(); } if (contextMap instanceof ReadOnlyThreadContextMap) { readOnlyContextMap = (ReadOnlyThreadContextMap) contextMap; } else { readOnlyContextMap = null; } }
/** * Initializes static variables based on system properties. Normally called when this class is initialized by the VM * and when Log4j is reconfigured. */ public static void init() { CopyOnWriteSortedArrayThreadContextMap.init(); GarbageFreeSortedArrayThreadContextMap.init(); DefaultThreadContextMap.init(); initPrivate(); }
@Test public void testThreadLocalInheritableIfConfigured() { System.setProperty(DefaultThreadContextMap.INHERITABLE_MAP, "true"); ThreadContextMapFactory.init(); try { final ThreadLocal<Map<String, String>> threadLocal = DefaultThreadContextMap.createThreadLocalMap(true); assertTrue(threadLocal instanceof InheritableThreadLocal<?>); } finally { System.clearProperty(DefaultThreadContextMap.INHERITABLE_MAP); } } }
LOGGER.error("Unable to locate or load configured ThreadContextMap {}", provider.getThreadContextMap(), e); result = createDefaultThreadContextMap(); result = createDefaultThreadContextMap();