You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by kw...@apache.org on 2018/01/23 15:21:51 UTC
[sling-org-apache-sling-commons-threads] branch master updated:
SLING-7433 Improve logging in case ThreadLocalCleaner does not work
This is an automated email from the ASF dual-hosted git repository.
kwin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-threads.git
The following commit(s) were added to refs/heads/master by this push:
new 1ffb9d9 SLING-7433 Improve logging in case ThreadLocalCleaner does not work
1ffb9d9 is described below
commit 1ffb9d9c12637e790151ad499cfb2c5738e9dbdd
Author: Konrad Windszus <kw...@apache.org>
AuthorDate: Tue Jan 23 16:21:37 2018 +0100
SLING-7433 Improve logging in case ThreadLocalCleaner does not work
---
.../impl/ThreadPoolExecutorCleaningThreadLocals.java | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/src/main/java/org/apache/sling/commons/threads/impl/ThreadPoolExecutorCleaningThreadLocals.java b/src/main/java/org/apache/sling/commons/threads/impl/ThreadPoolExecutorCleaningThreadLocals.java
index 8e62410..922f18b 100644
--- a/src/main/java/org/apache/sling/commons/threads/impl/ThreadPoolExecutorCleaningThreadLocals.java
+++ b/src/main/java/org/apache/sling/commons/threads/impl/ThreadPoolExecutorCleaningThreadLocals.java
@@ -52,14 +52,22 @@ public class ThreadPoolExecutorCleaningThreadLocals extends ThreadPoolExecutor {
protected void beforeExecute(Thread t, Runnable r) {
LOGGER.debug("Collecting changes to ThreadLocal for thread {} from now on...", t);
- ThreadLocalCleaner cleaner = new ThreadLocalCleaner(listener);
- local.set(cleaner);
+ try {
+ ThreadLocalCleaner cleaner = new ThreadLocalCleaner(listener);
+ local.set(cleaner);
+ } catch (Throwable e) {
+ LOGGER.warn("Could not set up thread local cleaner (most probably not a compliant JRE): {}", e, e);
+ }
}
protected void afterExecute(Runnable r, Throwable t) {
LOGGER.debug("Cleaning up thread locals for thread {}...", Thread.currentThread());
ThreadLocalCleaner cleaner = local.get();
+ if (cleaner != null) {
+ cleaner.cleanup();
+ } else {
+ LOGGER.warn("Could not clean up thread locals in thread {} as the cleaner was not set up correctly", Thread.currentThread());
+ }
local.remove();
- cleaner.cleanup();
}
}
--
To stop receiving notification emails like this one, please contact
kwin@apache.org.