You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-dev@db.apache.org by "Kristian Waagan (JIRA)" <ji...@apache.org> on 2009/02/17 08:24:59 UTC
[jira] Commented: (DERBY-4061) InputStream returned from
Blob.getBinaryStream(long, long) terminates the stream by returning 0,
should return -1
[ https://issues.apache.org/jira/browse/DERBY-4061?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12674114#action_12674114 ]
Kristian Waagan commented on DERBY-4061:
----------------------------------------
I think the problem is restricted to UpdatableBlobStream only. The combinations I tried with Clob succeeded, and the client driver also succeeds with the repro for both Blob and Clob.
The problem in UpdatableBlobStream, is that the underlying source is asked to read zero bytes, which it does... The calling code fails to handle this scenario, which is a valid one seen from InputStream (from JavaDoc: "If len is zero, then no bytes are read and 0 is returned; otherwise, there is an attempt to read at least one byte.").
> InputStream returned from Blob.getBinaryStream(long, long) terminates the stream by returning 0, should return -1
> -----------------------------------------------------------------------------------------------------------------
>
> Key: DERBY-4061
> URL: https://issues.apache.org/jira/browse/DERBY-4061
> Project: Derby
> Issue Type: Bug
> Components: JDBC
> Affects Versions: 10.4.2.0
> Reporter: Trejkaz
>
> Take the following code to copy a sub-stream from a BLOB:
> Blob blob = rs.getBlob(1);
> InputStream stream = blob.getBinaryStream(1000, 2000);
> try {
> IOUtils.copy(stream, out);
> } finally {
> stream.close();
> }
> This will loop forever in IOUtils.copy, as the InputStream is returning 0 at end of stream instead of -1. It probably should return -1 to comply with the Javadoc for InputStream.
> Notes:
> I have not yet checked Blob.getBinaryStream(), or any of the Clob methods, or the client driver. So some of these may have a similar issue.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.