Skip to content

Commit 4a3e4f2

Browse files
committed
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
1 parent 05e745f commit 4a3e4f2

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

src/changes/changes.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ The <action> type attribute can be add,update,fix,remove.
6262
<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>
6363
<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>
6464
<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>
65+
<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>
66+
<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>
6567
<!-- UPDATE -->
6668
<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>
6769
<action dev="ggregory" type="update" due-to="Gary Gregory">Bump commons-lang3 from 3.13.0 to 3.14.0.</action>

src/main/java/org/apache/commons/io/IOExceptionList.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
package org.apache.commons.io;
1919

2020
import java.io.IOException;
21+
import java.util.ArrayList;
2122
import java.util.Collections;
2223
import java.util.Iterator;
2324
import java.util.List;
@@ -115,7 +116,7 @@ public <T extends Throwable> T getCause(final int index, final Class<T> clazz) {
115116
* @return The list of causes.
116117
*/
117118
public <T extends Throwable> List<T> getCauseList() {
118-
return (List<T>) causeList;
119+
return (List<T>) new ArrayList<>(causeList);
119120
}
120121

121122
/**
@@ -126,7 +127,7 @@ public <T extends Throwable> List<T> getCauseList() {
126127
* @return The list of causes.
127128
*/
128129
public <T extends Throwable> List<T> getCauseList(final Class<T> clazz) {
129-
return (List<T>) causeList;
130+
return (List<T>) new ArrayList<>(causeList);
130131
}
131132

132133
@Override

0 commit comments

Comments
 (0)