Commit 087f2c4
Improve exception handling in
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: 805944057cache.asMap().computeIfAbsent etc.1 parent 233d873 commit 087f2c4
File tree
2 files changed
+5
-9
lines changed- guava-tests/test/com/google/common/cache
- guava/src/com/google/common/cache
2 files changed
+5
-9
lines changedLines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
139 | 139 | | |
140 | 140 | | |
141 | 141 | | |
142 | | - | |
| 142 | + | |
143 | 143 | | |
144 | 144 | | |
145 | 145 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2259 | 2259 | | |
2260 | 2260 | | |
2261 | 2261 | | |
| 2262 | + | |
| 2263 | + | |
| 2264 | + | |
2262 | 2265 | | |
2263 | 2266 | | |
2264 | 2267 | | |
| |||
2268 | 2271 | | |
2269 | 2272 | | |
2270 | 2273 | | |
2271 | | - | |
2272 | 2274 | | |
2273 | 2275 | | |
2274 | 2276 | | |
| |||
3585 | 3587 | | |
3586 | 3588 | | |
3587 | 3589 | | |
3588 | | - | |
3589 | | - | |
3590 | | - | |
3591 | | - | |
3592 | | - | |
3593 | | - | |
3594 | | - | |
| 3590 | + | |
3595 | 3591 | | |
3596 | 3592 | | |
3597 | 3593 | | |
| |||
0 commit comments