[jboss-jira] [JBoss JIRA] Commented: (JBCACHE-1289) VersionAwareMarshalle.objectFromStream implemention uses unreliable InputStream.available

Elias Ross (JIRA) jira-events at lists.jboss.org
Fri Feb 8 13:00:04 EST 2008


    [ http://jira.jboss.com/jira/browse/JBCACHE-1289?page=comments#action_12398952 ] 
            
Elias Ross commented on JBCACHE-1289:
-------------------------------------

Your changes don't work:

org.jboss.cache.CacheException: java.io.StreamCorruptedException: invalid stream header: 79770500
...
Caused by: java.io.StreamCorruptedException: invalid stream header: 79770500
	at java.io.ObjectInputStream.readStreamHeader(Unknown Source)
	at java.io.ObjectInputStream.<init>(Unknown Source)
	at org.jboss.util.stream.MarshalledValueInputStream.<init>(MarshalledValueInputStream.java:45)
	at org.jboss.cache.marshall.VersionAwareMarshaller.objectFromStream(VersionAwareMarshaller.java:240)
	at org.jboss.cache.loader.s3.S3CacheLoader.get(S3CacheLoader.java:260)

Hence the "PushbackInputStream" to put in the header.

> 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

        



More information about the jboss-jira mailing list