Search code examples
stringbuilderfindbugspmdstringbuffer

Findbugs or PMD rule to detect when StringBuffer should be replaced with StringBuilder


Is there a rule in FindBugs or PMD that will warn when StringBuffer, which is synchronized, can be safely replaced with StringBuilder?

For example when a StringBuffer variable reference never escapes (to another Thread) from a method it would be possible to safely replace it with StringBuilder.


Solution

  • http://fb-contrib.sf.net has one, called LocalSynchronizedCollections

    this is a plugin for findbugs.