[
https://issues.apache.org/jira/browse/OAK-956?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Alexander Klimetschek updated OAK-956:
--------------------------------------
Priority: Major (was: Minor)
Issue Type: Bug (was: Improvement)
Actually, it's a major bug, because {{BufferedInputStream}} *requires* a
correct implementation of {{InputStream#available()}}.
The {{SegmentStream}} makes use of the {{InputStream}} contract that allows to
return less bytes in a {{read()}} call than it was asked for. This happens here
at the borders of the 4K segments. This behavior is handled by the
BufferedInputStream (BIS), which loops over the read until it got all bytes, so
clients using BIS don't have to worry about that. However, that loop in BIS has
an optimization and checks wether {{available()}} returns more than 0 before
actually trying again. Since SegmentStream always returns 0, this fails.
The issue came up with sling's HTTP Byte Range request support (inside
[StreamRendererServlet|http://svn.apache.org/repos/asf/sling/trunk/bundles/servlets/get/src/main/java/org/apache/sling/servlets/get/impl/helpers/StreamRendererServlet.java])
which uses a BIS. But anyway, using a BufferedInputStream is a standard
approach in Java when handling streams, especially if they have that very
issue, so this is a major bug.
> SegmentStream doesn't implement the method available()
> ------------------------------------------------------
>
> Key: OAK-956
> URL: https://issues.apache.org/jira/browse/OAK-956
> Project: Jackrabbit Oak
> Issue Type: Bug
> Components: core
> Reporter: Antonio Sanso
>
> org.apache.jackrabbit.oak.plugins.segment.SegmentStream doesn't implement
> the method available()
> {code}
> Value.getStream().available()
> {code}
> will always return 0
--
This message was sent by Atlassian JIRA
(v6.1#6144)