jpackage AsyncTest test [1] revealed that if multiple jpackage tool providers are executed concurrently, they may share the same logging config and output streams. This is due to the implementation of the Log class, which uses an inheritable thread-local variable to store the logging config [2]. This is inherently wrong. Each jpackage tool provider instance must have its own logging config Log.Logger object.
Currently, two jpackage tool provider instances will share the same Log.Logger object in the following configuration:
1. Create jpackage tool provider instance.
2. Start a thread and create another jpackage tool provider instance in the started thread.
It is with virtual threads and pooled executors, as they make things unpredictable. You may create one instance of jpackage tool provider in a virtual thread or a native thread of a pooled executor, and all subsequently created jpackage tool provider instances may share the same Log.Logger object.
[1] https://github.com/openjdk/jdk/blob/d433ce52360994be5a88a0bcbf39cbb741b435ec/test/jdk/tools/jpackage/share/AsyncTest.java
[2] https://github.com/openjdk/jdk/blob/d433ce52360994be5a88a0bcbf39cbb741b435ec/src/jdk.jpackage/share/classes/jdk/jpackage/internal/Log.java#L114
Currently, two jpackage tool provider instances will share the same Log.Logger object in the following configuration:
1. Create jpackage tool provider instance.
2. Start a thread and create another jpackage tool provider instance in the started thread.
It is with virtual threads and pooled executors, as they make things unpredictable. You may create one instance of jpackage tool provider in a virtual thread or a native thread of a pooled executor, and all subsequently created jpackage tool provider instances may share the same Log.Logger object.
[1] https://github.com/openjdk/jdk/blob/d433ce52360994be5a88a0bcbf39cbb741b435ec/test/jdk/tools/jpackage/share/AsyncTest.java
[2] https://github.com/openjdk/jdk/blob/d433ce52360994be5a88a0bcbf39cbb741b435ec/src/jdk.jpackage/share/classes/jdk/jpackage/internal/Log.java#L114
- links to
-
Commit(master)
openjdk/jdk/9ed0ecbc
-
Review(master)
openjdk/jdk/29175