[jbosscache-dev] Re: Any reason not to use ExposedByteArrayOutputStream instead of ByteArrayOutputStream ?
Manik Surtani
manik at jboss.org
Fri Jul 4 08:17:44 EDT 2008
On 4 Jul 2008, at 12:32, Bela Ban wrote:
> Manik Surtani wrote:
>> But that would involve JGroups code calling Buffer.copy() again,
>> which is the same as using a normal BAOS. Just that it happens a
>> bit later in the chain of events.
>
> No: the byte[] buffer with offset and length are passed down to the
> TCP or datagram socket and *NOT* copied at all !
Ok, makes more sense. Misleading copy() method on the class had me
thinking it was actually used somewhere. :-)
>> This should have far-reaching consequences as I'm not aware of
>> anyone else but JBossCache to use Marshaller. Or maybe, to be on
>> the safe side, I could create a Marshaller2 so existing code
>> doesn't break (extending Marshaller)... http://jira.jboss.com/jira/browse/JGRP-796That
>> should
>>
>> I wasn't talking about reusing stream instances, I was referring to
>> the same problem you have above with JGroups is going to be
>> encountered with every cache loader impl in that the byte[]
>> retrieved may be larger than necessary and contain uninitialized
>> values.
>
> So JBC has to switch to a Buffer-like implementation too. At least
> where it is important. I suggest do it immediately wherever code can
> be changed (e.g. internal code) and defer it to later in cases where
> external code might rely on it, in order not to break anything.
Ok, so once we have a Marshaller interface that uses this Buffer I can
switch to it.
> We need to reduce copying wherever possible !
+100
--
Manik Surtani
Lead, JBoss Cache
manik at jboss.org
More information about the jbosscache-dev
mailing list