mirror of https://github.com/apache/activemq.git
Handle a potential NPE case. git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1165797 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
82e3be347c
commit
6e6d8605d3
|
@ -369,11 +369,13 @@ public class SequenceSet extends LinkedNodeList<Sequence> implements Iterable<Lo
|
||||||
private class SequenceIterator implements Iterator<Long> {
|
private class SequenceIterator implements Iterator<Long> {
|
||||||
|
|
||||||
private Sequence currentEntry;
|
private Sequence currentEntry;
|
||||||
private long lastReturned;
|
private long lastReturned = -1;
|
||||||
|
|
||||||
public SequenceIterator() {
|
public SequenceIterator() {
|
||||||
currentEntry = getHead();
|
currentEntry = getHead();
|
||||||
lastReturned = currentEntry.first - 1;
|
if (currentEntry != null) {
|
||||||
|
lastReturned = currentEntry.first - 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasNext() {
|
public boolean hasNext() {
|
||||||
|
|
|
@ -126,4 +126,14 @@ public class SequenceSetTest {
|
||||||
assertEquals(expected[index++], iterator.next().longValue());
|
assertEquals(expected[index++], iterator.next().longValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testIteratorEmptySequenceSet() {
|
||||||
|
SequenceSet set = new SequenceSet();
|
||||||
|
|
||||||
|
Iterator<Long> iterator = set.iterator();
|
||||||
|
while(iterator.hasNext()) {
|
||||||
|
fail("Should not have any elements");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue