RFR: 8349206: j.u.l.Handler classes create deadlock risk via synchronized publish() method [v2]

Daniel Fuchs dfuchs at openjdk.org
Fri Feb 14 16:48:21 UTC 2025


On Fri, 14 Feb 2025 16:32:08 GMT, David Beaumont <duke at openjdk.org> wrote:

>> src/java.logging/share/classes/java/util/logging/FileHandler.java line 193:
>> 
>>> 191:             out.write(b);
>>> 192:             written++;
>>> 193:             flushOrRotateIfFull();
>> 
>> I don't think that's correct. You don't want to flush and rotate in the middle of publishing a LogRecord. You want to flush and rotate either before or after - but not in the middle.
>
> See the comment above about how the only calls to "write()" occur for a complete log entry. This is something we can control in StreamHandler (I'm happy to add a test to verify this if you want though - I'm writing a new StreamHandler test at the moment).

This sounds fragile to me. I'd rather use a package private method called within the lock to signal that a record has been written.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/23491#discussion_r1956440843


More information about the core-libs-dev mailing list