Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Minor simplification and clarification.

  • Loading branch information...
commit bdb5e8f815f4aa5370e689565ea9193db257752d 1 parent be8bf4d
Toby Crawley tobias authored
15 runtime/impl/src/main/java/org/immutant/runtime/impl/ClojureRuntimeImpl.java
View
@@ -26,7 +26,6 @@
import org.jboss.logging.Logger;
import clojure.lang.Agent;
-import clojure.lang.ArraySeq;
import clojure.lang.LockingTransaction;
import clojure.lang.RT;
import clojure.lang.Symbol;
@@ -45,9 +44,13 @@ protected void postInvoke(ClassLoader originalClassloader) {
try {
// leaving these thread locals around will cause memory leaks when the application
// is undeployed.
+ removeThreadLocal( LockingTransaction.class, "transaction" );
removeThreadLocal( Var.class, "dvals" );
+
+ // this one doesn't leak, but leaving it set can theoretically allow another
+ // application to read the value off of the thread when it is doled out
+ //again from the pool
removeThreadLocal( Agent.class, "nested" );
- removeThreadLocal( LockingTransaction.class, "transaction" );
} catch (Exception e) {
log.error( "Failed to clear thread locals: ", e );
} finally {
@@ -73,7 +76,7 @@ protected Var var(String namespacedFunction) {
@SuppressWarnings("rawtypes")
protected void removeThreadLocal( Class klass, String fieldName ) throws Exception {
- Field field = lookupField( klass, fieldName, true );
+ Field field = lookupField( klass, fieldName );
if (field != null) {
ThreadLocal tl = (ThreadLocal)field.get( null );
if (tl != null) {
@@ -83,7 +86,7 @@ protected void removeThreadLocal( Class klass, String fieldName ) throws Excepti
}
@SuppressWarnings("rawtypes")
- protected Field lookupField(Class klass, String fieldName, boolean makeAccessible) throws NoSuchFieldException {
+ protected Field lookupField(Class klass, String fieldName) throws NoSuchFieldException {
Map<String, Field> fields = this.fieldCache.get( klass );
if (fields == null) {
fields = new HashMap<String, Field>();
@@ -93,9 +96,7 @@ protected Field lookupField(Class klass, String fieldName, boolean makeAccessibl
Field field = fields.get( fieldName );
if (field == null) {
field = klass.getDeclaredField( fieldName );
- if (makeAccessible) {
- field.setAccessible( true );
- }
+ field.setAccessible( true );
fields.put( fieldName, field );
}
Please sign in to comment.
Something went wrong with that request. Please try again.