HHH-14725 Fix reset handling on BlobProxy

This commit is contained in:
Andrea Boriero 2024-12-11 12:33:16 +01:00 committed by Andrea Boriero
parent c475770d09
commit 57c0b26d86
1 changed files with 9 additions and 6 deletions

View File

@ -70,8 +70,9 @@ public final class BlobProxy implements Blob, BlobImplementer {
} }
private void setStreamMark() { private void setStreamMark() {
if ( binaryStream.getInputStream().markSupported() ) { final InputStream inputStream = binaryStream.getInputStream();
binaryStream.getInputStream().mark( markBytes ); if ( inputStream != null && inputStream.markSupported() ) {
inputStream.mark( markBytes );
resetAllowed = true; resetAllowed = true;
} }
else { else {
@ -92,14 +93,16 @@ public final class BlobProxy implements Blob, BlobImplementer {
private void resetIfNeeded() throws SQLException { private void resetIfNeeded() throws SQLException {
try { try {
if ( needsReset ) { if ( needsReset ) {
if ( !resetAllowed ) { final InputStream inputStream = binaryStream.getInputStream();
if ( !resetAllowed && inputStream != null) {
throw new SQLException( "Underlying stream does not allow reset" ); throw new SQLException( "Underlying stream does not allow reset" );
} }
if ( inputStream != null ) {
binaryStream.getInputStream().reset(); inputStream.reset();
setStreamMark(); setStreamMark();
} }
} }
}
catch ( IOException ioe) { catch ( IOException ioe) {
throw new SQLException("could not reset reader"); throw new SQLException("could not reset reader");
} }