Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id CE740200C34 for ; Mon, 27 Feb 2017 09:49:27 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id CD38F160B7D; Mon, 27 Feb 2017 08:49:27 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 22CC1160B6C for ; Mon, 27 Feb 2017 09:49:26 +0100 (CET) Received: (qmail 12337 invoked by uid 500); 27 Feb 2017 08:49:26 -0000 Mailing-List: contact commits-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list commits@activemq.apache.org Received: (qmail 12312 invoked by uid 99); 27 Feb 2017 08:49:26 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 27 Feb 2017 08:49:26 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 09FC6DFDA9; Mon, 27 Feb 2017 08:49:26 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: martyntaylor@apache.org To: commits@activemq.apache.org Date: Mon, 27 Feb 2017 08:49:26 -0000 Message-Id: <119b515a5b3f4c3a87d37b79fd26b556@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [1/3] activemq-artemis git commit: ARTEMIS-998 Fix NPE in JDBC FileDriver when BLOB is null archived-at: Mon, 27 Feb 2017 08:49:28 -0000 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 Authored: Sat Feb 25 11:36:16 2017 +0000 Committer: Martyn Taylor 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;