diff --git a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/proxy/BlobProxy.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/proxy/BlobProxy.java index 68d91a37c3..12e12dcae0 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/proxy/BlobProxy.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/proxy/BlobProxy.java @@ -70,8 +70,9 @@ public final class BlobProxy implements Blob, BlobImplementer { } private void setStreamMark() { - if ( binaryStream.getInputStream().markSupported() ) { - binaryStream.getInputStream().mark( markBytes ); + final InputStream inputStream = binaryStream.getInputStream(); + if ( inputStream != null && inputStream.markSupported() ) { + inputStream.mark( markBytes ); resetAllowed = true; } else { @@ -92,12 +93,14 @@ public final class BlobProxy implements Blob, BlobImplementer { private void resetIfNeeded() throws SQLException { try { if ( needsReset ) { - if ( !resetAllowed ) { + final InputStream inputStream = binaryStream.getInputStream(); + if ( !resetAllowed && inputStream != null) { throw new SQLException( "Underlying stream does not allow reset" ); } - - binaryStream.getInputStream().reset(); - setStreamMark(); + if ( inputStream != null ) { + inputStream.reset(); + setStreamMark(); + } } } catch ( IOException ioe) {