2016-10-13

Java: PMD AvoidStringBufferField resolution

Inside an inherited code, I got a warning from PMD, stating
StringBuffers can grow quite a lot, and so may become a source of memory leak (if the owning class has a long life time).

StringBuffers/StringBuilders can grow considerably, and so may become a source of memory leaks if held within objects with long lifetimes.
So I went ahead and replaced the StringBuilder with a StringWriter. It even has the same append method signature for strings :D

No comments :

Post a Comment