From: Kai Moritz Date: Thu, 31 May 2012 20:42:43 +0000 (+0200) Subject: Unnötige decorate()-Aufrufe durch AcceleratorFilter verhindert X-Git-Url: http://juplo.de/gitweb/?a=commitdiff_plain;h=5f8def1103a2a408579d1b6ae29e447a272a9558;p=percentcodec Unnötige decorate()-Aufrufe durch AcceleratorFilter verhindert --- diff --git a/cachecontrol/src/main/java/de/halbekunst/juplo/cachecontrol/AcceleratorFilter.java b/cachecontrol/src/main/java/de/halbekunst/juplo/cachecontrol/AcceleratorFilter.java index ffafddc7..f9cd886f 100644 --- a/cachecontrol/src/main/java/de/halbekunst/juplo/cachecontrol/AcceleratorFilter.java +++ b/cachecontrol/src/main/java/de/halbekunst/juplo/cachecontrol/AcceleratorFilter.java @@ -333,6 +333,7 @@ public class AcceleratorFilter implements Filter { */ response.reset(); pos = 0; + size = 0; stream = null; writer = null; } @@ -649,9 +650,11 @@ public class AcceleratorFilter implements Filter { public void write(int i) throws IOException { if (pos == bufferSize) { out().write(buffer); - pos = 0; committed = true; - cacheControl.decorate(request, response); + /** Dekoration nur beim ersten Schreib-Schub anstoßen */ + if (pos == size) + cacheControl.decorate(request, response); + pos = 0; } buffer[pos++] = (byte) i; size++; @@ -663,7 +666,9 @@ public class AcceleratorFilter implements Filter { return; committed = true; - cacheControl.decorate(request, response); + /** Dekoration nur beim ersten Schreib-Schub anstoßen */ + if (pos == size) + cacheControl.decorate(request, response); out().write(buffer, 0, pos); out().flush(); pos = 0;