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

Jason Mehrens duke at openjdk.org
Sun Mar 2 03:22:56 UTC 2025


On Fri, 28 Feb 2025 12:29:04 GMT, David Beaumont <duke at openjdk.org> wrote:

>The former is, in my opinion, a pretty awful user experience...

Specifically, I'm referring to this, with awareness of the above described limitations:

//String.format is var-arg
logger.log(Level.SEVERE, () -> { return String.format("foo=%s bar=%s", arg1, arg2); });

//logger is not var-arg     
if (logger.isLoggable(lvl)) { //if arg1 and arg2 known to be never null
    logger.log(lvl, "foo={0} bar={1}", new Object[]{arg1.toString(), arg2.toString()});
}
         
//logger is not var-arg
if (logger.isLoggable(lvl)) { //if arg1 and arg2 are nullable
    logger.log(lvl, "foo={0} bar={1}", new Object[]{Objects.toString(arg1), Objects.toString(arg2)});
}


How did you worked around this deadlock issue prior to this patch?  That would be awesome information to add to the JIRA ticket for those that would like this patch but are unable to upgrade.

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

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


More information about the core-libs-dev mailing list