Martin Hoffesommer wrote:
Hi,

going through the mailing list archive I couldn't find any mention of
the problem/issue that I've encountered.

Basically I have a CumulativeProtocolDecoder that has to accumulate
some data internally in addition to 'regular' messages; sort of an
out-of-band channel. To do this I'm storing an IoBuffer instance as
session attribute.

Now here's the problem: The buffer I'm storing is allocated as
IoBuffer.allocate(0,false) and then set to auto-expand via
setAutoExpand(true). This however always gets me the same buffer
instance which is then falsely shared between all my sessions; more
precisely it is the static EMPTY_HEAP_BUFFER inside IoBuffer.
Yeah. This is how the constructor was designed.
Now my questions:
1.) Why does allocate perform this "optimization" of returning the
same empty buffer when an initial zero capacity buffer is requested?
I have no idea. Seems insane as even if you tells the constructor that the buffer is autoexpandable, if the capacity is 0, yiu will still have a ref to this static buffer.
2.) If this is indeed done on purpose, should these buffers then still
be allowed to grow?
I don't think so, but then, what will it be good for ? An empty buffer, not expandable ? Sounds like a useless object to me ;)

Anyway, IMHO, all these IoBuffer stuff is something which should go away, asap. It was a bad idea, from the beginning. We are trying to get it replaced by a better structure, but it will take a bit of time.


--
--
cordialement, regards,
Emmanuel Lécharny
www.iktek.com
directory.apache.org


Reply via email to