diff --git a/src/java/org/codehaus/groovy/grails/web/util/StreamCharBuffer.java b/src/java/org/codehaus/groovy/grails/web/util/StreamCharBuffer.java
index <HASH>..<HASH> 100644
--- a/src/java/org/codehaus/groovy/grails/web/util/StreamCharBuffer.java
+++ b/src/java/org/codehaus/groovy/grails/web/util/StreamCharBuffer.java
@@ -1182,7 +1182,11 @@ public class StreamCharBuffer implements Writable, CharSequence {
 
 	@Override
 	public int length() {
-		return toString().length();
+		if(cachedToString != null) {
+			return toString().length();
+		} else {
+			return size();
+		}
 	}
 
 	@Override
small bug fix that prevents calling toString() in length() if groovy truth is tested.