Skip to content

Commit 8d5d470

Browse files
committed
Merged fix for GRAILS-5892 "SecurtyFilter Example of chapter 11.3 Authentication in the doc causes Exception in Grails 1.2.1"
1 parent 517feb3 commit 8d5d470

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

src/java/org/codehaus/groovy/grails/web/sitemesh/GrailsContentBufferingResponse.java

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public class GrailsContentBufferingResponse extends HttpServletResponseWrapper {
1818
private final GrailsPageResponseWrapper pageResponseWrapper;
1919
private final ContentProcessor contentProcessor;
2020
private final SiteMeshWebAppContext webAppContext;
21+
private boolean redirectCalled;
2122

2223
public GrailsContentBufferingResponse(HttpServletResponse response, final ContentProcessor contentProcessor, final SiteMeshWebAppContext webAppContext) {
2324
super(new GrailsPageResponseWrapper(webAppContext.getRequest(), response, new PageParserSelector() {
@@ -65,19 +66,30 @@ public Content getContent() throws IOException {
6566

6667
public void sendError(int sc) throws IOException {
6768
GrailsWebRequest webRequest = WebUtils.retrieveGrailsWebRequest();
69+
6870
try {
69-
super.sendError(sc);
70-
} finally {
71+
if(!redirectCalled && !isCommitted())
72+
super.sendError(sc);
73+
}
74+
finally {
7175
WebUtils.storeGrailsWebRequest(webRequest);
7276
}
7377
}
7478

7579
public void sendError(int sc, String msg) throws IOException {
7680
GrailsWebRequest webRequest = WebUtils.retrieveGrailsWebRequest();
7781
try {
78-
super.sendError(sc, msg);
79-
} finally {
82+
if(!redirectCalled && !isCommitted())
83+
super.sendError(sc, msg);
84+
}
85+
finally {
8086
WebUtils.storeGrailsWebRequest(webRequest);
8187
}
8288
}
89+
90+
@Override
91+
public void sendRedirect(String location) throws IOException {
92+
this.redirectCalled = true;
93+
super.sendRedirect(location);
94+
}
8395
}

0 commit comments

Comments
 (0)