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:07:52 UTC
[sling-org-apache-sling-commons-threads] branch master updated:
SLING-7320 guard against NPE happening when initReflectionFields fails
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 bb1ec98 SLING-7320 guard against NPE happening when initReflectionFields fails
bb1ec98 is described below
commit bb1ec98753d7972a63d961e81725796ac2a918a8
Author: Konrad Windszus <kw...@apache.org>
AuthorDate: Tue Jan 23 16:07:39 2018 +0100
SLING-7320 guard against NPE happening when initReflectionFields fails
---
.../org/apache/sling/commons/threads/impl/ThreadLocalCleaner.java | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/main/java/org/apache/sling/commons/threads/impl/ThreadLocalCleaner.java b/src/main/java/org/apache/sling/commons/threads/impl/ThreadLocalCleaner.java
index 98f264f..b755034 100644
--- a/src/main/java/org/apache/sling/commons/threads/impl/ThreadLocalCleaner.java
+++ b/src/main/java/org/apache/sling/commons/threads/impl/ThreadLocalCleaner.java
@@ -31,7 +31,7 @@ public class ThreadLocalCleaner {
/* Reflection fields */
/** this field is in class {@link ThreadLocal} and is of type {@code ThreadLocal.ThreadLocalMap} */
- private static Field threadLocalsField;
+ private static volatile Field threadLocalsField;
/** this field is in class {@link ThreadLocal} and is of type {@code ThreadLocal.ThreadLocalMap} */
private static Field inheritableThreadLocalsField;
private static Class<?> threadLocalMapClass;
@@ -45,11 +45,11 @@ public class ThreadLocalCleaner {
private static Field threadLocalMapSizeField;
/** this field is in the class {@code ThreadLocal.ThreadLocalMap} and next resize threshold */
private static Field threadLocalMapThresholdField;
- private static IllegalStateException reflectionException;
+ private static volatile IllegalStateException reflectionException;
public ThreadLocalCleaner(ThreadLocalChangeListener listener) {
- if (threadLocalsField == null) {
+ if (threadLocalsField == null || reflectionException != null) {
initReflectionFields();
}
this.listener = listener;
@@ -75,7 +75,7 @@ public class ThreadLocalCleaner {
} catch (NoSuchFieldException e) {
reflectionException = new IllegalStateException(
"Could not locate threadLocals field in class Thread. " +
- "Will not be able to clear thread locals: " + e);
+ "Will not be able to clear thread locals: " + e, e);
throw reflectionException;
}
}
--
To stop receiving notification emails like this one, please contact
kwin@apache.org.