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() {
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,14 +93,16 @@ 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();
if ( inputStream != null ) {
inputStream.reset();
setStreamMark();
}
}
}
catch ( IOException ioe) {
throw new SQLException("could not reset reader");
}