[jboss-jira] [JBoss JIRA] Created: (JBCOMMON-117) Race-condition leads to IllegalStateException Cache list entries number (x) > than the maximum allowed (x-1)

Rico Neubauer (JIRA) jira-events at lists.jboss.org
Tue Dec 14 08:49:52 EST 2010


Race-condition leads to IllegalStateException Cache list entries number (x) > than the maximum allowed (x-1)
------------------------------------------------------------------------------------------------------------

                 Key: JBCOMMON-117
                 URL: https://issues.jboss.org/browse/JBCOMMON-117
             Project: JBoss Common
          Issue Type: Bug
      Security Level: Public (Everyone can see)
          Components: common-core (2.x)
    Affects Versions:  2.2.17.GA, 2.2.18.GA 
            Reporter: Rico Neubauer
         Attachments: JBCOMMON-117.diff

org.jboss.util.LRUCachePolicy takes care of a cache with a maxCapacity. Unfortunately the modifications of the count of entries is not thread-safe and might lead to the situation that the cache holds more than maxCapacity entries. This can only be seen rarely under heavy load on SMP machines; so far the count reached at most maxCapacity+1, but it's imaginable it could go beyond.
One possibility is to fix the modifications of count, which should preferably NOT introduce synchronizations.
Another simpler approach is to not throw the exception in case of the cache already having crossed the limit (which itself does not error-out), but behave nicely, since there are no real implications and the limit is not considered to be needed that strict imho.
I will attach a proposed patch, showing the problem and using the latter option to fix it.

-- 
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the jboss-jira mailing list