Skip to content

Commit cf40b83

Browse files
committed
HHH-14725 Fix reset handling on BlobProxy
1 parent 4f6faec commit cf40b83

File tree

1 file changed

+9
-6
lines changed
  • hibernate-core/src/main/java/org/hibernate/engine/jdbc/proxy

1 file changed

+9
-6
lines changed

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

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,9 @@ private BlobProxy(InputStream stream, long length) {
7070
}
7171

7272
private void setStreamMark() {
73-
if ( binaryStream.getInputStream().markSupported() ) {
74-
binaryStream.getInputStream().mark( markBytes );
73+
final InputStream inputStream = binaryStream.getInputStream();
74+
if ( inputStream != null && inputStream.markSupported() ) {
75+
inputStream.mark( markBytes );
7576
resetAllowed = true;
7677
}
7778
else {
@@ -92,12 +93,14 @@ public BinaryStream getUnderlyingStream() throws SQLException {
9293
private void resetIfNeeded() throws SQLException {
9394
try {
9495
if ( needsReset ) {
95-
if ( !resetAllowed ) {
96+
final InputStream inputStream = binaryStream.getInputStream();
97+
if ( !resetAllowed && inputStream != null) {
9698
throw new SQLException( "Underlying stream does not allow reset" );
9799
}
98-
99-
binaryStream.getInputStream().reset();
100-
setStreamMark();
100+
if ( inputStream != null ) {
101+
inputStream.reset();
102+
setStreamMark();
103+
}
101104
}
102105
}
103106
catch ( IOException ioe) {

0 commit comments

Comments
 (0)