Skip to content

Commit 81593f8

Browse files
committed
Merge branch '1.2.x' of [email protected]:grails/grails into 1.2.x
2 parents f761f12 + 3be1d82 commit 81593f8

File tree

9 files changed

+282
-67
lines changed

9 files changed

+282
-67
lines changed

lib/groovy-all-1.6.7.jar

-71 KB
Binary file not shown.

src/java/grails/test/MockUtils.groovy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import org.springframework.beans.SimpleTypeConverter
3737
import org.springframework.mock.web.MockHttpSession
3838
import org.springframework.validation.Errors
3939
import org.springframework.web.context.request.RequestContextHolder
40-
import org.springframework.web.servlet.ModelAndView;
40+
import org.springframework.web.servlet.ModelAndView
4141

4242
import grails.validation.ValidationException
4343

@@ -197,7 +197,7 @@ class MockUtils {
197197
else if (map["view"] != null) {
198198
assert map["text"] == null : "'text' cannot be used with 'view' in render"
199199

200-
modelAndView["view"] = map["view"]
200+
modelAndView["viewName"] = map["view"]
201201
modelAndView["model"] = map["model"]
202202
}
203203
else if (map["text"] != null) {

src/java/org/codehaus/groovy/grails/orm/hibernate/cfg/HibernateNamedQueriesBuilder.groovy

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ class HibernateNamedQueriesBuilder {
2929
private final domainClass
3030
private final dynamicMethods
3131

32-
private boolean initializationComplete = false
33-
3432
/**
3533
* @param domainClass the GrailsDomainClass defining the named queries
3634
* @param grailsApplication a GrailsApplication instance
@@ -58,7 +56,6 @@ class HibernateNamedQueriesBuilder {
5856
closure.resolveStrategy = Closure.DELEGATE_ONLY
5957
closure.delegate = this
6058
closure.call()
61-
initializationComplete = true
6259
}
6360

6461
private handleMethodMissing = {String name, args ->
@@ -71,7 +68,7 @@ class HibernateNamedQueriesBuilder {
7168
}
7269

7370
def methodMissing(String name, args) {
74-
if (!initializationComplete && args && args[0] instanceof Closure) {
71+
if (args && args[0] instanceof Closure) {
7572
return handleMethodMissing(name, args)
7673
}
7774
throw new MissingMethodException(name, HibernateNamedQueriesBuilder, args)
@@ -139,7 +136,7 @@ class NamedCriteriaProxy {
139136
}
140137

141138
def findAllWhere(Map params, Boolean uniq = false) {
142-
def closureClone = criteriaClosure.clone()
139+
def closureClone = getPreparedCriteriaClosure()
143140
def queryClosure = {
144141
closureClone.delegate = delegate
145142
closureClone()
@@ -168,6 +165,7 @@ class NamedCriteriaProxy {
168165

169166
private getPreparedCriteriaClosure() {
170167
def closureClone = criteriaClosure.clone()
168+
closureClone.resolveStrategy = Closure.DELEGATE_FIRST
171169
if (namedCriteriaParams) {
172170
closureClone = closureClone.curry(namedCriteriaParams)
173171
}

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)