RFR: 8373628: jpackage doesn't print to console until completetion

Alexey Semenyuk asemenyuk at openjdk.org
Sat Dec 13 01:51:50 UTC 2025


On Sat, 13 Dec 2025 01:04:52 GMT, Alexander Matveev <almatvee at openjdk.org> wrote:

>> Make jpackage ToolProvider implementation implement `ToolProvider#run(PrintStream, PrintStream, String)` method such that it passes `PrintWriter` objects with auto-flush enabled into `ToolProvider#run(PrintWriter, PrintWriter, String)` call.
>
> src/jdk.jpackage/share/classes/jdk/jpackage/internal/cli/Main.java line 74:
> 
>> 72:             PrintWriter outWriter = new PrintWriter(out, true);
>> 73:             PrintWriter errWriter = new PrintWriter(err, true);
>> 74:             try {
> 
> Looks good, but why we need two `try` blocks?

To guarantee that both `PrintWriter`-s will be flushed. If we do

try {
    return run(...);
} finally {
    outWriter.flush();
    errWriter.flush();
}


`errWriter.flush()` will not be called if `outWriter.flush()` throws.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/28807#discussion_r2615976964


More information about the core-libs-dev mailing list