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 - Warn about logging code where closure of toString() calls synchronized methods
Summary: Warn about logging code where closure of toString() calls synchronized methods
Status: NEW
Alias: None
Product: java
Classification: Unclassified
Component: Hints (show other bugs)
Version: 6.x
Hardware: PC Mac OS X
: P3 normal (vote)
Assignee: Svata Dedic
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-12-08 12:52 UTC by _ tboudreau
Modified: 2013-09-02 14:22 UTC (History)
0 users

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.