RFR: 8314755: Resource leak: SwingWorker listener keeps strong reference to executor [v4]

Alexey Ivanov aivanov at openjdk.org
Mon Oct 2 18:52:19 UTC 2023


On Tue, 12 Sep 2023 12:34:12 GMT, Christopher Sahnwaldt <duke at openjdk.org> wrote:

>> In https://github.com/openjdk/jdk/commit/b8af3d50192f8bc98d83f8102f0fd1989f302e32 the weak reference was accidentally changed from a field to a local variable, which means that the PropertyChangeListener keeps a strong reference to executorService, which is a resource leak
>
> Christopher Sahnwaldt has updated the pull request incrementally with one additional commit since the last revision:
> 
>   SwingWorkerExecutorLeakTest.java: use AppContext.getAppContext() instead of SunToolkit.createNewAppContext() to create AppContext, set necessary system properties

> Maybe this issue is a non-issue. Someone who knows how `AppContext` is currently used should check.
> 
> I just found [this comment](https://bugs.openjdk.org/browse/JDK-8289616?focusedCommentId=14516108#comment-14516108) by @prrace: "AppContext.dispose() is no longer called from anywhere in JDK code." So as I explained in my previous comment, this is a non-issue. I'll close it.

Likely, it's not an issue any more. `AppContext` was used to isolate different applets which run in the same JVM as well as to isolate the deployment stack (Java Console as an example) from applets and Java Web Start apps.

As the comment you linked to explains, there should never be more than one `AppContext` and its `dispose()` method is never called.

> I guess such a situation only occurs if an application starts a GUI, later shuts down the GUI, but keeps the JVM running. Should be pretty rare.

I think so. GUI application usually has its GUI throughout its entire lifespan.

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

PR Comment: https://git.openjdk.org/jdk/pull/15081#issuecomment-1743576856


More information about the client-libs-dev mailing list