Skip to content

Conversation

copybara-service[bot]
Copy link
Contributor

@copybara-service copybara-service bot commented Sep 11, 2025

Improve exception handling in cache.asMap().computeIfAbsent etc.

Don't store an exception thrown by the compute function. It doesn't appear that the stored exception is ever used. Tests still pass after this deletion.

Also move the evaluation of the compute function to before the possible creation of a new entry, so if it throws an exception then no entry is created.

Fixes #5438, fixes #7625, fixes #7975.

RELNOTES=Handling of exceptions from compute functions in Cache.asMap().computeIfAbsent and the like has been improved. (We do still recommend using Caffeine rather than com.google.common.cache.)

@copybara-service copybara-service bot changed the title Don't store an exception thrown in computeIfAbsent etc. Improve exception handling in cache.asMap().computeIfAbsent etc. Sep 11, 2025
@copybara-service copybara-service bot force-pushed the test_805040984 branch 3 times, most recently from a54e525 to 2e8ddce Compare September 11, 2025 19:10
Don't store an exception thrown by the compute function. It doesn't appear that the stored exception is ever used. Tests still pass after this deletion.

Also move the evaluation of the compute function to before the possible creation of a new entry, so if it throws an exception then no entry is created.

Fixes #5438, fixes #7625, fixes #7975.

RELNOTES=Handling of exceptions from compute functions in `Cache.asMap().computeIfAbsent` and the like has been improved. (We do still recommend using Caffeine rather than `com.google.common.cache`.)
PiperOrigin-RevId: 805944057
@copybara-service copybara-service bot merged commit 087f2c4 into master Sep 11, 2025
1 check passed
@copybara-service copybara-service bot deleted the test_805040984 branch September 11, 2025 19:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant