activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From martyntay...@apache.org
Subject [1/3] activemq-artemis git commit: ARTEMIS-998 Fix NPE in JDBC FileDriver when BLOB is null
Date Mon, 27 Feb 2017 08:49:26 GMT
Repository: activemq-artemis
Updated Branches:
  refs/heads/1.x 84acb2f50 -> e79524683


ARTEMIS-998 Fix NPE in JDBC FileDriver when BLOB is null

(cherry picked from commit a1012884ccc765e8670a172612aa1e582b865ca7)


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/01075ae3
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/01075ae3
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/01075ae3

Branch: refs/heads/1.x
Commit: 01075ae36f3ab288660baf24902f0d15dbb37aca
Parents: 84acb2f
Author: Martyn Taylor <mtaylor@redhat.com>
Authored: Sat Feb 25 11:36:16 2017 +0000
Committer: Martyn Taylor <mtaylor@redhat.com>
Committed: Mon Feb 27 08:48:22 2017 +0000

----------------------------------------------------------------------
 .../store/file/JDBCSequentialFileFactoryDriver.java  | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/01075ae3/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/file/JDBCSequentialFileFactoryDriver.java
----------------------------------------------------------------------
diff --git a/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/file/JDBCSequentialFileFactoryDriver.java
b/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/file/JDBCSequentialFileFactoryDriver.java
index 90be5ff..54e6965 100644
--- a/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/file/JDBCSequentialFileFactoryDriver.java
+++ b/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/file/JDBCSequentialFileFactoryDriver.java
@@ -155,7 +155,9 @@ public class JDBCSequentialFileFactoryDriver extends AbstractJDBCDriver
{
          try (ResultSet rs = readLargeObject.executeQuery()) {
             if (rs.next()) {
                Blob blob = rs.getBlob(1);
-               file.setWritePosition((int) blob.length());
+               if (blob != null) {
+                  file.setWritePosition((int) blob.length());
+               }
             }
             connection.commit();
          } catch (SQLException e) {
@@ -250,6 +252,9 @@ public class JDBCSequentialFileFactoryDriver extends AbstractJDBCDriver
{
          try (ResultSet rs = appendToLargeObject.executeQuery()) {
             if (rs.next()) {
                Blob blob = rs.getBlob(1);
+               if (blob == null) {
+                  blob = connection.createBlob();
+               }
                bytesWritten = blob.setBytes(blob.length() + 1, data);
                rs.updateBlob(1, blob);
                rs.updateRow();
@@ -279,9 +284,11 @@ public class JDBCSequentialFileFactoryDriver extends AbstractJDBCDriver
{
          try (ResultSet rs = readLargeObject.executeQuery()) {
             if (rs.next()) {
                final Blob blob = rs.getBlob(1);
-               readLength = (int) calculateReadLength(blob.length(), bytes.remaining(), file.position());
-               byte[] data = blob.getBytes(file.position() + 1, readLength);
-               bytes.put(data);
+               if (blob != null) {
+                  readLength = (int) calculateReadLength(blob.length(), bytes.remaining(),
file.position());
+                  byte[] data = blob.getBytes(file.position() + 1, readLength);
+                  bytes.put(data);
+               }
             }
             connection.commit();
             return readLength;


Mime
View raw message