Skip to content

Commit 135651d

Browse files
committed
Merge pull request #1387 from michael-simons:SPR-15449
* pr/1387: Polish "Improve unless condition in caching doc" Improve unless condition in caching doc
2 parents 37d0db1 + 7084bc2 commit 135651d

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/docs/asciidoc/integration.adoc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8327,11 +8327,12 @@ supported wrapper so the previous example can be rewritten as follows:
83278327
[source,java,indent=0]
83288328
[subs="verbatim,quotes"]
83298329
----
8330-
@Cacheable(cacheNames="book", condition="#name.length() < 32", **unless="#result.hardback"**)
8330+
@Cacheable(cacheNames="book", condition="#name.length() < 32", **unless="#result?.hardback"**)
83318331
public Optional<Book> findBook(String name)
83328332
----
83338333

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.
83358336

83368337
[[cache-spel-context]]
83378338
===== Available caching SpEL evaluation context

0 commit comments

Comments
 (0)