Return-Path: Delivered-To: apmail-commons-commits-archive@minotaur.apache.org Received: (qmail 34893 invoked from network); 16 Nov 2010 08:06:08 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 16 Nov 2010 08:06:08 -0000 Received: (qmail 88402 invoked by uid 500); 16 Nov 2010 08:06:39 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 88286 invoked by uid 500); 16 Nov 2010 08:06:39 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 88272 invoked by uid 99); 16 Nov 2010 08:06:38 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 16 Nov 2010 08:06:38 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 16 Nov 2010 08:06:38 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 9E8A023889E7; Tue, 16 Nov 2010 08:05:24 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1035550 - /commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/cache/DefaultFilesCache.java Date: Tue, 16 Nov 2010 08:05:24 -0000 To: commits@commons.apache.org From: rgoers@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20101116080524.9E8A023889E7@eris.apache.org> Author: rgoers Date: Tue Nov 16 08:05:24 2010 New Revision: 1035550 URL: http://svn.apache.org/viewvc?rev=1035550&view=rev Log: Use ConcurrentMap instead of synchronization Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/cache/DefaultFilesCache.java Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/cache/DefaultFilesCache.java URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/cache/DefaultFilesCache.java?rev=1035550&r1=1035549&r2=1035550&view=diff ============================================================================== --- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/cache/DefaultFilesCache.java (original) +++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/cache/DefaultFilesCache.java Tue Nov 16 08:05:24 2010 @@ -22,6 +22,8 @@ import org.apache.commons.vfs2.FileSyste import java.util.HashMap; import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; /** * A {@link org.apache.commons.vfs2.FilesCache} implementation.
@@ -35,8 +37,8 @@ public class DefaultFilesCache extends A { /** The FileSystem cache */ - private final Map> filesystemCache = - new HashMap>(10); + private final ConcurrentMap> filesystemCache = + new ConcurrentHashMap>(10); public void putFile(final FileObject file) { @@ -56,13 +58,13 @@ public class DefaultFilesCache extends A files.clear(); } - protected Map getOrCreateFilesystemCache(FileSystem filesystem) + protected ConcurrentMap getOrCreateFilesystemCache(FileSystem filesystem) { - Map files = filesystemCache.get(filesystem); + ConcurrentMap files = filesystemCache.get(filesystem); if (files == null) { - files = new HashMap(); - filesystemCache.put(filesystem, files); + filesystemCache.putIfAbsent(filesystem, new ConcurrentHashMap()); + files = filesystemCache.get(filesystem); } return files;