You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by hl...@apache.org on 2008/01/19 18:25:52 UTC
svn commit: r613426 -
/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/services/ThreadCleanupHubImpl.java
Author: hlship
Date: Sat Jan 19 09:25:52 2008
New Revision: 613426
URL: http://svn.apache.org/viewvc?rev=613426&view=rev
Log:
TAPESTRY-2037: NullPointerException caused by many rapid page refreshes
Modified:
tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/services/ThreadCleanupHubImpl.java
Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/services/ThreadCleanupHubImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/services/ThreadCleanupHubImpl.java?rev=613426&r1=613425&r2=613426&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/services/ThreadCleanupHubImpl.java (original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/services/ThreadCleanupHubImpl.java Sat Jan 19 09:25:52 2008
@@ -41,23 +41,31 @@
_logger = logger;
}
- public synchronized void addThreadCleanupListener(ThreadCleanupListener listener)
+ private synchronized List<ThreadCleanupListener> get()
{
- _holder.get().add(listener);
+ return _holder.get();
+ }
+
+ private synchronized List<ThreadCleanupListener> getAndRemove()
+ {
+ List<ThreadCleanupListener> result = _holder.get();
+
+ _holder.remove();
+
+ return result;
+ }
+
+ public void addThreadCleanupListener(ThreadCleanupListener listener)
+ {
+ get().add(listener);
}
/**
* Instructs the hub to notify all its listeners (for the current thread). It also discards its list of listeners.
*/
- public synchronized void cleanup()
+ public void cleanup()
{
- List<ThreadCleanupListener> listeners = _holder.get();
-
- // Discard the listeners. In a perfect world, we would set a per-thread flag that prevented
- // more listeners from being added, until a new thread begins. But we don't have a concept
- // of thread start, just thread complete.
-
- _holder.remove();
+ List<ThreadCleanupListener> listeners = getAndRemove();
for (ThreadCleanupListener listener : listeners)
{