calrissian / mango

Common utilities for rapid application development
Apache License 2.0
17 stars 7 forks source link

CloseableIterables.emptyIterable() is severly broken #157

Closed eawagner closed 9 years ago

eawagner commented 9 years ago

The problem is that the Empty Iterable is backed but a constant Iterable that is constructed using the wrap() method, which will make an AbstractCloseableIterable.

The problem with this is that once the AbstractCloseableIterable is closed, it can't be reused. This means that as soon as anyone closes one emptyIterable, noone can use it or they will receive an exception that the iterable is already closed.

My current workaround has been to simply create the emptyIterable each time manually,

CloseableIterables.wrap(Collections.emptySet());

The long term solution is to not use AbstractCloseableIterable for any constant, as it maintains state.