This was caused by a silly mistake in my fix for 6299405. I cleaned up some code in
StreamCloser so as to avoid an array copy. In theory the copy should be unnecessary
because we synchronize add/remove operations on the toCloseQueue, or so I thought.
It turns out that we don't actually synchronize properly in removeFromQueue(), but
that's not really the cause of the failure here. The bug is that without the copied
array, we will get a ConcurrentModificationException because is.close() will in turn
call StreamCloser.removeFromQueue() while we are iterating over the set of streams.
So anyway, I shouldn't have touched this code in the first place. I'll revert the
code back to the way it was and will add a comment saying why the copy is necessary.