[concurrency-interest] New bug pattern, way to common

David J. Biesack David.Biesack at sas.com
Tue Mar 18 13:24:57 EDT 2008

> Date: Fri, 14 Mar 2008 15:28:30 -0400
> From: Bill Pugh <pugh at cs.umd.edu>
> Subject: [concurrency-interest] New bug pattern, way to common
> I identified a new concurrency bug pattern that is way too common:
> Synchronizing on a field in order to prevent concurrent access to that  
> field.
>       synchronized (listeners) {
>           ...
>           listeners = results;
>       }


Since you said

> There are 26 occurrences of this pattern in apache-tomcat.

I assumed FindBugs found these 26 occurrences.

However, when I tried it, this code is not flagged by FindBugs (1.3.2) as a ML_SYNC_ON_UPDATED_FIELD


  "ML: Method synchronizes on an updated field (ML_SYNC_ON_UPDATED_FIELD)

   This method synchronizes on an object references from a mutable field.
   This is unlikely to have useful semantics, since different threads
   may be synchronizing on different objects."

(it's entirely possible I've not configured FindBugs correctly...)

David J. Biesack     SAS Institute Inc.
(919) 531-7771       SAS Campus Drive
http://www.sas.com   Cary, NC 27513

More information about the Concurrency-interest mailing list