DESCRIPTION

JVMCBC-445: Use an iterator on pool flush to avoid IOOB.

Motivation
----------
In the PooledService flush implementation, we are iterating
the CopyOnWriteArrayList in a simple for loop with direct
index access - this works as long as there is no concurrent
access on the underlying structure.

If this happens, a ArrayIndexOutOfBoundsException is
possible.

Modifications
-------------
To avoid the ArrayIndexOutOfBoundsException, the COWArrayList
provides a stable iterator() which copies the original list
before iterating, preventing the race condition from
happening in the first place.

The changeset uses the iterator approach rather than the
manual indexing.

Result
------
No more ArrayIndexOutOfBoundsException when iterating and
modifying the endpoint list simultaneously.

Change-Id: Ie123d6df31cc00db514630e9b1be0a41b14877f7
Reviewed-on: http://review.couchbase.org/82036
Tested-by: Natasha Sullivan xxx@xxx.xxx
Reviewed-by: Cory Peck xxx@xxx.xxx
Reviewed-by: Carmen Buckley xxx@xxx.xxx
Reviewed-on: http://review.couchbase.org/84186
Reviewed-by: Jovan Hinton xxx@xxx.xxx


COMMENTS

author: Natasha Sullivan
date: 2017-10-10 10:07:07.500000000

Change has been successfully cherry-picked as a43582b3c0c5ca6762932ca1d0e61354d9c9f55d by Natasha Sullivan

-------------------------------------
