Skip to content

Commit

Permalink
Fix S3ChannelContext.FragmentState#cancelAndRelease (#5095)
Browse files Browse the repository at this point in the history
  • Loading branch information
devinrsmith authored Feb 1, 2024
1 parent b0dabbf commit 1c1aa7e
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,20 @@ private boolean matches(final long fragmentIndex) {
}

private void cancelAndRelease() {
try (final SafeCloseable ignored = () -> SafeCloseable.closeAll(
future == null ? null : () -> future.cancel(true), bufferRelease)) {
try (
final SafeCloseable ignored1 = cancelOnClose(future, true);
final SafeCloseable ignored2 = bufferRelease) {
fragmentIndex = UNINITIALIZED_FRAGMENT_INDEX;
future = null;
bufferRelease = null;
}
}

// do not inline, needs to capture future at time of method call
private static SafeCloseable cancelOnClose(Future<?> future, boolean mayInterruptIfRunning) {
return future == null ? null : () -> future.cancel(mayInterruptIfRunning);
}

private void set(
final long fragmentIndex,
@NotNull final Future<ByteBuffer> future,
Expand Down

0 comments on commit 1c1aa7e

Please sign in to comment.