You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-dev@jackrabbit.apache.org by Chetan Mehrotra <ch...@gmail.com> on 2015/05/21 08:20:50 UTC

LazyInputStream does not uses BufferedInputStream while creating stream from underlying File

While having a look at how the InputStream is opened while accessing
content from any binary file it appears that LazyInputStream creates a
FileInputStream [1] from the underlying file instance

Should not it be a BufferedInputStream or is it the responsibility of
the caller to wrap it in the buffered variant?

Chetan Mehrotra
[1] https://github.com/apache/jackrabbit/blob/trunk/jackrabbit-data/src/main/java/org/apache/jackrabbit/core/data/LazyFileInputStream.java#L102

Re: LazyInputStream does not uses BufferedInputStream while creating stream from underlying File

Posted by Chetan Mehrotra <ch...@gmail.com>.
Opened OAK-2898 to track this.

Testing that passed stream at Oak/JCR level is buffered would indeed be tricky!
Chetan Mehrotra


On Thu, May 21, 2015 at 2:16 PM, Thomas Mueller <mu...@adobe.com> wrote:
> Hi,
>
> Sure.
>
> We should probably have some kind of test case to ensure the stream is
> wrapped. Not sure how to be test it, if the BufferedInputStream is again
> wrapped in some other way:
>
> * Check if "markSupported()" returns true (it does for
> BufferedInputStream, but not for FileInputStream; and if
> BufferedInputStream is again wrapped, typically markSupported() is
> delegated, at least in FilterInputStream).
> * Using reflection? :-)
> * Measureing performance: not a reliable way to test it
>
>
> Regards,
> Thomas
>
> On 21/05/15 10:33, "Chetan Mehrotra" <ch...@gmail.com> wrote:
>
>>On Thu, May 21, 2015 at 1:31 PM, Thomas Mueller <mu...@adobe.com> wrote:
>>> Yes, it would be better if we wrap it somewhere (not necessarily right
>>> there, but somewhere
>>
>>I think we can do that in DataStoreBlobStore. Right?
>>
>>Chetan Mehrotra
>

Re: LazyInputStream does not uses BufferedInputStream while creating stream from underlying File

Posted by Thomas Mueller <mu...@adobe.com>.
Hi,

Sure.

We should probably have some kind of test case to ensure the stream is
wrapped. Not sure how to be test it, if the BufferedInputStream is again
wrapped in some other way:

* Check if "markSupported()" returns true (it does for
BufferedInputStream, but not for FileInputStream; and if
BufferedInputStream is again wrapped, typically markSupported() is
delegated, at least in FilterInputStream).
* Using reflection? :-)
* Measureing performance: not a reliable way to test it


Regards,
Thomas

On 21/05/15 10:33, "Chetan Mehrotra" <ch...@gmail.com> wrote:

>On Thu, May 21, 2015 at 1:31 PM, Thomas Mueller <mu...@adobe.com> wrote:
>> Yes, it would be better if we wrap it somewhere (not necessarily right
>> there, but somewhere
>
>I think we can do that in DataStoreBlobStore. Right?
>
>Chetan Mehrotra


Re: LazyInputStream does not uses BufferedInputStream while creating stream from underlying File

Posted by Chetan Mehrotra <ch...@gmail.com>.
On Thu, May 21, 2015 at 1:31 PM, Thomas Mueller <mu...@adobe.com> wrote:
> Yes, it would be better if we wrap it somewhere (not necessarily right
> there, but somewhere

I think we can do that in DataStoreBlobStore. Right?

Chetan Mehrotra

Re: LazyInputStream does not uses BufferedInputStream while creating stream from underlying File

Posted by Thomas Mueller <mu...@adobe.com>.
Hi,

Yes, it would be better if we wrap it somewhere (not necessarily right
there, but somewhere), because the caller will not always do that. I
thought that's already done, but I'm not sure.

Regards,
Thomas

On 21/05/15 08:20, "Chetan Mehrotra" <ch...@gmail.com> wrote:

>While having a look at how the InputStream is opened while accessing
>content from any binary file it appears that LazyInputStream creates a
>FileInputStream [1] from the underlying file instance
>
>Should not it be a BufferedInputStream or is it the responsibility of
>the caller to wrap it in the buffered variant?
>
>Chetan Mehrotra
>[1] 
>https://github.com/apache/jackrabbit/blob/trunk/jackrabbit-data/src/main/j
>ava/org/apache/jackrabbit/core/data/LazyFileInputStream.java#L102