You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Konstantin Kolinko <kn...@gmail.com> on 2012/10/02 20:32:10 UTC

trunk: An buffer exception in AccessLogValve.log(..)

Hi!

Running current trunk + Nio connector + JDK 7u7, I see a lot of the
following exceptions.

It looks like there is some bug in AccessLogValve optimization when
StringBuilder was replaced with a CharBuffer.

A CharBuffer cannot grow itself?


02-Oct-2012 22:17:29.000 SEVERE [http-nio-8080-exec-2]
org.apache.coyote.http11.AbstractHttp11Processor.process Error
processing request
 java.nio.BufferOverflowException
	at java.nio.Buffer.nextPutIndex(Buffer.java:513)
	at java.nio.HeapCharBuffer.put(HeapCharBuffer.java:163)
	at java.nio.CharBuffer.put(CharBuffer.java:892)
	at java.nio.CharBuffer.put(CharBuffer.java:915)
	at java.nio.CharBuffer.append(CharBuffer.java:1311)
	at org.apache.catalina.valves.AccessLogValve$RequestElement.addElement(AccessLogValve.java:1577)
	at org.apache.catalina.valves.AccessLogValve.log(AccessLogValve.java:944)
	at org.apache.catalina.core.AccessLogAdapter.log(AccessLogAdapter.java:51)
	at org.apache.catalina.core.ContainerBase.logAccess(ContainerBase.java:1043)
	at org.apache.catalina.core.ContainerBase.logAccess(ContainerBase.java:1050)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:480)
	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:963)
	at org.apache.coyote.http11.Http11NioProcessor.process(Http11NioProcessor.java:234)
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:617)
	at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:223)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1568)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
	at java.lang.Thread.run(Thread.java:722)

Best regards,
Konstantin Kolinko

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


Re: trunk: An buffer exception in AccessLogValve.log(..)

Posted by "verlag.preisser@t-online.de" <ve...@t-online.de>.
Hi,

-----Original-Nachricht-----
> Von: Christopher Schultz <ch...@christopherschultz.net>
> An: Tomcat Developers List <de...@tomcat.apache.org>


> > A CharBuffer cannot grow itself?
> 
> The API does not seem to say anything about re-sizing CharBuffers.

The Javadoc for java.nio.Buffer (superclass of CharBuffer) states that:
    A buffer's capacity is the number of elements it contains. The capacity of a buffer is never negative and never changes. 

So one would probably need to manually allocate a bigger buffer when it has too little remaining elements.


Regards,
Konstantin Preißer



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


Re: trunk: An buffer exception in AccessLogValve.log(..)

Posted by Mark Thomas <ma...@apache.org>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 02/10/2012 21:37, Christopher Schultz wrote:
> Konstantin,
> 
> On 10/2/12 3:58 PM, Konstantin Kolinko wrote:
>> 2012/10/2 Christopher Schultz <ch...@christopherschultz.net>:
>>> Konstantin,
>>> 
>>> On 10/2/12 2:32 PM, Konstantin Kolinko wrote:
>>>> Running current trunk + Nio connector + JDK 7u7, I see a lot
>>>> of the following exceptions.
>>>> 
>>>> It looks like there is some bug in AccessLogValve
>>>> optimization when StringBuilder was replaced with a
>>>> CharBuffer.
>>>> 
>>>> A CharBuffer cannot grow itself?

My bad. I'll fix that.

>>> The API does not seem to say anything about re-sizing
>>> CharBuffers.
>>> 
>> 
>> The CharArrayWriter class can be a replacement here.
>> 
>> It grows itself. It is reusable with CharArrayWriter.reset(). It
>> can write its buffer without creating a copy with 
>> CharArrayWriter.writeTo(Writer).
> 
> Sounds ideal.

+1.

> One thing I might consider is whether it can *shrink* at some
> point. I can imagine some relatively rare use case where someone
> uses ${xxx}r or %{xxx}s and the resulting string ends up being
> huge. Then the AccessLogValve has this huge buffer that is not
> necessary.
> 
> I'm just thinking about JSP caches, etc. that are often referenced 
> taking up large amounts of heap space because they never shrink.

There is a limit (set at 256 characters) and if the buffer is above
this size it gets thrown away rather than recycled.

Mark

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://www.enigmail.net/

iQIcBAEBAgAGBQJQa2kKAAoJEBDAHFovYFnnM74P/08DdXdAWynBV+3cCViOnDGw
nLNXAH7/E2FZTbyWb0HjbEjKwEY2JxdL71mHTEudNLRYvR3M5ZYXGId7J4jX4CXS
uNZFLnEUJH9Dx4sdLwsD6gIbJtDReD0zLkl1yJS2Bfq+ssdKXtZ8dqPgwYx34BYK
OExsh9lBH9TRY0CUf+Sfm8v+s2wOBu4Y00IHw7+yFRmHPLJVS/YzcLP2YwLGBZxI
N2uq35HHWXmbGd+UbAVD6w4UVFJdXxNk3BBS2NFOwT55SaqPJG6II/Bl+3MKHN2s
0AtOjCjioWxJT8cqxmSkserbX+Z0QDO4FJe3QEoBndRh+z9XOJ6Y6kBJp/EcsRYA
gG1wWOqM1hShVVpn12YGimGa13Ki+B/uoDxO8RlA6pDbh3puhZ0pq4/oWkrAR1hJ
bzyUSs3w2wD/Um7acKQfntj8tZRKt37oeFclAqMZmJmPVaDhqBQMJxUvo8UQvGYF
gZVJFNDSJInjfI8Lss4MFl6ErNwfwN6zYhLtzQVjiEzF5idJCTk9pt0Z7raFt0Em
+SM+bW3bLfW1qSpAmlIuismMDadwNY4k/vobRa607b9fi7sABAlk9wlMuRWQfFd4
InPTEFYGvX33aNZ9HmvJJmw9XTJHNowUcYv+XuLZ/TuDuJMveOv6+VVZORQoKada
6gR8WCGWxPI9JmBLsUo/
=ggGG
-----END PGP SIGNATURE-----

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


Re: trunk: An buffer exception in AccessLogValve.log(..)

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

On 10/2/12 3:58 PM, Konstantin Kolinko wrote:
> 2012/10/2 Christopher Schultz <ch...@christopherschultz.net>:
>> Konstantin,
>>
>> On 10/2/12 2:32 PM, Konstantin Kolinko wrote:
>>> Running current trunk + Nio connector + JDK 7u7, I see a lot of the
>>> following exceptions.
>>>
>>> It looks like there is some bug in AccessLogValve optimization when
>>> StringBuilder was replaced with a CharBuffer.
>>>
>>> A CharBuffer cannot grow itself?
>>
>> The API does not seem to say anything about re-sizing CharBuffers.
>>
> 
> The CharArrayWriter class can be a replacement here.
> 
> It grows itself.
> It is reusable with CharArrayWriter.reset().
> It can write its buffer without creating a copy with
> CharArrayWriter.writeTo(Writer).

Sounds ideal.

One thing I might consider is whether it can *shrink* at some point. I
can imagine some relatively rare use case where someone uses ${xxx}r or
%{xxx}s and the resulting string ends up being huge. Then the
AccessLogValve has this huge buffer that is not necessary.

I'm just thinking about JSP caches, etc. that are often referenced
taking up large amounts of heap space because they never shrink.

-chris


Re: trunk: An buffer exception in AccessLogValve.log(..)

Posted by Konstantin Kolinko <kn...@gmail.com>.
2012/10/2 Christopher Schultz <ch...@christopherschultz.net>:
> Konstantin,
>
> On 10/2/12 2:32 PM, Konstantin Kolinko wrote:
>> Running current trunk + Nio connector + JDK 7u7, I see a lot of the
>> following exceptions.
>>
>> It looks like there is some bug in AccessLogValve optimization when
>> StringBuilder was replaced with a CharBuffer.
>>
>> A CharBuffer cannot grow itself?
>
> The API does not seem to say anything about re-sizing CharBuffers.
>

The CharArrayWriter class can be a replacement here.

It grows itself.
It is reusable with CharArrayWriter.reset().
It can write its buffer without creating a copy with
CharArrayWriter.writeTo(Writer).


Best regards,
Konstantin Kolinko

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


Re: trunk: An buffer exception in AccessLogValve.log(..)

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

On 10/2/12 2:32 PM, Konstantin Kolinko wrote:
> Running current trunk + Nio connector + JDK 7u7, I see a lot of the
> following exceptions.
> 
> It looks like there is some bug in AccessLogValve optimization when
> StringBuilder was replaced with a CharBuffer.
> 
> A CharBuffer cannot grow itself?

The API does not seem to say anything about re-sizing CharBuffers.

-chris