HTTPCLIENT-1772: [OSGi] WeakList needs to support "clear" method
git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/branches/4.5.x@1762913 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
07fe1b7cdb
commit
b99a5138cc
|
@ -62,6 +62,11 @@ class WeakList<T> extends AbstractList<T> {
|
|||
return innerList.add(new WeakReference<T>(t));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
innerList.clear();
|
||||
}
|
||||
|
||||
private void checkReferences() {
|
||||
final ListIterator<WeakReference<T>> references = innerList.listIterator();
|
||||
while (references.hasNext()) {
|
||||
|
|
|
@ -59,4 +59,15 @@ public class WeakListTest {
|
|||
assertTrue(thrown);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void clearSupported() {
|
||||
final WeakList<Object> list = new WeakList<Object>();
|
||||
|
||||
list.add("hello");
|
||||
assertEquals(1, list.size());
|
||||
|
||||
list.clear();
|
||||
assertEquals(0, list.size());
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue