RFR: 8364361: [process] java.lang.Process should implement Closeable [v18]
Roger Riggs
rriggs at openjdk.org
Fri Oct 24 18:07:41 UTC 2025
On Fri, 24 Oct 2025 04:33:53 GMT, Joe Darcy <darcy at openjdk.org> wrote:
>> Roger Riggs has updated the pull request incrementally with one additional commit since the last revision:
>>
>> Adopt review suggestions for javadoc wording.
>> Refactor the utility method to wait for the process, return true on termination, false on interrupt.
>> Various updates to the test related to logging of output when a test fails.
>
> src/java.base/share/classes/java/lang/Process.java line 264:
>
>> 262: c.close();
>> 263: return firstIOE;
>> 264: } catch (IOException ioe) {
>
> What is the expected outcome if the close method misbehaves and throws a runtime exception or error instead of IOException?
To avoid interrupting the closing of streams, quietClose should catch all Exceptions and add them as suppressed exceptions. If there is no first IOException, a new IOException is created. This catch all behavior is similar to the handling of try-with-resources except that TWR catches Throwables. Catching and suppressing Errors would hide fatal errors that could be handled elsewhere.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/26649#discussion_r2461452539
More information about the core-libs-dev
mailing list