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.
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,
The long term solution is to not use AbstractCloseableIterable for any constant, as it maintains state.