https://issues.apache.org/bugzilla/show_bug.cgi?id=49778

           Summary: Inconsistent synchronization in SimplePool.java
           Product: Tomcat 6
           Version: 6.0.18
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: major
          Priority: P2
         Component: Catalina
        AssignedTo: dev@tomcat.apache.org
        ReportedBy: fsl...@gmail.com


In class org.apache.tomcat.util.collections.SimplePool, current is a mutable
field. In method put/get, current field is updated with a lock held. But in
method getCount(), the access to current field is not protected by a lock. 

In current Java memory model, the up-to-date current field value is not
guaranteed to be seen in the absence of synchronization. So getCount() method
can return a stale or inconsistent value, which results in undesired behavior.

Proposed solution:

public int getCount() {
  int ret = 0;
  synchronized (lock) {
    ret = current+1;
  }
  return ret;
}

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to