Fix IndexOutOfBoundsException in IOExceptionList contructors.
MODIFY
src/main/java/org/apache/commons/io/IOExceptionList.java
src/main/java/org/apache/commons/io/IOExceptionList.java
@@ -52,7 +52,7 @@ public IOExceptionList(final List<? extends Throwable> causeList) {
* @since 2.9.0
*/
public IOExceptionList(final String message, final List<? extends Throwable> causeList) {
- super(message, causeList == null ? null : causeList.get(0));
+ super(message, causeList == null || causeList.isEmpty() ? null : causeList.get(0));
this.causeList = causeList == null ? Collections.emptyList() : causeList;
}

MODIFY
src/test/java/org/apache/commons/io/IOExceptionListTestCase.java
src/test/java/org/apache/commons/io/IOExceptionListTestCase.java
@@ -49,6 +49,12 @@ public void testCause() {
assertEquals(list, causeList);
}
+ @Test
+ public void testEmptyList() {
+ new IOExceptionList(Collections.emptyList());
+ new IOExceptionList("foo", Collections.emptyList());
+ }
+
@Test
public void testMessageCause() {
final EOFException cause = new EOFException();

Fix IndexOutOfBoundsException in IOExceptionList contructors.