You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by jw...@apache.org on 2008/11/07 01:34:05 UTC

svn commit: r712021 - /myfaces/trinidad/branches/1.2.9.1-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/util/ThreadLocalUtils.java

Author: jwaldman
Date: Thu Nov  6 16:34:03 2008
New Revision: 712021

URL: http://svn.apache.org/viewvc?rev=712021&view=rev
Log:
TRINIDAD-1291 ThreadLocalUtils blows up if a referenced ThreadLocal has been GC'ed

(removed iterator.remove(); for null threadLocal)

Modified:
    myfaces/trinidad/branches/1.2.9.1-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/util/ThreadLocalUtils.java

Modified: myfaces/trinidad/branches/1.2.9.1-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/util/ThreadLocalUtils.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.9.1-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/util/ThreadLocalUtils.java?rev=712021&r1=712020&r2=712021&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.9.1-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/util/ThreadLocalUtils.java (original)
+++ myfaces/trinidad/branches/1.2.9.1-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/util/ThreadLocalUtils.java Thu Nov  6 16:34:03 2008
@@ -197,13 +197,12 @@
       {
         ThreadLocal<?> threadLocal = iterator.next().get();
         
-        if (threadLocal == null)
-        {
-          // the threadLocal has been released, so remove this entry.  It will be
-          // readded if the ThreadLocal is ever recreated
-          iterator.remove();
-        }
-        else
+        // if the threadLocal is null, that means it has been released and we would really
+        // like to reclaim the entry, however remove isn't supported on CopyOnWriteArrayLists
+        // and the synchronization required to safely remove this item probably isn't
+        // worthy the small increase in memory of keeping around this empty item, so we don't
+        // bother cleaning up this entry
+        if (threadLocal != null)
         {
           // reset the threadlocal for this thread
           threadLocal.remove();