ARTEMIS-998 Fix NPE in JDBC FileDriver when BLOB is null
This commit is contained in:
parent
739b8e75b5
commit
a1012884cc
|
@ -155,8 +155,10 @@ public class JDBCSequentialFileFactoryDriver extends AbstractJDBCDriver {
|
||||||
try (ResultSet rs = readLargeObject.executeQuery()) {
|
try (ResultSet rs = readLargeObject.executeQuery()) {
|
||||||
if (rs.next()) {
|
if (rs.next()) {
|
||||||
Blob blob = rs.getBlob(1);
|
Blob blob = rs.getBlob(1);
|
||||||
|
if (blob != null) {
|
||||||
file.setWritePosition((int) blob.length());
|
file.setWritePosition((int) blob.length());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
connection.commit();
|
connection.commit();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
connection.rollback();
|
connection.rollback();
|
||||||
|
@ -250,6 +252,9 @@ public class JDBCSequentialFileFactoryDriver extends AbstractJDBCDriver {
|
||||||
try (ResultSet rs = appendToLargeObject.executeQuery()) {
|
try (ResultSet rs = appendToLargeObject.executeQuery()) {
|
||||||
if (rs.next()) {
|
if (rs.next()) {
|
||||||
Blob blob = rs.getBlob(1);
|
Blob blob = rs.getBlob(1);
|
||||||
|
if (blob == null) {
|
||||||
|
blob = connection.createBlob();
|
||||||
|
}
|
||||||
bytesWritten = blob.setBytes(blob.length() + 1, data);
|
bytesWritten = blob.setBytes(blob.length() + 1, data);
|
||||||
rs.updateBlob(1, blob);
|
rs.updateBlob(1, blob);
|
||||||
rs.updateRow();
|
rs.updateRow();
|
||||||
|
@ -279,10 +284,12 @@ public class JDBCSequentialFileFactoryDriver extends AbstractJDBCDriver {
|
||||||
try (ResultSet rs = readLargeObject.executeQuery()) {
|
try (ResultSet rs = readLargeObject.executeQuery()) {
|
||||||
if (rs.next()) {
|
if (rs.next()) {
|
||||||
final Blob blob = rs.getBlob(1);
|
final Blob blob = rs.getBlob(1);
|
||||||
|
if (blob != null) {
|
||||||
readLength = (int) calculateReadLength(blob.length(), bytes.remaining(), file.position());
|
readLength = (int) calculateReadLength(blob.length(), bytes.remaining(), file.position());
|
||||||
byte[] data = blob.getBytes(file.position() + 1, readLength);
|
byte[] data = blob.getBytes(file.position() + 1, readLength);
|
||||||
bytes.put(data);
|
bytes.put(data);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
connection.commit();
|
connection.commit();
|
||||||
return readLength;
|
return readLength;
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
|
|
Loading…
Reference in New Issue