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 13:41:32 UTC

[commons-vfs] branch master updated (4d7756e -> 6c25a03)

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

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


    from 4d7756e  Enabled PMD check in Maven default goal.
     new 3f2cfce  Default size is fine.
     new c0e2899  Add missing Javadocs and use better parameter names.
     new dcaeb6b  Add missing Javadocs.
     new 5afec75  Camel-case internal name.
     new 87b52ac  Better use of the internal concurrent map.
     new 6c25a03  Format, inline single-use local variable.

The 6 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../commons/vfs2/cache/DefaultFilesCache.java       | 16 ++++++++--------
 .../apache/commons/vfs2/cache/LRUFilesCache.java    | 21 ++++++++-------------
 .../commons/vfs2/cache/OnCallRefreshFileObject.java |  5 +++++
 .../vfs2/events/AbstractFileChangeEvent.java        | 17 ++++++++++++++---
 .../apache/commons/vfs2/events/ChangedEvent.java    |  9 +++++++--
 .../org/apache/commons/vfs2/events/CreateEvent.java |  9 +++++++--
 .../org/apache/commons/vfs2/events/DeleteEvent.java |  9 +++++++--
 .../commons/vfs2/cache/LRUFilesCacheTestCase.java   |  6 ++----
 8 files changed, 58 insertions(+), 34 deletions(-)

[commons-vfs] 06/06: Format, inline single-use local variable.

Posted by gg...@apache.org.
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 6c25a034487c93284b6f4b62e82665766ed94ca2
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sat Nov 27 08:41:29 2021 -0500

    Format, inline single-use local variable.
---
 .../java/org/apache/commons/vfs2/cache/LRUFilesCacheTestCase.java   | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/commons-vfs2/src/test/java/org/apache/commons/vfs2/cache/LRUFilesCacheTestCase.java b/commons-vfs2/src/test/java/org/apache/commons/vfs2/cache/LRUFilesCacheTestCase.java
index 086b10d..1333f18 100644
--- a/commons-vfs2/src/test/java/org/apache/commons/vfs2/cache/LRUFilesCacheTestCase.java
+++ b/commons-vfs2/src/test/java/org/apache/commons/vfs2/cache/LRUFilesCacheTestCase.java
@@ -16,8 +16,6 @@
  */
 package org.apache.commons.vfs2.cache;
 
-import java.io.File;
-
 import org.apache.commons.vfs2.AbstractProviderTestConfig;
 import org.apache.commons.vfs2.AbstractVfsTestCase;
 import org.apache.commons.vfs2.CacheTestSuite;
@@ -31,6 +29,7 @@ import junit.framework.Test;
  * Tests the {@link LRUFilesCache} using {@link LRUFilesCacheTests}.
  */
 public class LRUFilesCacheTestCase extends AbstractProviderTestConfig {
+
     public static Test suite() throws Exception {
         final CacheTestSuite suite = new CacheTestSuite(new LRUFilesCacheTestCase());
         suite.addTests(LRUFilesCacheTests.class);
@@ -44,7 +43,6 @@ public class LRUFilesCacheTestCase extends AbstractProviderTestConfig {
 
     @Override
     public FileObject getBaseTestFolder(final FileSystemManager manager) throws Exception {
-        final File testDir = AbstractVfsTestCase.getTestDirectoryFile();
-        return manager.toFileObject(testDir);
+        return manager.toFileObject(AbstractVfsTestCase.getTestDirectoryFile());
     }
 }

[commons-vfs] 02/06: Add missing Javadocs and use better parameter names.

Posted by gg...@apache.org.
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 c0e289984b200a239d219dc3e44aa12e2891f6ad
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sat Nov 27 08:36:37 2021 -0500

    Add missing Javadocs and use better parameter names.
---
 .../commons/vfs2/events/AbstractFileChangeEvent.java    | 17 ++++++++++++++---
 .../org/apache/commons/vfs2/events/ChangedEvent.java    |  9 +++++++--
 .../org/apache/commons/vfs2/events/CreateEvent.java     |  9 +++++++--
 .../org/apache/commons/vfs2/events/DeleteEvent.java     |  9 +++++++--
 4 files changed, 35 insertions(+), 9 deletions(-)

diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/events/AbstractFileChangeEvent.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/events/AbstractFileChangeEvent.java
index 7db6728..1e9e360 100644
--- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/events/AbstractFileChangeEvent.java
+++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/events/AbstractFileChangeEvent.java
@@ -25,9 +25,20 @@ import org.apache.commons.vfs2.FileObject;
  */
 public abstract class AbstractFileChangeEvent extends FileChangeEvent {
 
-    public AbstractFileChangeEvent(final FileObject file) {
-        super(file);
+    /**
+     * Constructs a new instance.
+     *
+     * @param fileObject the file object.
+     */
+    public AbstractFileChangeEvent(final FileObject fileObject) {
+        super(fileObject);
     }
 
-    public abstract void notify(final FileListener listener) throws Exception;
+    /**
+     * Notifies the given file listener of this event.
+     *
+     * @param fileListener The file listener to notify.
+     * @throws Exception Anything can happen.
+     */
+    public abstract void notify(final FileListener fileListener) throws Exception;
 }
diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/events/ChangedEvent.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/events/ChangedEvent.java
index 5445be7..dc05fdd 100644
--- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/events/ChangedEvent.java
+++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/events/ChangedEvent.java
@@ -24,8 +24,13 @@ import org.apache.commons.vfs2.FileObject;
  */
 public class ChangedEvent extends AbstractFileChangeEvent {
 
-    public ChangedEvent(final FileObject file) {
-        super(file);
+    /**
+     * Constructs a new instance.
+     *
+     * @param fileObject the file object.
+     */
+    public ChangedEvent(final FileObject fileObject) {
+        super(fileObject);
     }
 
     @Override
diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/events/CreateEvent.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/events/CreateEvent.java
index c428785..cb0429c 100644
--- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/events/CreateEvent.java
+++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/events/CreateEvent.java
@@ -24,8 +24,13 @@ import org.apache.commons.vfs2.FileObject;
  */
 public class CreateEvent extends AbstractFileChangeEvent {
 
-    public CreateEvent(final FileObject file) {
-        super(file);
+    /**
+     * Constructs a new instance.
+     *
+     * @param fileObject the file object.
+     */
+    public CreateEvent(final FileObject fileObject) {
+        super(fileObject);
     }
 
     @Override
diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/events/DeleteEvent.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/events/DeleteEvent.java
index ef23119..9846a8c 100644
--- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/events/DeleteEvent.java
+++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/events/DeleteEvent.java
@@ -24,8 +24,13 @@ import org.apache.commons.vfs2.FileObject;
  */
 public class DeleteEvent extends AbstractFileChangeEvent {
 
-    public DeleteEvent(final FileObject file) {
-        super(file);
+    /**
+     * Constructs a new instance.
+     *
+     * @param fileObject the file object.
+     */
+    public DeleteEvent(final FileObject fileObject) {
+        super(fileObject);
     }
 
     @Override

[commons-vfs] 01/06: Default size is fine.

Posted by gg...@apache.org.
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 3f2cfce96575bd70716f12f44eee1bc1c1770a58
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sat Nov 27 08:13:14 2021 -0500

    Default size is fine.
---
 .../src/main/java/org/apache/commons/vfs2/cache/LRUFilesCache.java      | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/cache/LRUFilesCache.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/cache/LRUFilesCache.java
index 0fa6a7b..100611c 100644
--- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/cache/LRUFilesCache.java
+++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/cache/LRUFilesCache.java
@@ -49,7 +49,7 @@ public class LRUFilesCache extends AbstractFilesCache {
     private static final Log log = LogFactory.getLog(LRUFilesCache.class);
 
     /** The FileSystem cache */
-    private final ConcurrentMap<FileSystem, Map<FileName, FileObject>> filesystemCache = new ConcurrentHashMap<>(10);
+    private final ConcurrentMap<FileSystem, Map<FileName, FileObject>> filesystemCache = new ConcurrentHashMap<>();
 
     /** The size of the cache */
     private final int lruSize;

[commons-vfs] 04/06: Camel-case internal name.

Posted by gg...@apache.org.
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 5afec75b4f7a8fc4ac042fcfa751a7f982d4908e
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sat Nov 27 08:37:26 2021 -0500

    Camel-case internal name.
---
 .../org/apache/commons/vfs2/cache/DefaultFilesCache.java | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 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 4da0aa4..fed6618 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
@@ -45,7 +45,7 @@ import org.apache.commons.vfs2.FileSystem;
 public class DefaultFilesCache extends AbstractFilesCache {
 
     /** The FileSystem cache. Keeps one Map for each FileSystem. */
-    private final ConcurrentMap<FileSystem, ConcurrentMap<FileName, FileObject>> filesystemCache = new ConcurrentHashMap<>(
+    private final ConcurrentMap<FileSystem, ConcurrentMap<FileName, FileObject>> fileSystemCache = new ConcurrentHashMap<>(
             10);
 
     @Override
@@ -63,7 +63,7 @@ public class DefaultFilesCache extends AbstractFilesCache {
     @Override
     public FileObject getFile(final FileSystem filesystem, final FileName name) {
         // avoid creating filesystem entry for empty filesystem cache:
-        final Map<FileName, FileObject> files = filesystemCache.get(filesystem);
+        final Map<FileName, FileObject> files = fileSystemCache.get(filesystem);
         if (files == null) {
             // cache for filesystem is not known => file is not cached:
             return null;
@@ -75,18 +75,18 @@ public class DefaultFilesCache extends AbstractFilesCache {
     @Override
     public void clear(final FileSystem filesystem) {
         // avoid keeping a reference to the FileSystem (key) object
-        final Map<FileName, FileObject> files = filesystemCache.remove(filesystem);
+        final Map<FileName, FileObject> files = fileSystemCache.remove(filesystem);
         if (files != null) {
             files.clear(); // help GC
         }
     }
 
     protected ConcurrentMap<FileName, FileObject> getOrCreateFilesystemCache(final FileSystem filesystem) {
-        ConcurrentMap<FileName, FileObject> files = filesystemCache.get(filesystem);
+        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));
-            files = filesystemCache.get(filesystem);
+            fileSystemCache.putIfAbsent(filesystem, new ConcurrentHashMap<>(200, 0.75f, 8));
+            files = fileSystemCache.get(filesystem);
         }
 
         return files;
@@ -95,13 +95,13 @@ public class DefaultFilesCache extends AbstractFilesCache {
     @Override
     public void close() {
         super.close();
-        filesystemCache.clear();
+        fileSystemCache.clear();
     }
 
     @Override
     public void removeFile(final FileSystem filesystem, final FileName name) {
         // avoid creating filesystem entry for empty filesystem cache:
-        final Map<FileName, FileObject> files = filesystemCache.get(filesystem);
+        final Map<FileName, FileObject> files = fileSystemCache.get(filesystem);
         if (files != null) {
             files.remove(name);
             // This would be too racey:

[commons-vfs] 03/06: Add missing Javadocs.

Posted by gg...@apache.org.
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 dcaeb6b3529d499f4313b7cccd6981361db2ef6f
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sat Nov 27 08:36:59 2021 -0500

    Add missing Javadocs.
---
 .../java/org/apache/commons/vfs2/cache/OnCallRefreshFileObject.java  | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/cache/OnCallRefreshFileObject.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/cache/OnCallRefreshFileObject.java
index 1a041b7..14620d2 100644
--- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/cache/OnCallRefreshFileObject.java
+++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/cache/OnCallRefreshFileObject.java
@@ -31,6 +31,11 @@ import org.apache.commons.vfs2.impl.DecoratedFileObject;
  */
 public class OnCallRefreshFileObject extends DecoratedFileObject {
 
+    /**
+     * Constructs a new instance to decorate the given file object.
+     *
+     * @param fileObject The decorated.
+     */
     public OnCallRefreshFileObject(final FileObject fileObject) {
         super(fileObject);
     }

[commons-vfs] 05/06: Better use of the internal concurrent map.

Posted by gg...@apache.org.
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 87b52ac8cb68d101bc1c24d7587cb20a35e1a50a
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sat Nov 27 08:40:56 2021 -0500

    Better use of the internal concurrent map.
---
 .../apache/commons/vfs2/cache/LRUFilesCache.java    | 21 ++++++++-------------
 1 file changed, 8 insertions(+), 13 deletions(-)

diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/cache/LRUFilesCache.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/cache/LRUFilesCache.java
index 100611c..eecaefc 100644
--- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/cache/LRUFilesCache.java
+++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/cache/LRUFilesCache.java
@@ -49,7 +49,7 @@ public class LRUFilesCache extends AbstractFilesCache {
     private static final Log log = LogFactory.getLog(LRUFilesCache.class);
 
     /** The FileSystem cache */
-    private final ConcurrentMap<FileSystem, Map<FileName, FileObject>> filesystemCache = new ConcurrentHashMap<>();
+    private final ConcurrentMap<FileSystem, Map<FileName, FileObject>> fileSystemCache = new ConcurrentHashMap<>();
 
     /** The size of the cache */
     private final int lruSize;
@@ -100,9 +100,9 @@ public class LRUFilesCache extends AbstractFilesCache {
                         VfsLog.warn(getLogger(), log, Messages.getString("vfs.impl/LRUFilesCache-remove-ex.warn"), e);
                     }
 
-                    final Map<?, ?> files = filesystemCache.get(filesystem);
+                    final Map<?, ?> files = fileSystemCache.get(filesystem);
                     if (files.isEmpty()) {
-                        filesystemCache.remove(filesystem);
+                        fileSystemCache.remove(filesystem);
                     }
 
                     return true;
@@ -180,25 +180,20 @@ public class LRUFilesCache extends AbstractFilesCache {
         try {
             files.clear();
 
-            filesystemCache.remove(filesystem);
+            fileSystemCache.remove(filesystem);
         } finally {
             writeLock.unlock();
         }
     }
 
-    protected Map<FileName, FileObject> getOrCreateFilesystemCache(final FileSystem filesystem) {
-        Map<FileName, FileObject> files = filesystemCache.get(filesystem);
-        if (files == null) {
-            files = new MyLRUMap(filesystem, lruSize);
-            filesystemCache.putIfAbsent(filesystem, files);
-        }
-        return files;
+    protected Map<FileName, FileObject> getOrCreateFilesystemCache(final FileSystem fileSystem) {
+        return fileSystemCache.computeIfAbsent(fileSystem, k -> new MyLRUMap(k, lruSize));
     }
 
     @Override
     public void close() {
         super.close();
-        filesystemCache.clear();
+        fileSystemCache.clear();
     }
 
     @Override
@@ -210,7 +205,7 @@ public class LRUFilesCache extends AbstractFilesCache {
             files.remove(name);
 
             if (files.isEmpty()) {
-                filesystemCache.remove(filesystem);
+                fileSystemCache.remove(filesystem);
             }
         } finally {
             writeLock.unlock();