Synchronized classes Vector, Hashtable, Stack and StringBuffer should not be used squid:S1149

Why is the use of StringBuffer object shown as a Code smell although i am running multiple threads and trying to access the object from different threads?

Hello @Prahaladh_Venkataram

I had a look at this rule, and stumble into your post. I know it’s an old one, but I believe the question is still relevant.

Indeed, the rule seems to blindly report any use of listed synchronized classes, without taking into account the context (if used in multiple threads or not). In fact, the problem is that it is impossible to know, I slightly changed the description of the rule, but I don’t see anything smarter to do here, do you?

Fortunately, reporting such usage in a synchronized context should be rare and even then, the warning could be correct since it seems that the synchronized is often badly used.

Therefore, only when the developers fully understand what he is actually using, he might consider resolving at won’t fix. In the case where the whole project is legitimately using it, one should consider disabling the rule.

If you have any other input on the subject, feel free to share them here.