Author: jdonnerstag
Date: Sun Aug 15 19:01:17 2010
New Revision: 985734

URL: http://svn.apache.org/viewvc?rev=985734&view=rev
Log:
fixed: MarkupCache's modification listener fails with 'no Application in this 
thread' error
Issue: WICKET-2992

Modified:
    wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/MarkupCache.java

Modified: 
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/MarkupCache.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/MarkupCache.java?rev=985734&r1=985733&r2=985734&view=diff
==============================================================================
--- wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/MarkupCache.java 
(original)
+++ wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/MarkupCache.java 
Sun Aug 15 19:01:17 2010
@@ -61,6 +61,12 @@ public class MarkupCache implements IMar
        private IMarkupCacheKeyProvider markupCacheKeyProvider;
 
        /**
+        * Note that you can not use Application.get() since removeMarkup() 
will be call from a
+        * ModificationWatcher thread which has no associated Application.
+        */
+       private final Application application;
+
+       /**
         * @return The markup cache associated with the application
         */
        public final static IMarkupCache get()
@@ -75,6 +81,8 @@ public class MarkupCache implements IMar
         */
        protected MarkupCache()
        {
+               application = Application.get();
+
                markupCache = newCacheImplementation();
                markupKeyCache = newCacheImplementation();
                if (markupCache == null)
@@ -167,8 +175,7 @@ public class MarkupCache implements IMar
                        // resources no longer in the cache. Note that you can 
not use
                        // Application.get() since removeMarkup() will be call 
from a
                        // ModificationWatcher thread which has no associated 
Application.
-                       final IModificationWatcher watcher = Application.get()
-                               .getResourceSettings()
+                       final IModificationWatcher watcher = 
application.getResourceSettings()
                                .getResourceWatcher(true);
                        if (watcher != null)
                        {
@@ -440,6 +447,7 @@ public class MarkupCache implements IMar
                                markupKeyCache.put(cacheKey, locationString);
                                return markup;
                        }
+
                        // Watch file in the future
                        final IModificationWatcher watcher = Application.get()
                                .getResourceSettings()


Reply via email to