Skip to content

Commit e05b523

Browse files
author
Lucas McDonald
committed
m
1 parent caeac1d commit e05b523

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/main/java/software/amazon/encryption/s3/internal/CipherSubscriber.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,8 @@ public void onNext(ByteBuffer byteBuffer) {
4747
byte[] buf = BinaryUtils.copyBytesFrom(byteBuffer, amountToReadFromByteBuffer);
4848
outputBuffer = cipher.update(buf, 0, amountToReadFromByteBuffer);
4949
if (outputBuffer == null || outputBuffer.length == 0) {
50-
// No bytes provided from upstream; just return.
51-
// No need to emit empty bytes to downstream; this can be misinterpreted.
52-
return;
50+
// No bytes provided from upstream; to avoid blocking, send an empty buffer to the wrapped subscriber.
51+
wrappedSubscriber.onNext(ByteBuffer.allocate(0));
5352
} else {
5453
boolean atEnd = isLastPart && contentRead.get() + amountToReadFromByteBuffer >= contentLength;
5554

@@ -80,6 +79,9 @@ public void onNext(ByteBuffer byteBuffer) {
8079
wrappedSubscriber.onNext(ByteBuffer.wrap(outputBuffer));
8180
}
8281
}
82+
} else {
83+
// Do nothing
84+
wrappedSubscriber.onNext(byteBuffer);
8385
}
8486
}
8587

0 commit comments

Comments
 (0)