[
https://issues.apache.org/jira/browse/DERBY-2444?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12484359
]
Knut Anders Hatlen commented on DERBY-2444:
-------------------------------------------
Thanks for the updated patch, Narayanan!
I looked at the javadoc for Blob.getBinaryStream(long,long) at
http://java.sun.com/javase/6/docs/api/. It says
Throws:
SQLException - if pos is less than 1 or if pos is greater than the number
of bytes in the Blob or if pos + length is greater than the number of bytes in
the Blob
(The wording is similar for Clob.getCharacterStream(long,long).)
I don't think that matches the current checks. For instance,
Lob.checkPosition() throws exception if (pos > length() + 1) whereas the it
should throw exception if (pos > length()) . And checkLength() only checks
whether length is negative. It would probably be good to add tests for these
boundary cases in BlobTest/ClobTest as well.
I don't think this part of getBinaryStream() is correct:
+ InputStream retVal = new java.io.ByteArrayInputStream
+ (binaryString_, (int)(pos), (int)length);
The pos argument starts on 1, whereas the offset argument to
ByteArrayInputStream starts on 0. The tests in BlobTest passed, though, which I
found a bit puzzling. It seems there is a dataOffset_ variable in Blob which,
by accident, was one when running the tests, so the bug wasn't discovered. I
believe pos should be replaced with (dataOffset_ + pos - 1).
> Implement not implemented methods Blob.getBinaryStream(long pos, long length)
> and Clob. getCharacterStream(long pos, long length) in the Network Client
> -------------------------------------------------------------------------------------------------------------------------------------------------------
>
> Key: DERBY-2444
> URL: https://issues.apache.org/jira/browse/DERBY-2444
> Project: Derby
> Issue Type: Improvement
> Components: Network Client
> Reporter: V.Narayanan
> Assigned To: V.Narayanan
> Attachments: ClobBlobNotImplemented_v1.diff,
> ClobBlobNotImplemented_v1.stat, ClobBlobNotImplemented_v2.diff,
> ClobBlobNotImplemented_v2.stat
>
>
> The following methods were introduced in the java.sql.Clob and java.sql.Blob
> interface as part of JDBC 4.0 and need to be implemented.
> Clob
> ------
> getCharacterStream(long pos, long length)
> Blob
> ------
> getBinaryStream(long pos, long length)
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.