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


COMMENTS

author: Natasha Sullivan
date: 2017-08-08 06:41:14.489000000

Uploaded patch set 2.

-------------------------------------
author: Natasha Sullivan
date: 2017-08-08 06:45:20.977000000

Patch Set 2: Verified+1

-------------------------------------
author: Hugo Blankenship
date: 2017-08-08 06:45:22.610000000

Patch Set 2:

Build Started http://sdkbuilds.sc.couchbase.com/job/couchbase-jvm-core-test/9/

-------------------------------------
author: Hugo Blankenship
date: 2017-08-08 06:47:39.377000000

Patch Set 2: Code-Review-2

Build Failed 

http://sdkbuilds.sc.couchbase.com/job/couchbase-jvm-core-test/9/ : FAILURE

-------------------------------------
author: Natasha Sullivan
date: 2017-08-08 08:34:23.215000000

Removed Code-Review-2 by Hugo Blankenship xxx@xxx.xxx


-------------------------------------
author: Cory Peck
date: 2017-08-08 17:28:09.402000000

Patch Set 2: Code-Review+2

-------------------------------------
author: Carmen Buckley
date: 2017-08-08 22:31:05.289000000

Patch Set 2: Code-Review+1

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