You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by vi...@apache.org on 2016/11/03 15:11:18 UTC

svn commit: r1767903 - /tomcat/trunk/java/org/apache/catalina/connector/OutputBuffer.java

Author: violetagg
Date: Thu Nov  3 15:11:18 2016
New Revision: 1767903

URL: http://svn.apache.org/viewvc?rev=1767903&view=rev
Log:
Set the buffer size if it is above the one specified when OutputBuffer object was created.
This change resets the behavior to the one before r1758421.

Modified:
    tomcat/trunk/java/org/apache/catalina/connector/OutputBuffer.java

Modified: tomcat/trunk/java/org/apache/catalina/connector/OutputBuffer.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/connector/OutputBuffer.java?rev=1767903&r1=1767902&r2=1767903&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/connector/OutputBuffer.java (original)
+++ tomcat/trunk/java/org/apache/catalina/connector/OutputBuffer.java Thu Nov  3 15:11:18 2016
@@ -639,7 +639,7 @@ public class OutputBuffer extends Writer
 
 
     public void setBufferSize(int size) {
-        if (size != bb.capacity()) {
+        if (size > bb.capacity()) {
             bb = ByteBuffer.allocate(size);
             clear(bb);
         }



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Re: svn commit: r1767903 - /tomcat/trunk/java/org/apache/catalina/connector/OutputBuffer.java

Posted by Christopher Schultz <ch...@christopherschultz.net>.
Violeta,

On 11/3/16 12:43 PM, Violeta Georgieva wrote:
> 2016-11-03 18:37 GMT+02:00 Christopher Schultz <chris@christopherschultz.net
>> :
>>
>> Violetta,
>>
>> On 11/3/16 11:11 AM, violetagg@apache.org wrote:
>>> Author: violetagg
>>> Date: Thu Nov  3 15:11:18 2016
>>> New Revision: 1767903
>>>
>>> URL: http://svn.apache.org/viewvc?rev=1767903&view=rev
>>> Log:
>>> Set the buffer size if it is above the one specified when OutputBuffer
> object was created.
>>> This change resets the behavior to the one before r1758421.
>>>
>>> Modified:
>>>     tomcat/trunk/java/org/apache/catalina/connector/OutputBuffer.java
>>>
>>> Modified:
> tomcat/trunk/java/org/apache/catalina/connector/OutputBuffer.java
>>> URL:
> http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/connector/OutputBuffer.java?rev=1767903&r1=1767902&r2=1767903&view=diff
>>>
> ==============================================================================
>>> --- tomcat/trunk/java/org/apache/catalina/connector/OutputBuffer.java
> (original)
>>> +++ tomcat/trunk/java/org/apache/catalina/connector/OutputBuffer.java
> Thu Nov  3 15:11:18 2016
>>> @@ -639,7 +639,7 @@ public class OutputBuffer extends Writer
>>>
>>>
>>>      public void setBufferSize(int size) {
>>> -        if (size != bb.capacity()) {
>>> +        if (size > bb.capacity()) {
>>>              bb = ByteBuffer.allocate(size);
>>>              clear(bb);
>>>          }
>>
>> Might this cause a problem with output buffers growing without bound?
> 
> This is an API that the application can call.
> Servlet javadoc specifies:
> 
> "Sets the preferred buffer size for the body of the response. The servlet
> container will use a buffer at least as large as the size requested. The
> actual buffer size used can be found using getBufferSize."
> https://docs.oracle.com/javaee/7/api/javax/servlet/ServletResponse.html#setBufferSize-int-

Okay. It might be nice to have a way for client code to shrink the
buffer size at some point, maybe by checking the current buffer size
relative to the requested buffer size, and shrink the buffer if there is
some factor of difference.

I can imagine a use case of setting the buffer size to be large for a
huge response and then attempting to reduce the buffer size again to
"save memory".

-chris


Re: svn commit: r1767903 - /tomcat/trunk/java/org/apache/catalina/connector/OutputBuffer.java

Posted by Violeta Georgieva <mi...@gmail.com>.
2016-11-03 18:37 GMT+02:00 Christopher Schultz <chris@christopherschultz.net
>:
>
> Violetta,
>
> On 11/3/16 11:11 AM, violetagg@apache.org wrote:
> > Author: violetagg
> > Date: Thu Nov  3 15:11:18 2016
> > New Revision: 1767903
> >
> > URL: http://svn.apache.org/viewvc?rev=1767903&view=rev
> > Log:
> > Set the buffer size if it is above the one specified when OutputBuffer
object was created.
> > This change resets the behavior to the one before r1758421.
> >
> > Modified:
> >     tomcat/trunk/java/org/apache/catalina/connector/OutputBuffer.java
> >
> > Modified:
tomcat/trunk/java/org/apache/catalina/connector/OutputBuffer.java
> > URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/connector/OutputBuffer.java?rev=1767903&r1=1767902&r2=1767903&view=diff
> >
==============================================================================
> > --- tomcat/trunk/java/org/apache/catalina/connector/OutputBuffer.java
(original)
> > +++ tomcat/trunk/java/org/apache/catalina/connector/OutputBuffer.java
Thu Nov  3 15:11:18 2016
> > @@ -639,7 +639,7 @@ public class OutputBuffer extends Writer
> >
> >
> >      public void setBufferSize(int size) {
> > -        if (size != bb.capacity()) {
> > +        if (size > bb.capacity()) {
> >              bb = ByteBuffer.allocate(size);
> >              clear(bb);
> >          }
>
> Might this cause a problem with output buffers growing without bound?

This is an API that the application can call.
Servlet javadoc specifies:

"Sets the preferred buffer size for the body of the response. The servlet
container will use a buffer at least as large as the size requested. The
actual buffer size used can be found using getBufferSize."
https://docs.oracle.com/javaee/7/api/javax/servlet/ServletResponse.html#setBufferSize-int-

Regards,
Violeta

>
> -chris
>

Re: svn commit: r1767903 - /tomcat/trunk/java/org/apache/catalina/connector/OutputBuffer.java

Posted by Christopher Schultz <ch...@christopherschultz.net>.
Violetta,

On 11/3/16 11:11 AM, violetagg@apache.org wrote:
> Author: violetagg
> Date: Thu Nov  3 15:11:18 2016
> New Revision: 1767903
> 
> URL: http://svn.apache.org/viewvc?rev=1767903&view=rev
> Log:
> Set the buffer size if it is above the one specified when OutputBuffer object was created.
> This change resets the behavior to the one before r1758421.
> 
> Modified:
>     tomcat/trunk/java/org/apache/catalina/connector/OutputBuffer.java
> 
> Modified: tomcat/trunk/java/org/apache/catalina/connector/OutputBuffer.java
> URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/connector/OutputBuffer.java?rev=1767903&r1=1767902&r2=1767903&view=diff
> ==============================================================================
> --- tomcat/trunk/java/org/apache/catalina/connector/OutputBuffer.java (original)
> +++ tomcat/trunk/java/org/apache/catalina/connector/OutputBuffer.java Thu Nov  3 15:11:18 2016
> @@ -639,7 +639,7 @@ public class OutputBuffer extends Writer
>  
>  
>      public void setBufferSize(int size) {
> -        if (size != bb.capacity()) {
> +        if (size > bb.capacity()) {
>              bb = ByteBuffer.allocate(size);
>              clear(bb);
>          }

Might this cause a problem with output buffers growing without bound?

-chris