Skip to content

Commit

Permalink
HHH-14725 Fix reset handling on BlobProxy
Browse files Browse the repository at this point in the history
  • Loading branch information
dreab8 authored and beikov committed Dec 18, 2024
1 parent 0b28e2c commit 0b61cc3
Showing 1 changed file with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public final class BlobProxy implements Blob, BlobImplementer {
* @see #generateProxy(byte[])
*/
private BlobProxy(byte[] bytes) {
binaryStream = new ArrayBackedBinaryStream( bytes );
binaryStream = new BinaryStreamImpl(bytes);
markBytes = bytes.length + 1;
setStreamMark();
}
Expand All @@ -68,8 +68,9 @@ private BlobProxy(InputStream stream, long length) {
}

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 {
Expand All @@ -89,12 +90,14 @@ public BinaryStream getUnderlyingStream() throws SQLException {
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) {
Expand Down

0 comments on commit 0b61cc3

Please # to comment.