Skip to content
This repository has been archived by the owner on Nov 14, 2024. It is now read-only.

Fix coalescing supplier #4541

Merged
merged 6 commits into from
Jan 28, 2020
Merged

Fix coalescing supplier #4541

merged 6 commits into from
Jan 28, 2020

Conversation

j-baker
Copy link
Contributor

@j-baker j-baker commented Jan 28, 2020

Let's just take out a lock - and write a test that covers it. It's more
obviously correct.

Let's just take out a lock - and write a test that covers it. It's more
obviously correct.
@changelog-app
Copy link

changelog-app bot commented Jan 28, 2020

Generate changelog in changelog/@unreleased

Type

  • Feature
  • Improvement
  • Fix
  • Break
  • Deprecation
  • Manual task
  • Migration

Description

Fix coalescing supplier race condition

Check the box to generate changelog(s)

  • Generate changelog entry

future.complete(delegate.get());
} catch (Throwable t) {
future.completeExceptionally(t);
synchronized (lock) {
Copy link
Contributor Author

@j-baker j-baker Jan 28, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is an uncontended lock except in the case of the bug.

@j-baker j-baker force-pushed the jbaker/coalescing_supplier_fix branch from e96a501 to d9ae980 Compare January 28, 2020 10:48
Copy link
Contributor

@jeremyk-91 jeremyk-91 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change is correct, but should have a changelog explaining how the old one would fail. Thanks!

Whoops, I need to validate the SettableFuture part that just came out

Copy link
Contributor

@gmaretic gmaretic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implementation looks good, and the test is legit!

return counter.incrementAndGet();
});
List<ListenableFuture<?>> futures = IntStream.range(0, poolSize)
.mapToObj(index -> executorService.submit(() -> assertIncreasing(supplier)))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is neat!

@j-baker j-baker merged commit 56878fa into develop Jan 28, 2020
@delete-merged-branch delete-merged-branch bot deleted the jbaker/coalescing_supplier_fix branch January 28, 2020 11:43
@svc-autorelease
Copy link
Collaborator

Released 0.185.3

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants