RFR: 8303198: System and Runtime.exit() resilience to logging errors
Roger Riggs
rriggs at openjdk.org
Mon Feb 27 16:08:16 UTC 2023
On Mon, 27 Feb 2023 15:58:33 GMT, Alan Bateman <alanb at openjdk.org> wrote:
>> Consolidate logging and handle exceptions by printing to standard error and ignoring the exception.
>> Exceptions while logging will not interfere with Runtime.exit.
>
> src/java.base/share/classes/java/lang/Shutdown.java line 189:
>
>> 187: } catch (Throwable throwable2) {
>> 188: // Ignore
>> 189: }
>
> The update means that several threads racing to exit may result in more than one message being logged. I don't think that's a big issue but just wanted to make sure that this was deliberate.
Yes, its racy, and intentional, but from a diagnostic view, the developer should know that multiple callers were trying to exit. All but one will hang.
Consolidating the code in a single method is cleaner and with fewer interactions between separate code blocks.
-------------
PR: https://git.openjdk.org/jdk/pull/12770
More information about the core-libs-dev
mailing list