Hi, On Sun, 2021-10-17 at 14:26 -0500, Paul Bjorkstrand wrote: > As far as I understand, thread locals' storage is an implementation > detail > in the JVM. There isn't an API to clear all/arbitrary thread locals. > Thread > pools, or applications that use thread pools, need to provide hooks to > do > that, so that code can do its own cleanup. This is exactly what the > request listener that Carsten mentioned does.
Sling's thread pool actually cleans up thread locals after execution [1]. It's not yet fixed for Java 17 though [2]. [1]: https://github.com/apache/sling-org-apache-sling-commons-threads/blob/org.apache.sling.commons.threads-3.2.22/src/main/java/org/apache/sling/commons/threads/impl/ThreadPoolExecutorCleaningThreadLocals.java [2]: https://issues.apache.org/jira/browse/SLING-10831 Thanks, Robert
