Details
-
Bug
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
3.0, 3.1, 3.2
-
None
Description
AbstractListDecorator uses getList() to access its private member variable for its methods:
public int indexOf(Object object) { return getList().indexOf(object); }
Which allows me to almost do something like this (notice I'm taking some liberties here with the no-arg serialization constructor):
public static class FutureList<T> extends AbstractListDecorator { private Future<List<T>> futureList; public FutureList(Future<List<T>> futureList) { super(); this.futureList = futureList; } @Override protected Collection<T> getCollection() { try { return futureList.get(); } catch (InterruptedException e) { throw new RuntimeException(e); } catch (ExecutionException e) { throw new RuntimeException(e); } } }
But AbstractCollectionDecorator uses its private member variable
public boolean add(Object object) { return collection.add(object); }
When it should be IMHO:
public boolean add(Object object) { return getCollection().add(object); }
Of course most everybody has an armpit and an opinion