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:22 UTC
[commons-vfs] 01/03: Fix Checkstyle MagicNumber.
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 48fb2965f7b616ceb69ab2fd7b693e294ca080f0
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sat Nov 27 10:40:19 2021 -0500
Fix Checkstyle MagicNumber.
---
.../java/org/apache/commons/vfs2/cache/DefaultFilesCache.java | 8 +++++---
1 file changed, 5 insertions(+), 3 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 fed6618..94cb6c4 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
@@ -44,9 +44,11 @@ import org.apache.commons.vfs2.FileSystem;
*/
public class DefaultFilesCache extends AbstractFilesCache {
+ private static final float LOAD_FACTOR = 0.75f;
+ private static final int INITIAL_CAPACITY = 200;
+
/** The FileSystem cache. Keeps one Map for each FileSystem. */
- private final ConcurrentMap<FileSystem, ConcurrentMap<FileName, FileObject>> fileSystemCache = new ConcurrentHashMap<>(
- 10);
+ private final ConcurrentMap<FileSystem, ConcurrentMap<FileName, FileObject>> fileSystemCache = new ConcurrentHashMap<>(10);
@Override
public void putFile(final FileObject file) {
@@ -85,7 +87,7 @@ 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<>(200, 0.75f, 8));
+ fileSystemCache.putIfAbsent(filesystem, new ConcurrentHashMap<>(INITIAL_CAPACITY, LOAD_FACTOR, Math.max(2, Runtime.getRuntime().availableProcessors()) / 2));
files = fileSystemCache.get(filesystem);
}