RFR: 8349206: j.u.l.Handler classes create deadlock risk via synchronized publish() method [v6]
David Beaumont
duke at openjdk.org
Tue Feb 25 11:18:54 UTC 2025
On Tue, 25 Feb 2025 01:17:21 GMT, Stuart Marks <smarks at openjdk.org> wrote:
>> David Beaumont has updated the pull request incrementally with one additional commit since the last revision:
>>
>> Tweaking @implNote for better rendering.
>
> src/java.logging/share/classes/java/util/logging/Handler.java line 80:
>
>> 78: * {@link FileHandler} or {@link Formatter} then, in order to have complete
>> 79: * control of synchronization, it is recommended to subclass {@code Handler}
>> 80: * directly.
>
> The discussion here belongs on StreamHandler.publish(), because its implementation does lock on the StreamHandler instance itself. As such there isn't any other discussion of locking in the specs for this class, so it seems kind of misplaced.
Yeah, it's difficult to know where this should go, because while `StreamHandler` is the only important case in the JDK which suffer(s/ed) from this, if you look through github, I'd say the majority of publish() methods are (erroneously) synchronized. That's why I hoisted the docs here, because it's something I want people to see when they consider writing or modifying their own subclasses. The mentions of StreamHandler, FileHandler et al are just the examples we can point at, but the warning is meant to be general, and I personally think it fits better in the class which defines the publish() method.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/23491#discussion_r1969562270
More information about the core-libs-dev
mailing list