Ard Schrijvers pushed to branch bugfix/HSTTWO-3854 at cms-community / hippo-site-toolkit
Commits: ae47f08f by Ard Schrijvers at 2016-11-10T11:06:35+01:00 HSTTWO-3854 in case of a redirection, do not flush components (windows) in case of a redirection (which short-circuits later hst components their doBeforeRender), it doesn't make sense to flush the components before doing the redirect. In the best scenario, the flushing does not harm, but there are circumstances where the flushing results that already something is flushed to the backing http servlet response resulting in : Exception during sendRedirect. java.lang.IllegalStateException: Cannot call sendRedirect() after the response has been committed This could already happen in version 10 (more likely in the channel mngr), but it was not so easily triggered. In version 11, the problem is triggered much easier. Since there seems to be no reason to flush components before redirecting, just remove that code Also the comment in HstServletResponseState above the method getParentWriter was not accurate: The response only become committed if the parent writer was the actual backing http servlet response writer *and* on that writer #flush would be invoked. Hence removing the faulty comment - - - - - 2 changed files: - commons/src/main/java/org/hippoecm/hst/core/component/HstServletResponseState.java - components/core/src/main/java/org/hippoecm/hst/core/container/AggregationValve.java Changes: ===================================== commons/src/main/java/org/hippoecm/hst/core/component/HstServletResponseState.java ===================================== --- a/commons/src/main/java/org/hippoecm/hst/core/component/HstServletResponseState.java +++ b/commons/src/main/java/org/hippoecm/hst/core/component/HstServletResponseState.java @@ -991,10 +991,6 @@ public class HstServletResponseState implements HstResponseState { this.parentResponse.setLocale(locale); } - /** - * After invoking this method, the backing http servlet response becomes committed. After this method gets - * invoked, not more response headers can be set and no redirect can be done any more - */ protected Writer getParentWriter() throws IOException { try { return getResponseWriter(); ===================================== components/core/src/main/java/org/hippoecm/hst/core/container/AggregationValve.java ===================================== --- a/components/core/src/main/java/org/hippoecm/hst/core/container/AggregationValve.java +++ b/components/core/src/main/java/org/hippoecm/hst/core/container/AggregationValve.java @@ -193,10 +193,6 @@ public class AggregationValve extends AbstractBaseOrderableValve { } } else if (redirectLocation != null) { try { - for (int i = sortedComponentWindows.length - 1; i >= 0; i--) { - HstComponentWindow window = sortedComponentWindows[i]; - window.getResponseState().flush(); - } boolean permanent = false; if (HttpServletResponse.SC_MOVED_PERMANENTLY == rootWindow.getResponseState().getStatus()) { View it on GitLab: https://code.onehippo.org/cms-community/hippo-site-toolkit/commit/ae47f08fb77ee38d63cf5d89b8b8d6c850b3a4dd
_______________________________________________ Hippocms-svn mailing list Hippocms-svn@lists.onehippo.org https://lists.onehippo.org/mailman/listinfo/hippocms-svn