Skip to content

Commit 3be1d82

Browse files
Merge branch '1.2.x' of github.com:grails/grails into 1.2.x
2 parents d383df3 + 6da175a commit 3be1d82

File tree

4 files changed

+255
-60
lines changed

4 files changed

+255
-60
lines changed

src/java/org/codehaus/groovy/grails/web/pages/GroovyPageOutputStack.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,12 @@ private GroovyPageOutputStack(Writer topWriter, boolean autoSync) {
121121

122122
private Writer unwrapTargetWriter(Writer targetWriter) {
123123
if(targetWriter instanceof GrailsPrintWriter) {
124-
return ((GrailsPrintWriter)targetWriter).getOut();
125-
} else {
126-
return targetWriter;
124+
GrailsPrintWriter gpw=((GrailsPrintWriter)targetWriter);
125+
if(gpw.isAllowUnwrappingOut()) {
126+
return ((GrailsPrintWriter)targetWriter).getOut();
127+
}
127128
}
129+
return targetWriter;
128130
}
129131

130132
public void push(final Writer newWriter) {

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,26 @@ public static interface DestinationFactory {
2020
public GrailsRoutablePrintWriter(DestinationFactory factory) {
2121
super(new NullWriter());
2222
this.factory = factory;
23+
2324
}
25+
26+
/**
27+
*
28+
* tell others if getOut() can be called to "unwrap" the actual target writer
29+
*
30+
* if the destination hasn't been activated, don't allow it.
31+
*
32+
*
33+
* @see org.codehaus.groovy.grails.web.util.GrailsPrintWriter#isAllowUnwrappingOut()
34+
*/
35+
@Override
36+
public boolean isAllowUnwrappingOut() {
37+
if(destination==null) {
38+
return false;
39+
} else {
40+
return true;
41+
}
42+
}
2443

2544
public Writer getOut() {
2645
return getDestination();
@@ -199,4 +218,5 @@ public void close() throws IOException {
199218

200219
}
201220

221+
202222
}

src/java/org/codehaus/groovy/grails/web/util/GrailsPrintWriter.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,18 @@ public class GrailsPrintWriter extends PrintWriter {
2525
private static final char CRLF[] = { '\r', '\n' };
2626
protected boolean trouble=false;
2727
protected Writer out;
28+
protected boolean allowUnwrappingOut=true;
2829
private boolean finalTargetHere=false;
2930
private boolean usageFlag=false;
3031

3132
public GrailsPrintWriter(Writer out) {
3233
super(out);
3334
this.out=out;
3435
}
36+
37+
public boolean isAllowUnwrappingOut() {
38+
return allowUnwrappingOut;
39+
}
3540

3641
public Writer getOut() {
3742
return out;

0 commit comments

Comments
 (0)