mark()/reset() bug in InputEntityStream

4 messages Options
Embed this post
Permalink
Arjohn Kampman

mark()/reset() bug in InputEntityStream

Reply Threaded More More options
Print post
Permalink
Hi again,

I'm running into a problem that I've traced back to InputEntityStream.
This class doesn't handle mark/reset combinations properly, although it
does indicate the this functionality is supported if the underlying
stream supports it. I'm setting a mark, read X bytes from the stream and
then reset the stream to the marked position. After this, the stream
ends exactly X bytes before the actual end of the stream.

The bug is related to the availableSize variable in InputEntityStream.
This variable is decreased with each call to read(...), but is never
increased when reset() is called.

There's a very simple and less simple solution for this. The very simple
solution is to override markSupported() and return false. The less
simple solution is to handle the mark/reset properly.

FWIW: I would prefer the less simple solution :-)


--
Arjohn Kampman, Senior Software Engineer
Aduna - Semantic Power
www.aduna-software.com

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=7458&dsMessageId=2414898
jlouvel

RE: mark()/reset() bug in InputEntityStream

Reply Threaded More More options
Print post
Permalink
Arjohn,

Thanks for reporting this bug. I have just fixed it in SVN 1.1 branch and
SVN trunk. Also, I added a test case and I went for the less simple option
;-)

Best regards,
Jerome Louvel
--
Restlet ~ Founder and Lead developer ~ http://www.restlet.org
Noelios Technologies ~ Co-founder ~ http://www.noelios.com




-----Message d'origine-----
De : Arjohn Kampman [mailto:[hidden email]]
Envoyé : jeudi 5 novembre 2009 21:24
À : [hidden email]
Objet : mark()/reset() bug in InputEntityStream

Hi again,

I'm running into a problem that I've traced back to InputEntityStream.
This class doesn't handle mark/reset combinations properly, although it
does indicate the this functionality is supported if the underlying
stream supports it. I'm setting a mark, read X bytes from the stream and
then reset the stream to the marked position. After this, the stream
ends exactly X bytes before the actual end of the stream.

The bug is related to the availableSize variable in InputEntityStream.
This variable is decreased with each call to read(...), but is never
increased when reset() is called.

There's a very simple and less simple solution for this. The very simple
solution is to override markSupported() and return false. The less
simple solution is to handle the mark/reset properly.

FWIW: I would prefer the less simple solution :-)


--
Arjohn Kampman, Senior Software Engineer
Aduna - Semantic Power
www.aduna-software.com

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=7458&dsMessageId=24148
98

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=7458&dsMessageId=2416514
Arjohn Kampman

Re: mark()/reset() bug in InputEntityStream

Reply Threaded More More options
Print post
Permalink
Thank you very much!

Regards,

Arjohn


Jerome Louvel wrote:

> Arjohn,
>
> Thanks for reporting this bug. I have just fixed it in SVN 1.1 branch and
> SVN trunk. Also, I added a test case and I went for the less simple option
> ;-)
>
> Best regards,
> Jerome Louvel
> --
> Restlet ~ Founder and Lead developer ~ http://www.restlet.org
> Noelios Technologies ~ Co-founder ~ http://www.noelios.com
>
>
>
>
> -----Message d'origine-----
> De : Arjohn Kampman [mailto:[hidden email]]
> Envoyé : jeudi 5 novembre 2009 21:24
> À : [hidden email]
> Objet : mark()/reset() bug in InputEntityStream
>
> Hi again,
>
> I'm running into a problem that I've traced back to InputEntityStream.
> This class doesn't handle mark/reset combinations properly, although it
> does indicate the this functionality is supported if the underlying
> stream supports it. I'm setting a mark, read X bytes from the stream and
> then reset the stream to the marked position. After this, the stream
> ends exactly X bytes before the actual end of the stream.
>
> The bug is related to the availableSize variable in InputEntityStream.
> This variable is decreased with each call to read(...), but is never
> increased when reset() is called.
>
> There's a very simple and less simple solution for this. The very simple
> solution is to override markSupported() and return false. The less
> simple solution is to handle the mark/reset properly.
>
> FWIW: I would prefer the less simple solution :-)
>
>


--
Arjohn Kampman, Senior Software Engineer
Aduna - Semantic Power
www.aduna-software.com

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=7458&dsMessageId=2416573
Arjohn Kampman

Re: mark()/reset() bug in InputEntityStream

Reply Threaded More More options
Print post
Permalink
Hi Jerome,

I just tested the fix using the new snapshots from the public maven
repo. The problem is gone now, I'm seeing a green test results line
again :-)

Arjohn

Arjohn Kampman wrote:

> Thank you very much!
>
> Regards,
>
> Arjohn
>
>
> Jerome Louvel wrote:
>> Arjohn,
>>
>> Thanks for reporting this bug. I have just fixed it in SVN 1.1 branch and
>> SVN trunk. Also, I added a test case and I went for the less simple option
>> ;-)
>>
>> Best regards,
>> Jerome Louvel
>> --
>> Restlet ~ Founder and Lead developer ~ http://www.restlet.org
>> Noelios Technologies ~ Co-founder ~ http://www.noelios.com
>>
>>
>>
>>
>> -----Message d'origine-----
>> De : Arjohn Kampman [mailto:[hidden email]]
>> Envoyé : jeudi 5 novembre 2009 21:24
>> À : [hidden email]
>> Objet : mark()/reset() bug in InputEntityStream
>>
>> Hi again,
>>
>> I'm running into a problem that I've traced back to InputEntityStream.
>> This class doesn't handle mark/reset combinations properly, although it
>> does indicate the this functionality is supported if the underlying
>> stream supports it. I'm setting a mark, read X bytes from the stream and
>> then reset the stream to the marked position. After this, the stream
>> ends exactly X bytes before the actual end of the stream.
>>
>> The bug is related to the availableSize variable in InputEntityStream.
>> This variable is decreased with each call to read(...), but is never
>> increased when reset() is called.
>>
>> There's a very simple and less simple solution for this. The very simple
>> solution is to override markSupported() and return false. The less
>> simple solution is to handle the mark/reset properly.
>>
>> FWIW: I would prefer the less simple solution :-)
>>
>>
>
>


--
Arjohn Kampman, Senior Software Engineer
Aduna - Semantic Power
www.aduna-software.com

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=7458&dsMessageId=2419997