From 8fe94cd110a508d4f6209b34b4a6111a79112dc1 Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Wed, 15 Feb 2017 11:40:17 -0700 Subject: [PATCH] Issue #1328 - Making Response.setBufferSize(int) ISE more clear --- .../src/main/java/org/eclipse/jetty/server/Response.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/Response.java b/jetty-server/src/main/java/org/eclipse/jetty/server/Response.java index 1b256d78584..24510b5671f 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/Response.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/Response.java @@ -1145,8 +1145,10 @@ public class Response implements HttpServletResponse @Override public void setBufferSize(int size) { - if (isCommitted() || getContentCount() > 0) - throw new IllegalStateException("cannot set buffer size when response is committed or written to"); + if (isCommitted()) + throw new IllegalStateException("cannot set buffer size after response is in committed state"); + if (getContentCount() > 0) + throw new IllegalStateException("cannot set buffer size after response has " + getContentCount() + " bytes already written"); if (size < __MIN_BUFFER_SIZE) size = __MIN_BUFFER_SIZE; _out.setBufferSize(size);