You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2021/11/27 15:59:23 UTC

[commons-vfs] 02/03: Better concurrency.

This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-vfs.git

commit 23d4b54c3125a4a1d23cd919837f6d8a646196f7
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sat Nov 27 10:55:33 2021 -0500

    Better concurrency.
---
 .../main/java/org/apache/commons/vfs2/cache/DefaultFilesCache.java    | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/cache/DefaultFilesCache.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/cache/DefaultFilesCache.java
index 94cb6c4..70439b2 100644
--- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/cache/DefaultFilesCache.java
+++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/cache/DefaultFilesCache.java
@@ -87,8 +87,8 @@ public class DefaultFilesCache extends AbstractFilesCache {
         ConcurrentMap<FileName, FileObject> files = fileSystemCache.get(filesystem);
         // we loop to make sure we never return null even when concurrent clean is called
         while (files == null) {
-            fileSystemCache.putIfAbsent(filesystem, new ConcurrentHashMap<>(INITIAL_CAPACITY, LOAD_FACTOR, Math.max(2, Runtime.getRuntime().availableProcessors()) / 2));
-            files = fileSystemCache.get(filesystem);
+            files = fileSystemCache.computeIfAbsent(filesystem,
+                k -> new ConcurrentHashMap<>(INITIAL_CAPACITY, LOAD_FACTOR, Math.max(2, Runtime.getRuntime().availableProcessors()) / 2));
         }
 
         return files;