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:56:25 UTC

svn commit: r712027 - /myfaces/trinidad/trunk_1.2.x/trinidad-api/src/main/java/org/apache/myfaces/trinidad/util/ThreadLocalUtils.java

Author: jwaldman
Date: Thu Nov  6 16:56:24 2008
New Revision: 712027

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

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

Patch provided by Blake Sullivan

Modified:
    myfaces/trinidad/trunk_1.2.x/trinidad-api/src/main/java/org/apache/myfaces/trinidad/util/ThreadLocalUtils.java

Modified: myfaces/trinidad/trunk_1.2.x/trinidad-api/src/main/java/org/apache/myfaces/trinidad/util/ThreadLocalUtils.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk_1.2.x/trinidad-api/src/main/java/org/apache/myfaces/trinidad/util/ThreadLocalUtils.java?rev=712027&r1=712026&r2=712027&view=diff
==============================================================================
--- myfaces/trinidad/trunk_1.2.x/trinidad-api/src/main/java/org/apache/myfaces/trinidad/util/ThreadLocalUtils.java (original)
+++ myfaces/trinidad/trunk_1.2.x/trinidad-api/src/main/java/org/apache/myfaces/trinidad/util/ThreadLocalUtils.java Thu Nov  6 16:56:24 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();