File tree Expand file tree Collapse file tree 1 file changed +3
-2
lines changed Expand file tree Collapse file tree 1 file changed +3
-2
lines changed Original file line number Diff line number Diff line change @@ -8327,11 +8327,12 @@ supported wrapper so the previous example can be rewritten as follows:
8327
8327
[source,java,indent=0]
8328
8328
[subs="verbatim,quotes"]
8329
8329
----
8330
- @Cacheable(cacheNames="book", condition="#name.length() < 32", **unless="#result.hardback"**)
8330
+ @Cacheable(cacheNames="book", condition="#name.length() < 32", **unless="#result? .hardback"**)
8331
8331
public Optional<Book> findBook(String name)
8332
8332
----
8333
8333
8334
- Note that `result` still refers to `Book` and not `Optional`.
8334
+ Note that `result` still refers to `Book` and not `Optional`. As it might be `null`, we
8335
+ should use the safe navigation operator.
8335
8336
8336
8337
[[cache-spel-context]]
8337
8338
===== Available caching SpEL evaluation context
You can’t perform that action at this time.
0 commit comments