Return-Path: Delivered-To: apmail-directory-dev-archive@www.apache.org Received: (qmail 65661 invoked from network); 20 Nov 2005 22:45:49 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 20 Nov 2005 22:45:49 -0000 Received: (qmail 71225 invoked by uid 500); 20 Nov 2005 22:45:47 -0000 Delivered-To: apmail-directory-dev-archive@directory.apache.org Received: (qmail 71185 invoked by uid 500); 20 Nov 2005 22:45:47 -0000 Mailing-List: contact dev-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Apache Directory Developers List" Delivered-To: mailing list dev@directory.apache.org Received: (qmail 71168 invoked by uid 99); 20 Nov 2005 22:45:47 -0000 X-ASF-Spam-Status: No, hits=1.3 required=10.0 tests=SPF_FAIL X-Spam-Check-By: apache.org Received: from [192.87.106.226] (HELO ajax.apache.org) (192.87.106.226) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 20 Nov 2005 14:45:46 -0800 Received: from ajax.apache.org (ajax.apache.org [127.0.0.1]) by ajax.apache.org (Postfix) with ESMTP id C132A239 for ; Sun, 20 Nov 2005 23:45:25 +0100 (CET) Message-ID: <583643014.1132526725789.JavaMail.jira@ajax.apache.org> Date: Sun, 20 Nov 2005 23:45:25 +0100 (CET) From: "Emmanuel Lecharny (JIRA)" To: dev@directory.apache.org Subject: [jira] Commented: (DIRLDAP-71) CachingNormalizer exhibits concurrency flaw under load. In-Reply-To: <1116515560.1131749762892.JavaMail.jira@ajax.apache.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N [ http://issues.apache.org/jira/browse/DIRLDAP-71?page=comments#action_12358107 ] Emmanuel Lecharny commented on DIRLDAP-71: ------------------------------------------ It seems that there is a double flaw in this piece of code : 1) The cache.get( value ) does a cache.containsKey itself. The code should be : Object result = cache.get( value ) ; if ( result != null ) { return result ; } ... 2) The cache is an instance of LRUMap, which is not synchronized, and which relies on a not synchronized HashMap. This LRUMap must be synchronized using Collection.synchronizedMap(...) The containsKey method is not iterating over all keys, because the LRUMap is backed by a HashMap. The Normalizer.normalize() will behave correctly when receiving a null value. > CachingNormalizer exhibits concurrency flaw under load. > ------------------------------------------------------- > > Key: DIRLDAP-71 > URL: http://issues.apache.org/jira/browse/DIRLDAP-71 > Project: Directory LDAP > Type: Bug > Components: Common > Versions: 0.9.3 > Reporter: Jacob S. Barrett > Attachments: CachingNormalizer-Concurrency.patch > > CachingNormalizer doesn't have it's cache protected from concurrent modifications. Under load a state is reached where cache.containsKey(key) is true but the result of cache.get(key) results in an unexpected null value and thus a NullPointerException. This is really only reached when you have more than threads than the max cache size and therefore items in the cache are being purged. The attached path synchronizes the cache. It would be better to use a R/W lock from JSR 166 backport or something similar. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira