skorotkov commented on code in PR #11492:
URL: https://github.com/apache/ignite/pull/11492#discussion_r1743415899
##########
modules/core/src/main/java/org/apache/ignite/internal/jdbc2/JdbcBlob.java:
##########
@@ -54,7 +54,7 @@ public JdbcBlob(byte[] arr) {
@Override public byte[] getBytes(long pos, int len) throws SQLException {
ensureNotClosed();
- if (pos < 1 || arr.length - pos < 0 || len < 0)
+ if (pos < 1 || (arr.length - pos < 0 && arr.length > 0) || len < 0)
Review Comment:
It's needed to support the empty Blobs (blobs backed by an empty array).
Such blobs are returned from the java.sql.Connection::createBlob() which is
a standard way to get blob from arbitrary JDBC driver. It also may be created
via the concrete constructor as well like in the unittest below:
```
blob = new JdbcBlob(new byte[0]);
assertEquals(0, blob.getBytes(1, 0).length);
```
This is a correct code according to java.sql.Blob contract.
***
The corrsponding testcase was added into the file
modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcBlobTest.java
in this PR.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]