Skip to content

Commit

Permalink
Fix SpotBugs errors
Browse files Browse the repository at this point in the history
[ERROR] Medium:
org.apache.commons.io.monitor.FileAlterationMonitor.getObservers() may
expose internal representation by returning
FileAlterationMonitor.observers [org.apache.commons.io.monitor.FileAlterationMonitor]
At FileAlterationMonitor.java:[line 124] EI_EXPOSE_REP
[ERROR] Medium:
org.apache.commons.io.monitor.FileAlterationObserver.getListeners() may
expose internal representation by returning
FileAlterationObserver.listeners [org.apache.commons.io.monitor.FileAlterationObserver]
At FileAlterationObserver.java:[line 397] EI_EXPOSE_REP
  • Loading branch information
garydgregory committed Nov 23, 2023
1 parent e539867 commit 3a0bf1c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/changes/changes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ The <action> type attribute can be add,update,fix,remove.
<action dev="ggregory" type="fix" due-to="Gary Gregory">Fix SpotBugs error: Class org.apache.commons.io.filefilter.DelegateFileFilter defines non-transient non-serializable instance field fileFilter [org.apache.commons.io.filefilter.DelegateFileFilter] In DelegateFileFilter.java SE_BAD_FIELD.</action>
<action dev="ggregory" type="fix" due-to="Gary Gregory">Fix SpotBugs error: Class org.apache.commons.io.filefilter.DelegateFileFilter defines non-transient non-serializable instance field fileNameFilter [org.apache.commons.io.filefilter.DelegateFileFilter] In DelegateFileFilter.java SE_BAD_FIELD.</action>
<action dev="ggregory" type="fix" due-to="Gary Gregory">Fix SpotBugs error: org.apache.commons.io.function.IOStream$1.next() cannot throw NoSuchElementException [org.apache.commons.io.function.IOStream$1] At IOStream.java:[line 98] IT_NO_SUCH_ELEMENT.</action>
<action dev="ggregory" type="fix" due-to="Gary Gregory">Fix SpotBugs error: org.apache.commons.io.monitor.FileAlterationMonitor.getObservers() may expose internal representation by returning FileAlterationMonitor.observers [org.apache.commons.io.monitor.FileAlterationMonitor] At FileAlterationMonitor.java:[line 124] EI_EXPOSE_REP.</action>
<action dev="ggregory" type="fix" due-to="Gary Gregory">Fix SpotBugs error: Class org.apache.commons.io.monitor.FileAlterationObserver defines non-transient non-serializable instance field fileFilter [org.apache.commons.io.monitor.FileAlterationObserver] In FileAlterationObserver.java SE_BAD_FIELD.</action>
<action dev="ggregory" type="fix" due-to="Gary Gregory">Fix SpotBugs error: Class org.apache.commons.io.monitor.FileAlterationObserver defines non-transient non-serializable instance field listeners [org.apache.commons.io.monitor.FileAlterationObserver] In FileAlterationObserver.java SE_BAD_FIELD.</action>
<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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package org.apache.commons.io.monitor;

import java.time.Duration;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
Expand Down Expand Up @@ -121,7 +122,7 @@ public long getInterval() {
* @return The set of {@link FileAlterationObserver}
*/
public Iterable<FileAlterationObserver> getObservers() {
return observers;
return new ArrayList<>(observers);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.io.File;
import java.io.FileFilter;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
Expand Down Expand Up @@ -394,7 +395,7 @@ public FileFilter getFileFilter() {
* @return The file system listeners
*/
public Iterable<FileAlterationListener> getListeners() {
return listeners;
return new ArrayList<>(listeners);
}

/**
Expand Down

0 comments on commit 3a0bf1c

Please sign in to comment.