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 4a3e4f28 Fix SpotBugs errors
4a3e4f28 is described below
commit 4a3e4f284477ac6a43fea2f0c2cb0e210483c627
Author: Gary Gregory <[email protected]>
AuthorDate: Thu Nov 23 12:07:30 2023 -0500
Fix SpotBugs errors
- [ERROR] Medium: 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
- [ERROR] Medium:
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
---
src/changes/changes.xml | 2 ++
src/main/java/org/apache/commons/io/IOExceptionList.java | 5 +++--
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 24b75e50..a0d4e4e1 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -62,6 +62,8 @@ 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.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>
+ <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>
<!-- 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/IOExceptionList.java
b/src/main/java/org/apache/commons/io/IOExceptionList.java
index 8ee519b5..c8bd4bf9 100644
--- a/src/main/java/org/apache/commons/io/IOExceptionList.java
+++ b/src/main/java/org/apache/commons/io/IOExceptionList.java
@@ -18,6 +18,7 @@
package org.apache.commons.io;
import java.io.IOException;
+import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
@@ -115,7 +116,7 @@ public class IOExceptionList extends IOException implements
Iterable<Throwable>
* @return The list of causes.
*/
public <T extends Throwable> List<T> getCauseList() {
- return (List<T>) causeList;
+ return (List<T>) new ArrayList<>(causeList);
}
/**
@@ -126,7 +127,7 @@ public class IOExceptionList extends IOException implements
Iterable<Throwable>
* @return The list of causes.
*/
public <T extends Throwable> List<T> getCauseList(final Class<T> clazz) {
- return (List<T>) causeList;
+ return (List<T>) new ArrayList<>(causeList);
}
@Override