Issue #1328 - Making Response.setBufferSize(int) ISE more clear

This commit is contained in:
Joakim Erdfelt 2017-02-15 11:40:17 -07:00
parent 852d9d5c01
commit 8fe94cd110
1 changed files with 4 additions and 2 deletions

View File

@ -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);