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-io.git


The following commit(s) were added to refs/heads/master by this push:
     new e539867f Fix SpotBugs errors
e539867f is described below

commit e539867f5912a565d88d843bace0b9f429483723
Author: Gary Gregory <garydgreg...@gmail.com>
AuthorDate: Thu Nov 23 12:09:50 2023 -0500

    Fix SpotBugs errors
    
    - [ERROR] Medium:
    org.apache.commons.io.file.AccumulatorPathVisitor.getDirList() may
    expose internal representation by returning
    AccumulatorPathVisitor.dirList 
[org.apache.commons.io.file.AccumulatorPathVisitor]
    At AccumulatorPathVisitor.java:[line 179] EI_EXPOSE_REP
    - [ERROR] Medium:
    org.apache.commons.io.file.AccumulatorPathVisitor.getFileList() may
    expose internal representation by returning
    AccumulatorPathVisitor.fileList 
[org.apache.commons.io.file.AccumulatorPathVisitor]
    At AccumulatorPathVisitor.java:[line 188] EI_EXPOSE_REP
---
 src/changes/changes.xml                                      |  2 ++
 .../org/apache/commons/io/file/AccumulatorPathVisitor.java   | 12 ++++++------
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index a0d4e4e1..2b74571c 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -64,6 +64,8 @@ The <action> type attribute can be add,update,fix,remove.
       <action dev="ggregory" type="fix" due-to="Gary Gregory">Fix SpotBugs 
error: org.apache.commons.io.FileCleaningTracker.getDeleteFailures() may expose 
internal representation by returning FileCleaningTracker.deleteFailures 
[org.apache.commons.io.FileCleaningTracker] At FileCleaningTracker.java:[line 
218] EI_EXPOSE_REP.</action>
       <action dev="ggregory" type="fix" due-to="Gary Gregory">Fix SpotBugs 
error: org.apache.commons.io.IOExceptionList.getCauseList() may expose internal 
representation by returning IOExceptionList.causeList 
[org.apache.commons.io.IOExceptionList] At IOExceptionList.java:[line 118] 
EI_EXPOSE_REP.</action>
       <action dev="ggregory" type="fix" due-to="Gary Gregory">Fix SpotBugs 
error: org.apache.commons.io.IOExceptionList.getCauseList(Class) may expose 
internal representation by returning IOExceptionList.causeList 
[org.apache.commons.io.IOExceptionList] At IOExceptionList.java:[line 129] 
EI_EXPOSE_REP.</action>
+      <action dev="ggregory" type="fix" due-to="Gary Gregory">Fix SpotBugs 
error: org.apache.commons.io.file.AccumulatorPathVisitor.getDirList() may 
expose internal representation by returning AccumulatorPathVisitor.dirList 
[org.apache.commons.io.file.AccumulatorPathVisitor] At 
AccumulatorPathVisitor.java:[line 179] EI_EXPOSE_REP.</action>
+      <action dev="ggregory" type="fix" due-to="Gary Gregory">Fix SpotBugs 
error: org.apache.commons.io.file.AccumulatorPathVisitor.getFileList() may 
expose internal representation by returning AccumulatorPathVisitor.fileList 
[org.apache.commons.io.file.AccumulatorPathVisitor] At 
AccumulatorPathVisitor.java:[line 188] EI_EXPOSE_REP.</action>
       <!-- UPDATE -->
       <action dev="ggregory" type="update" due-to="Gary Gregory">Bump 
org.codehaus.mojo:exec-maven-plugin from 3.1.0 to 3.1.1 #512.</action>
       <action dev="ggregory" type="update" due-to="Gary Gregory">Bump 
commons-lang3 from 3.13.0 to 3.14.0.</action>      
diff --git 
a/src/main/java/org/apache/commons/io/file/AccumulatorPathVisitor.java 
b/src/main/java/org/apache/commons/io/file/AccumulatorPathVisitor.java
index ecfdd2b7..6aa26789 100644
--- a/src/main/java/org/apache/commons/io/file/AccumulatorPathVisitor.java
+++ b/src/main/java/org/apache/commons/io/file/AccumulatorPathVisitor.java
@@ -171,21 +171,21 @@ public class AccumulatorPathVisitor extends 
CountingPathVisitor {
     }
 
     /**
-     * Gets the list of visited directories.
+     * Gets a copy of the list of visited directories.
      *
-     * @return the list of visited directories.
+     * @return a copy of the list of visited directories.
      */
     public List<Path> getDirList() {
-        return dirList;
+        return new ArrayList<>(dirList);
     }
 
     /**
-     * Gets the list of visited files.
+     * Gets a copy of the list of visited files.
      *
-     * @return the list of visited files.
+     * @return a copy of the list of visited files.
      */
     public List<Path> getFileList() {
-        return fileList;
+        return new ArrayList<>(fileList);
     }
 
     @Override

Reply via email to