Ard Schrijvers pushed to branch release/4.1 at cms-community / 
hippo-site-toolkit


Commits:
2396db14 by Ard Schrijvers at 2017-06-29T15:00:24+02:00
HSTTWO-4076 [Backport 4.1] Make sure that in case of a repository exception, 
the error page is put in cache with the correct cachekey

(cherry picked from commit 886ac21d241b1e2a2580dfa651434136f226a9d7)

- - - - -


2 changed files:

- client/src/main/java/org/hippoecm/hst/servlet/BinariesServlet.java
- client/src/main/java/org/hippoecm/hst/servlet/utils/BinaryPage.java


Changes:

=====================================
client/src/main/java/org/hippoecm/hst/servlet/BinariesServlet.java
=====================================
--- a/client/src/main/java/org/hippoecm/hst/servlet/BinariesServlet.java
+++ b/client/src/main/java/org/hippoecm/hst/servlet/BinariesServlet.java
@@ -1,5 +1,5 @@
 /*
- *  Copyright 2010-2015 Hippo B.V. (http://www.onehippo.com)
+ *  Copyright 2010-2017 Hippo B.V. (http://www.onehippo.com)
  * 
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -458,6 +458,9 @@ public class BinariesServlet extends HttpServlet {
             return page;
         } catch (RepositoryException e) {
             BinaryPage errorPage = new BinaryPage(resourcePath);
+            // error page requires the same cachekey but is not set through 
the constructor. Unfortunately....
+            // if we don't set the cache, the blocking cache will never 
release the lock
+            errorPage.setCacheKey(new CacheKey(session.getUserID(), 
resourcePath));
             errorPage.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
             if (log.isDebugEnabled()) {
                 log.warn("Repository exception while resolving binaries 
request '" + request.getRequestURI() + "' : " + e, e);


=====================================
client/src/main/java/org/hippoecm/hst/servlet/utils/BinaryPage.java
=====================================
--- a/client/src/main/java/org/hippoecm/hst/servlet/utils/BinaryPage.java
+++ b/client/src/main/java/org/hippoecm/hst/servlet/utils/BinaryPage.java
@@ -1,5 +1,5 @@
 /*
- *  Copyright 2010-2015 Hippo B.V. (http://www.onehippo.com)
+ *  Copyright 2010-2017 Hippo B.V. (http://www.onehippo.com)
  * 
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -24,6 +24,8 @@ import javax.servlet.http.HttpServletResponse;
 
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.lang.ArrayUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * A {@link Serializable} representation of a resource from the repository as 
a html page.
@@ -32,6 +34,8 @@ import org.apache.commons.lang.ArrayUtils;
  */
 public class BinaryPage implements Serializable {
 
+    private static final Logger log = 
LoggerFactory.getLogger(BinaryPage.class);
+
     private static final long serialVersionUID = 1L;
 
     private final String path;
@@ -189,6 +193,10 @@ public class BinaryPage implements Serializable {
     }
 
     public CacheKey getCacheKey() {
+        if (cacheKey == null) {
+            log.error("Cachekey should never be null! but was for '{}'. 
Implementation issue", getResourcePath(),
+                    new Throwable("Cachey not allowed to be null"));
+        }
         return cacheKey;
     }
 



View it on GitLab: 
https://code.onehippo.org/cms-community/hippo-site-toolkit/commit/2396db14ecc77348e6dbd1acf8b9cbc322bf0caa
_______________________________________________
Hippocms-svn mailing list
Hippocms-svn@lists.onehippo.org
https://lists.onehippo.org/mailman/listinfo/hippocms-svn

Reply via email to