Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
-
1.1.8
-
None
-
Sprint connector/j 1.3.0
Description
When trying to write a blob via an input stream of unknown size, you most likely end up with an initialization of the JPA Blob field like:
public final void setDocument(InputStream inputStream, EntityManager entityManager) { |
HibernateEntityManager hibernateEntityManager = entityManager.unwrap(HibernateEntityManager.class); |
Session session = hibernateEntityManager.getSession();
|
LobHelper lobHelper = session.getLobHelper();
|
this.document = lobHelper.createBlob(inputStream, -1); |
}
|
while this works for the MySQL Java Connector, it does not for the MariaDB Java Client.
The following patch fixes this issue:
--- ./src/main/java/org/mariadb/jdbc/internal/common/query/parameters/ParameterWriter.java.orig 2015-02-09 17:01:52.494722950 +0100 |
+++ ./src/main/java/org/mariadb/jdbc/internal/common/query/parameters/ParameterWriter.java 2015-02-09 17:13:43.683386990 +0100 |
@@ -91,7 +91,7 @@ |
|
for (;;) { |
int bytesToRead = (int)Math.min(bytesLeft, buffer.length); |
- if(bytesToRead == 0) |
+ if(bytesToRead <= 0) |
break; |
len = is.read(buffer,0, bytesToRead); |
if (len <= 0) |