Skip to content

removalListener not getting invoked #650

Answered by ben-manes
manishkrishan asked this question in Q&A
Discussion options

You must be logged in to vote

By default the cache defers to an executor for non-critical path logic, like notifying the removal listener, since we don't know how expensive that work is and do not want to impact the caller if it would increase user-facing latencies. Most likely your test is completing before the ForkJoinPool.commonPool() executes the work. You can use Caffeine.executor(Runnable::run) to disable this behavior (as the cache's own logic is fast) or wait for the work to finish (e.g. using Awaitility).

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by ben-manes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants