Java modern design patterns
Around Method Pattern
The try-with-resource
feature is useful but it’s quite easy to forget to wrap the resource as the compiler won’t tell you forgot to do it.
One solution is to use the Around Method Pattern
:
Instead of:
We can do: