RFR: 8364361: [process] java.lang.Process should implement close and be AutoCloseable [v4]

Roger Riggs rriggs at openjdk.org
Wed Aug 20 20:19:45 UTC 2025


On Tue, 19 Aug 2025 21:52:10 GMT, Archie Cobbs <acobbs at openjdk.org> wrote:

>> Roger Riggs has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Revisited handling of IOExceptions to throw instead of completely ignoring or logging.
>
> src/java.base/share/classes/java/lang/Process.java line 652:
> 
>> 650:      */
>> 651:     public void close() throws IOException {
>> 652:         synchronized(this) {
> 
> Might be safer to create a dedicated, private object to use for locking here instead of `this`. Otherwise there's a possibility of deadlock (or indefinite delay), for example, if a subclass happens to have a `synchronized` method that could block while trying to communicate with the process, etc.

There are other `synchronized(this)` within Process, its cleaner to stay consistent and update them later in a separate PR.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/26649#discussion_r2289204143


More information about the core-libs-dev mailing list