*Version:*
commons-collections-4.5.0
*Description:*
In org.apache.commons.collections4.list.TreeList$TreeListIterator.previous(
TreeList.java:863).
The next reference is not checked for null before calling getValue(), which
can result in a NullPointerException.
```java
@Override
public E previous() {
checkModCount();
if (!hasPrevious()) {
throw new NoSuchElementException("Already at start of list.");
}
if (next == null) {
next = parent.root.get(nextIndex - 1);
} else {
next = next.previous();
}
final E value = next.getValue(); // NPE !
current = next;
currentIndex = --nextIndex;
return value;
}
```
*Step to reproduce:*
Test Code:
```java
package org.apache.commons.collections4.list;
import org.junit.Test;
import org.apache.commons.collections4.list.TreeList;
import java.time.format.TextStyle;
import java.util.NoSuchElementException;
public class TestClass {
@Test(timeout=3000)
public void test() throws Throwable {
TreeList<TextStyle> treeList0 = new TreeList<TextStyle>();
treeList0.add(TextStyle.FULL);
treeList0.add(TextStyle.SHORT);
TreeList.TreeListIterator<TextStyle> treeList_TreeListIterator0 = new
TreeList.TreeListIterator<TextStyle>(treeList0, 3);
treeList_TreeListIterator0.previous();
}
}
```
Execution Result:
```
JUnit version 4.12
.E
Time: 0.016
There was 1 failure:
1) test(org.apache.commons.collections4.list.TestClass)
java.lang.NullPointerException
at org.apache.commons.collections4.list.TreeList$TreeListIterator.previous(
TreeList.java:863)
at org.apache.commons.collections4.list.TestClass.test(TestClass.java:15)
FAILURES!!!
Tests run: 1, Failures: 1
```
Environment:
```
Apache Maven 3.9.1
Java version: 1.8.0_452, vendor: Private Build, runtime:
/usr/lib/jvm/java-8-openjdk-amd64/jre
Default locale: en, platform encoding: UTF-8
OS name: "linux", version: "5.15.0-138-generic", arch: "amd64", family:
"unix"
```