unwrap the recursion when removing orphan references. this caused a stack overflow exception if a thew thousand references where empty
This commit is contained in:
parent
c74e3da2dd
commit
54b3154ddc
@ -88,9 +88,10 @@ public class ConcurrentSet<T> implements Iterable<T>{
|
|||||||
|
|
||||||
public boolean hasNext() {
|
public boolean hasNext() {
|
||||||
if (current == null) return false;
|
if (current == null) return false;
|
||||||
T value = current.getValue();
|
if (current.getValue() == null) { // auto-removal of orphan references
|
||||||
if (value == null) { // auto-removal of orphan references
|
do {
|
||||||
remove();
|
remove();
|
||||||
|
} while(current != null && current.getValue() == null);
|
||||||
return hasNext();
|
return hasNext();
|
||||||
} else {
|
} else {
|
||||||
return true;
|
return true;
|
||||||
@ -101,7 +102,9 @@ public class ConcurrentSet<T> implements Iterable<T>{
|
|||||||
if (current == null) return null;
|
if (current == null) return null;
|
||||||
T value = current.getValue();
|
T value = current.getValue();
|
||||||
if (value == null) { // auto-removal of orphan references
|
if (value == null) { // auto-removal of orphan references
|
||||||
remove();
|
do {
|
||||||
|
remove();
|
||||||
|
} while(current != null && current.getValue() == null);
|
||||||
return next();
|
return next();
|
||||||
} else {
|
} else {
|
||||||
current = current.next();
|
current = current.next();
|
||||||
|
Loading…
Reference in New Issue
Block a user