RFR: 8303392: Runtime.exec and ProcessBuilder.start should use System logger [v2]
Daniel Fuchs
dfuchs at openjdk.org
Mon Mar 6 12:48:13 UTC 2023
On Sat, 4 Mar 2023 14:22:33 GMT, Roger Riggs <rriggs at openjdk.org> wrote:
>> Runtime.exec and ProcessBuilder.start methods create a new operating system process with the program and arguments. Many applications configure a logging subsystem to monitor application events. Logging a process start message with the program, arguments, and stack trace can identify the caller and purpose.
>> Logging the process start event is complementary to the process start event generated for JFR (Java Flight Recorder).
>
> Roger Riggs has updated the pull request incrementally with one additional commit since the last revision:
>
> Add javadoc @implNote to Runtime.exec and ProcessBuilder methods
src/java.base/share/classes/java/lang/ProcessBuilder.java line 1148:
> 1146: ", pid: " + process.pid());
> 1147: } catch (Throwable thEx) {/* ignore */}
> 1148: }
Is it really useful to try & catch a potential exception here, or wouldn't be better to let it propagate to the caller? An exception here would indicate a bug somewhere either in the logging backend or in the logging configuration - or possibly OOM or any other kind of VM error and maybe it would be better to just fail in that case, and let the VM exit (unless that exception is caught down the road by the caller?)
I understand why we would not want an exception in logging to prevent System.exit() from exiting, but surely the same constraint doesn't hold for `ProcessBuilder::start`?
-------------
PR: https://git.openjdk.org/jdk/pull/12862
More information about the core-libs-dev
mailing list