[CONJ-77] Method getBinaryStream() on Blob's throws Out of range (position > stream size) Created: 2013-11-19  Updated: 2014-10-24  Resolved: 2014-10-21

Status: Closed
Project: MariaDB Connector/J
Component/s: None
Affects Version/s: 1.1.5
Fix Version/s: 1.1.8

Type: Bug Priority: Critical
Reporter: Max Larsson Assignee: Massimo Siani (Inactive)
Resolution: Fixed Votes: 0
Labels: None

Attachments: Java Source File BlobTest.java     File CONJ77.patch     Java Archive File mariadb-java-client-1.1.8-preview.jar     Java Archive File mariadb-java-client-1.1.8-preview.jar    

 Description   

See the attached test. This issue describes a different behavior than the
MySQL/J Connector (v5.1.23), and thus the fails here being a drop in replacement.

If a table with a Blob column has the value of an empty string stored, it can't be restored with the getBinaryStream method of the Blob, because it throws
a SQLException with "Out of range (position > stream size)". Per se this
is a legal behavior, but in regards to be a drop in replacement not.



 Comments   
Comment by Jochen Wiedmann [ 2014-02-20 ]

Attaching a proposed patch. (Includes test case.)

Comment by Jochen Wiedmann [ 2014-02-20 ]

Fortunately, a patch seems trivial. The method

public InputStream getBinaryStream(final long pos, final long length)

doesn't take into account that pos is 1-based. In other words, it is sufficient to change

if (pos > actualSize)

{ throw SQLExceptionMapper.getSQLException("Out of range (position > stream size)"); }

to

if (pos-1 > actualSize) { throw SQLExceptionMapper.getSQLException("Out of range (position > stream size)"); }

(See attachment CONJ77.patch, which includes the test case from BlobTest.java.)

Comment by Cedric [ 2014-10-15 ]

I need this correction before next week and I see that 1.1.8 version is not released at this moment.
So, I patched connector source files thanks to CONJ77.patch ... but then I do not manage to genate binary files using pom.xml. I have a weird problem with "bzr" command.

Is it possible for you to attach mariadb connector binary files including this patch ?

Thanks a lot for your work !

Comment by Massimo Siani (Inactive) [ 2014-10-16 ]

I attached a snapshot that contains some more fixes than just this one. As far as I know, this is very close to 1.1.8, contains the closed issues and most of the 'in review' ones, too.

Or, I can just apply the patch for CONJ-77, if you wish.

Comment by Cedric [ 2014-10-16 ]

Perfect ! Thanks a lot. This is more than I need.

Comment by Cedric [ 2014-10-24 ]

Unfortunately I now get the error detailled in CONJ-114 ...
Is the correction included into mariadb-java-client-1.1.8-preview.jar ?

If not is it possible to do it ? ...

Thank you !

Comment by Massimo Siani (Inactive) [ 2014-10-24 ]

Replaced with the latest snapshot.

Comment by Cedric [ 2014-10-24 ]

Thanks ! It works fine !

Generated at Thu Feb 08 03:12:59 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.