[
http://jira.jboss.com/jira/browse/JBCACHE-1289?page=comments#action_12398907 ]
Manik Surtani commented on JBCACHE-1289:
----------------------------------------
Thanks for the patch, but I've got something else in trunk at the moment which may
solve your problem all the same.
The reason why I was using available() and creating a byte[] was so I could use pooled
OOS/OIS, but this is not going to work unless the source stream is a byte array input
stream in the first place. I.e., for unmarshalling replication events from JGroups, it
works fine but for cache loading I have to fall back to creating a new OOS/OIS directly
from the stream passed in. So unless the stream is a BAIS (in which case available() is
reliable) it won't use available() anymore.
VersionAwareMarshalle.objectFromStream implemention uses unreliable
InputStream.available
-----------------------------------------------------------------------------------------
Key: JBCACHE-1289
URL:
http://jira.jboss.com/jira/browse/JBCACHE-1289
Project: JBoss Cache
Issue Type: Bug
Security Level: Public(Everyone can see)
Reporter: Elias Ross
Assigned To: Manik Surtani
InputStream.available() may return less than the complete number of bytes available on
the stream. The following does not work:
@Override
public Object objectFromStream(InputStream is) throws Exception
{
int avbl = is.available(); // MAY RETURN 1 !
byte[] bytes = new byte[avbl];
is.read(bytes, 0, avbl);
return objectFromByteBuffer(bytes);
}
I want to be able to stream objects from the Amazon S3 service. The following does not
work either:
ObjectInputStream ois = new MarshalledValueInputStream(is);
short versionId = ois.readShort();
Marshaller marshaller = getMarshaller(versionId);
return marshaller.objectFromObjectStream(ois);
I'm guessing ReusableObjectInputStream needs to be used and changed to actually
support streams, not byte arrays! But I'm not too familiar with the mechanics.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira