rgoers commented on code in PR #2385: URL: https://github.com/apache/logging-log4j2/pull/2385#discussion_r1533312285
########## log4j-api/src/main/java/org/apache/logging/log4j/internal/ScopedContextAnchor.java: ########## @@ -0,0 +1,69 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to you under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.logging.log4j.internal; + +import java.util.ArrayDeque; +import java.util.Deque; +import java.util.Optional; +import org.apache.logging.log4j.ScopedContext; + +/** + * Anchor for the ScopedContext. This class is private and not for public consumption. + */ +public class ScopedContextAnchor { + private static final ThreadLocal<Deque<ScopedContext>> scopedContext = new ThreadLocal<>(); Review Comment: 1. This is NOT meant for only Java 21 and above. It is targeted at Log4j API which still supports Java 8. 2. ThreadLocals are NOT risky even with Virtual Threads when they are used in this way. I specifically looked for a mention of being able to disable ThreadLocals and could not find anything as I recall you previously mentioning that. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@logging.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org