Skip to content

Commit 0b61cc3

Browse files
dreab8beikov
authored andcommitted
HHH-14725 Fix reset handling on BlobProxy
1 parent 0b28e2c commit 0b61cc3

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

hibernate-core/src/main/java/org/hibernate/engine/jdbc/BlobProxy.java

+10-7
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public final class BlobProxy implements Blob, BlobImplementer {
4949
* @see #generateProxy(byte[])
5050
*/
5151
private BlobProxy(byte[] bytes) {
52-
binaryStream = new ArrayBackedBinaryStream( bytes );
52+
binaryStream = new BinaryStreamImpl(bytes);
5353
markBytes = bytes.length + 1;
5454
setStreamMark();
5555
}
@@ -68,8 +68,9 @@ private BlobProxy(InputStream stream, long length) {
6868
}
6969

7070
private void setStreamMark() {
71-
if ( binaryStream.getInputStream().markSupported() ) {
72-
binaryStream.getInputStream().mark( markBytes );
71+
final InputStream inputStream = binaryStream.getInputStream();
72+
if ( inputStream != null && inputStream.markSupported() ) {
73+
inputStream.mark( markBytes );
7374
resetAllowed = true;
7475
}
7576
else {
@@ -89,12 +90,14 @@ public BinaryStream getUnderlyingStream() throws SQLException {
8990
private void resetIfNeeded() throws SQLException {
9091
try {
9192
if ( needsReset ) {
92-
if ( !resetAllowed ) {
93+
final InputStream inputStream = binaryStream.getInputStream();
94+
if ( !resetAllowed && inputStream != null) {
9395
throw new SQLException( "Underlying stream does not allow reset" );
9496
}
95-
96-
binaryStream.getInputStream().reset();
97-
setStreamMark();
97+
if ( inputStream != null ) {
98+
inputStream.reset();
99+
setStreamMark();
100+
}
98101
}
99102
}
100103
catch ( IOException ioe) {

0 commit comments

Comments
 (0)