Skip to content
Discussion options

You must be logged in to vote

It looks like the cache computes a shared value and the dependent actions need to be contextual. This is where the bug lies.

// user A — triggers the loader
Thread.ofPlatform().name("userA").start(() -> {
    ThreadLocalWrapper.setValue(USER_A_VALUE);
    cache.get("shared-key")
            .thenRun(() -> {
                observeThreadLocalValue("User A", USER_A_VALUE, valueObservedOnUserAThread, doneLatch);
            });
});

loadStarted.await(10, TimeUnit.SECONDS);

// user B — coalesced onto the future from user A
Thread.ofPlatform().name("userB").start(() -> {
    ThreadLocalWrapper.setValue(USER_B_VALUE);
    cache.get("shared-key")
            .thenRun(() -> {
                obs…

Replies: 3 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by ben-manes
Comment options

You must be logged in to vote
1 reply
@ben-manes
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants