RereadableInputStream Closes the Original Stream

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

RereadableInputStream Closes the Original Stream

Keith R. Bennett
All -

Currently, the RereadableInputStream is intended as a wrapper around a stream, kind of like a BufferedInputStream.  It was intended to be used by, for example, an MS Word parser implementation that needed to make multiple passes over the data.

Like the BufferedInputStream, the RereadableInputStream closes the stream it's wrapping when its close() is called.  This seemed like the logical thing to do at the time.  Unfortunately, this is contrary to our statement in the Parser javadoc that says:

"The given stream is consumed but not closed by this method. The responsibility to close the stream remains on the caller."

Shall I change RereadableInputStream so that it does not close the stream it wraps?  This would make it conform with our current usage.  However, it might be a little surprising to a user of the class (and this class may be useful outside of our current use case).  Perhaps there could be a 'closeOriginalStream' constructor parameter?  This would support our use case while still providing the opportunity to use the class in a more general way.  This would be my preference.  What do you think?

Thanks,
Keith

Reply | Threaded
Open this post in threaded view
|

Re: RereadableInputStream Closes the Original Stream

Bertrand Delacretaz-2
On 10/9/07, Keith R. Bennett <[hidden email]> wrote:

> ...Shall I change RereadableInputStream so that it does not close the stream it
> wraps?...
> ...Perhaps there could be a
> 'closeOriginalStream' constructor parameter?...

That's probably the easiest thing to do.

-Bertrand
Reply | Threaded
Open this post in threaded view
|

Re: RereadableInputStream Closes the Original Stream

Keith R. Bennett
Bertrand -

Thanks for your advice.  I've changed the code accordingly, and the patch is attached to TIKA-52.  Since it may be a while before I can commit, is there someone else who could do that?

Thanks and regards,
Keith


Bertrand Delacretaz wrote
On 10/9/07, Keith R. Bennett <kbennett@bbsinc.biz> wrote:

> ...Shall I change RereadableInputStream so that it does not close the stream it
> wraps?...
> ...Perhaps there could be a
> 'closeOriginalStream' constructor parameter?...

That's probably the easiest thing to do.

-Bertrand