Skip to content

Commit

Permalink
add info about exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
cleaning-agent committed Dec 5, 2023
1 parent 9247a8b commit 813b4ae
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ mdc(timeMachine, () -> {
log.info("another message without context");
```

you can also return values:
You can also return values:

```java
var currentTime = mdc(timeMachine, () -> {
Expand Down Expand Up @@ -316,10 +316,11 @@ mdc(TimeMachineKey.class, timeMachine, () -> {

You can also use try-with-resources to manage your MDC context if you prefer that or need to.

For example, the following code would ...
For example, the following code ...

1. ... not be possible with the callback API because `availableSeats` is not effectively final
1. ... be inconvenient, because there are multiple values in the MDC context, which would require nested callbacks
1. ... would not be possible with the callback API because `availableSeats` is not effectively final
1. ... would be inconvenient, because there are multiple values in the MDC context, which would require nested callbacks
1. ... may not be possible if `seat.isAvaliable()` can throw **multiple** checked Exceptions. The callback API works with one checked Exception, though.

```java
int availableSeats = 0;
Expand Down

0 comments on commit 813b4ae

Please sign in to comment.