File tree Expand file tree Collapse file tree 1 file changed +7
-0
lines changed
src/main/java/software/amazon/encryption/s3/internal Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Original file line number Diff line number Diff line change 1111import javax .crypto .Cipher ;
1212import java .nio .ByteBuffer ;
1313import java .security .GeneralSecurityException ;
14+ import java .util .concurrent .atomic .AtomicBoolean ;
1415import java .util .concurrent .atomic .AtomicLong ;
1516
1617public class CipherSubscriber implements Subscriber <ByteBuffer > {
@@ -20,6 +21,7 @@ public class CipherSubscriber implements Subscriber<ByteBuffer> {
2021 private final Long contentLength ;
2122 private boolean isLastPart ;
2223 private int tagLength ;
24+ private AtomicBoolean finalBytesCalled = new AtomicBoolean (false );
2325
2426 private byte [] outputBuffer ;
2527
@@ -139,6 +141,11 @@ public void onComplete() {
139141 }
140142
141143 public void finalBytes () {
144+ if (!finalBytesCalled .compareAndSet (false , true )) {
145+ // already called, don't repeat
146+ return ;
147+ }
148+
142149 // If this isn't the last part, skip doFinal and just send outputBuffer downstream.
143150 // doFinal requires that all parts have been processed to compute the tag,
144151 // so the tag will only be computed when the last part is processed.
You can’t perform that action at this time.
0 commit comments