[External] : Re: A new build and a new structured concurrency API
Kasper Nielsen
kasperni at gmail.com
Tue Nov 16 14:33:58 UTC 2021
>
>
> If the language is changed to make AutoCloseable more flexible, this
> requirement
> might be removed.
>
> — Ron
Adding something like
default close(Throwable cause) {
close();
}
to AutoClosable would also be beneficial for people working with
databases. Right now a lot of transactional code looks like this:
try (Transaction transaction = Transaction.start()) {
... do transactional work
transaction.commit();
} catch (Throwable e) {
transaction.rollback();
}
Which could be reduced to
try (Transaction transaction = Transaction.start()) {
... do transactional work
}
If the Transaction instance could be notified that it was closed
exceptionally.
/Kasper
More information about the loom-dev
mailing list