This is an automated email from the ASF dual-hosted git repository.

mgrigorov pushed a commit to branch wicket-7.x
in repository https://gitbox.apache.org/repos/asf/wicket.git


The following commit(s) were added to refs/heads/wicket-7.x by this push:
     new 802b8c9  WICKET-6639 PageStoreManager$SessionEntry.clear produces 
NullPointerException
802b8c9 is described below

commit 802b8c90e79c4bfd5464b486e2af481c3f8c18db
Author: Martin Tzvetanov Grigorov <[email protected]>
AuthorDate: Sat Mar 2 23:45:21 2019 +0200

    WICKET-6639 PageStoreManager$SessionEntry.clear produces 
NullPointerException
    
    Add some checks for sessionCache being null
    
    (cherry picked from commit 116a7c57af87bbe515eb710664c7e28745ca0642)
---
 .../org/apache/wicket/page/PageStoreManager.java   | 27 +++++++++++++++-------
 1 file changed, 19 insertions(+), 8 deletions(-)

diff --git 
a/wicket-core/src/main/java/org/apache/wicket/page/PageStoreManager.java 
b/wicket-core/src/main/java/org/apache/wicket/page/PageStoreManager.java
index 44259e4..adee687 100644
--- a/wicket-core/src/main/java/org/apache/wicket/page/PageStoreManager.java
+++ b/wicket-core/src/main/java/org/apache/wicket/page/PageStoreManager.java
@@ -49,10 +49,10 @@ public class PageStoreManager extends AbstractPageManager
         * Web containers intercept
         * {@link javax.servlet.http.HttpSession#setAttribute(String, Object)} 
to detect changes and
         * replicate the session. If the attribute has been already bound in 
the session then
-        * {@link #valueUnbound(HttpSessionBindingEvent)} might get called - 
this flag
+        * {@link SessionEntry#valueUnbound(HttpSessionBindingEvent)} might get 
called - this flag
         * helps us to ignore the invocation in that case.
         * 
-        * @see #valueUnbound(HttpSessionBindingEvent)
+        * @see SessionEntry#valueUnbound(HttpSessionBindingEvent)
         */
        private static final ThreadLocal<Boolean> STORING_TOUCHED_PAGES = new 
ThreadLocal<Boolean>()
        {
@@ -148,11 +148,14 @@ public class PageStoreManager extends AbstractPageManager
                 */
                private IManageablePage findPage(int id)
                {
-                       for (IManageablePage p : sessionCache)
+                       if (sessionCache != null)
                        {
-                               if (p.getPageId() == id)
+                               for (IManageablePage p : sessionCache)
                                {
-                                       return p;
+                                       if (p.getPageId() == id)
+                                       {
+                                               return p;
+                                       }
                                }
                        }
                        return null;
@@ -172,6 +175,10 @@ public class PageStoreManager extends AbstractPageManager
                                        return;
                                }
 
+                               if (sessionCache == null)
+                               {
+                                       sessionCache = new ArrayList<>();
+                               }
                                sessionCache.add(page);
                        }
                }
@@ -347,9 +354,13 @@ public class PageStoreManager extends AbstractPageManager
                        return false;
                }
 
-               public void clear() {
-                       sessionCache.clear();
-                       
+               public void clear()
+               {
+                       if (sessionCache != null)
+                       {
+                               sessionCache.clear();
+                       }
+
                        // WICKET-5164 use the original sessionId
                        IPageStore store = getPageStore();
                        // store might be null if destroyed already

Reply via email to