RFR: 8319928: Exceptions thrown by cleanup actions passed to reinterpreted segments should be ignored
Maurizio Cimadamore
mcimadamore at openjdk.org
Mon Nov 13 11:10:57 UTC 2023
On Mon, 13 Nov 2023 08:35:21 GMT, Jorn Vernee <jvernee at openjdk.org> wrote:
> Not sure whether always swallowing the exceptions is the right move... it seems like an advantage that explicit arenas _can_ report exceptions thrown by cleanup actions. Silently ignoring exceptions seems bad, but something that is forced when using a Cleaner. I don't think we should extend that bad behavior to all arenas.
>
> I do think it is problematic that we bail out of the cleanup loop on the first exception, but I suggest solving this by catching the exceptions/Throwables thrown by individual cleanup actions, and then only propagating them at the end of the cleanup loop. (where, if there are multiple exceptions we can use `addSuppressed`).
The problem with this approach is that if we do this we would need either:
* `close` to throw `Throwable`, since *anything goes*
* `close` to throw some runtime exception wrapper (either existing, or a new type defined by us) which wraps whatever exception is thrown by the cleanup action
IMHO, neither approach is too compelling, given that neither would work with implicit arenas. While swallowing exceptions is never ideal, I think having uniform behavior across all arena kinds is important, and, let's also not forget that attaching custom cleanup actions is a rather advanced operation, so asking developers to use that with caution seems an ok move (even if not a perfect one, but no perfect move exists here).
-------------
PR Comment: https://git.openjdk.org/jdk/pull/16619#issuecomment-1807950255
More information about the core-libs-dev
mailing list