This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 178320

Summary: Warn about logging code where closure of toString() calls synchronized methods
Product: java Reporter: _ tboudreau <tboudreau>
Component: HintsAssignee: Svata Dedic <sdedic>
Status: NEW ---    
Severity: normal    
Priority: P3    
Version: 6.x   
Hardware: PC   
OS: Mac OS X   
Issue Type: ENHANCEMENT Exception Reporter:

Description _ tboudreau 2009-12-08 12:52:39 UTC
After experiencing issue 178013 (really the fault of the default JDK file logger, but it is what the JDK gives you by default), I am thinking maybe logging code that looks like 
log("foo" + this)
is an anti-pattern.

Even if it cannot deadlock, you don't really want logging code to make an application less live - i.e. if logging code will acquire locks, it will interfere with the performance of other threads which would also use the lock.

Seems like a hint for this would be useful.
Comment 1 _ tboudreau 2010-01-15 09:54:04 UTC
Meant to say the anti-pattern is
logger.log(Level.WHATEVER, "Foo {0}", someObject)
where the closure of someObject.toString() calls a synchronized method.

Requires a lot of analysis, unless we somehow cache this data, but it is something that can be a real problem.