RFR: 8303392: Runtime.exec and ProcessBuilder.start should use System logger [v2]
Roger Riggs
rriggs at openjdk.org
Mon Mar 6 16:39:06 UTC 2023
On Mon, 6 Mar 2023 12:44:57 GMT, Daniel Fuchs <dfuchs at openjdk.org> wrote:
>> 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`?
Since adding logging injects additional code during start(), the idea was to handle exceptions to avoid breaking existing code.
And since the logger is cached during the static initialization of the ProcessBuilder class, a mis-configured logger would cause ExceptionInInitializer, exposing the cause early, though in a pretty ugly way. I may need to reconsider that.
-------------
PR: https://git.openjdk.org/jdk/pull/12862
More information about the core-libs-dev
mailing list