[spring-extensions] branch master updated: JSE-36 - Support override of status code in error view

Scott Cantor cantor.2 at osu.edu
Mon Jun 8 23:00:20 UTC 2020


This is an automated email from the git hooks/post-receive script.

scantor pushed a commit to branch master
in repository spring-extensions.

View the commit online:
http://git.shibboleth.net/view/?p=spring-extensions.git;a=commit;h=dec23eec68c0938ef1fb646b2015a85a52d87376

The following commit(s) were added to refs/heads/master by this push:
       new  dec23ee   JSE-36 - Support override of status code in error view
dec23ee is described below

commit dec23eec68c0938ef1fb646b2015a85a52d87376
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Thu Jun 4 11:23:30 2020 -0400

    JSE-36 - Support override of status code in error view
    
    https://issues.shibboleth.net/jira/browse/JSE-36
---
 .../error/ExtendedMappingExceptionResolver.java     | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)

diff --git a/src/main/java/net/shibboleth/ext/spring/error/ExtendedMappingExceptionResolver.java b/src/main/java/net/shibboleth/ext/spring/error/ExtendedMappingExceptionResolver.java
index 51843cf..0855541 100644
--- a/src/main/java/net/shibboleth/ext/spring/error/ExtendedMappingExceptionResolver.java
+++ b/src/main/java/net/shibboleth/ext/spring/error/ExtendedMappingExceptionResolver.java
@@ -23,6 +23,7 @@ import java.util.function.Function;
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
 import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
 
 import net.shibboleth.utilities.java.support.codec.HTMLEncoder;
 
@@ -44,6 +45,9 @@ public class ExtendedMappingExceptionResolver extends SimpleMappingExceptionReso
     /** Model attribute carrying {@link HttpServletRequest}. */
     @Nonnull private static final String MODEL_ATTR_REQUEST = "request";
 
+    /** Model attribute carrying {@link HttpServletResponse}. */
+    @Nonnull private static final String MODEL_ATTR_RESPONSE = "response";
+
     /** Model attribute carrying {@link WebApplicationContext}. */
     @Nonnull private static final String MODEL_ATTR_SPRINGCONTEXT = "springContext";
 
@@ -68,8 +72,21 @@ public class ExtendedMappingExceptionResolver extends SimpleMappingExceptionReso
     }
     
     /** {@inheritDoc} */
-    @Override protected ModelAndView getModelAndView(final String viewName,
-            final Exception ex, final HttpServletRequest request) {
+    @Override
+    protected ModelAndView doResolveException(final HttpServletRequest request, final HttpServletResponse response,
+            final Object handler, final Exception ex) {
+        
+        final ModelAndView view = super.doResolveException(request, response, handler, ex);
+        if (view != null) {
+            view.addObject(MODEL_ATTR_RESPONSE, response);
+        }
+        return view;
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    protected ModelAndView getModelAndView(final String viewName, final Exception ex,
+            final HttpServletRequest request) {
         
         LoggerFactory.getLogger(ex.getClass()).error("", ex);
         

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list