Skip to content

Fixed an issue in S3 Transfer Manager where a thread could get stuck … #3852

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ private void handleOnNext(T item) {
log.debug(() -> "Delivering next item, numRequestInFlight=" + numberOfRequestInFlight);

consumer.apply(item).whenComplete((r, t) -> {
log.trace(() -> "Finished delivering, decrementing numRequestsInFlight, numRequestsInFlight=" + numberOfRequestInFlight);
numRequestsInFlight.decrementAndGet();
if (!isStreamingDone) {
subscription.request(1);
Expand Down Expand Up @@ -145,9 +146,9 @@ private void handleError(Throwable t) {

@Override
public void onComplete() {
log.debug(() -> "Received onComplete");
isStreamingDone = true;
storingSubscriber.onComplete();
flushBufferIfNeeded();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class AsyncBufferingSubscriberTest {
private CompletableFuture<Void> returnFuture;
private final List<CompletableFuture<Void>> futures = new ArrayList<>();
private static ScheduledExecutorService scheduledExecutorService;
private static final int MAX_NUM = 123;

@BeforeAll
public static void setUp() {
Expand All @@ -54,7 +55,7 @@ public static void setUp() {
@BeforeEach
public void setUpPerTest() {
returnFuture = new CompletableFuture<>();
for (int i = 0; i < 101; i++) {
for (int i = 0; i < MAX_NUM + 1; i++) {
futures.add(new CompletableFuture<>());
}
Iterator<CompletableFuture<Void>> iterator = futures.iterator();
Expand All @@ -76,16 +77,16 @@ public static void cleanUp() {
}

@ParameterizedTest
@ValueSource(ints = {1, 4, 11, 20, 100})
@ValueSource(ints = {1, 4, 11, 20, 100, MAX_NUM})
void differentNumberOfStrings_shouldCompleteSuccessfully(int numberOfStrings) throws Exception {
Flowable.fromArray(IntStream.range(0, numberOfStrings).mapToObj(String::valueOf).toArray(String[]::new)).subscribe(subscriber);


List<Integer> numRequestsInFlightSampling = new ArrayList<>();

Disposable disposable = Observable.interval(100, TimeUnit.MILLISECONDS, Schedulers.newThread())
.map(time -> subscriber.numRequestsInFlight())
.subscribe(numRequestsInFlightSampling::add, t -> {});
.map(time -> subscriber.numRequestsInFlight())
.subscribe(numRequestsInFlightSampling::add, t -> {
});

returnFuture.get(1000, TimeUnit.SECONDS);
assertThat(returnFuture).isCompleted().isNotCompletedExceptionally();
Expand Down