RFR: 8364361: [process] java.lang.Process should implement close and be AutoCloseable
Archie Cobbs
acobbs at openjdk.org
Tue Aug 5 20:32:02 UTC 2025
On Tue, 5 Aug 2025 19:57:53 GMT, Roger Riggs <rriggs at openjdk.org> wrote:
> Regardless of an interrupt, the process is destroyed, so there is no use to propagate the interrupt.
While it's true that it doesn't matter if the purpose of the interruption was only to interrupt the `close()` invocation, couldn't this `close()` operation be one of several different "shutdown" actions the thread is taking, some of which do throw `InterruptedException`, in which the purpose of the interruption is to interrupt any or all of them? In that case, you'd want the interrupt to "hang around" so it can happen if/when the next interruptible operation occurs.
In the example below, if the interruption just happens to occur during `Process.close()`, you want an `InterruptedException` to be thrown by `thing3.shutdown()` immediately (or as soon as possible):
try {
thing1.shutdown(); // throws InterruptedException
process2.close(); // does not throw InterruptedException
thing3.shutdown(); // throws InterruptedException
} catch (InterruptedException e) {
// bail out now
}
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/26649#discussion_r2255274208
More information about the core-libs-dev
mailing list