[main] Potential fix for incorrect hasNext in ref

This commit is contained in:
Johannes Frohnmeyer 2022-06-23 18:34:58 +02:00
parent 87bcac302c
commit 9e0711efc7
Signed by: Johannes
GPG Key ID: E76429612C2929F4
2 changed files with 4 additions and 2 deletions

View File

@ -21,7 +21,7 @@ public class WeakSet<E> extends AbstractSet<E> {
synchronized (WeakSet.this) {
if (delegate.hasNext()) {
next = unwrap(delegate.next());
return true;
return next != null || hasNext();
}
}
return false;

View File

@ -190,7 +190,9 @@ public class WeakValueMap<K, V> implements Map<K, V> {
synchronized (WeakValueMap.this) {
if (delegate.hasNext()) {
Entry<K, WeakValue<K, V>> ent = delegate.next();
next = new DelegateEntry(ent, unwrap(ent.getValue()));
V value = unwrap(ent.getValue());
if (value == null) return hasNext();
next = new DelegateEntry(ent, value);
return true;
}
}