DESCRIPTION

SPY-192: Ensure connection key is valid before checking if writable.

Motivation
----------
It has been discovered in the wild that sometimes CancelledKeyException are
received even if the key has been checked for validity before. It turns out
that the validity can change between the check and the next function call.

Modifications
-------------
The changeset makes sure to check if it is valid on both reading and
subsequent writing, reducing the chance of race conditions and interleaved
state changes.

Result
------
More stable behavior at runtime and less chance of CancelledKeyException.

Change-Id: Ic0db65f9c7ccc3a7b9738aaff0e3c7e60d7f25c2
Reviewed-on: http://review.couchbase.org/72270
Reviewed-by: Natasha Sullivan xxx@xxx.xxx
Tested-by: Natasha Sullivan xxx@xxx.xxx


COMMENTS

author: Natasha Sullivan
date: 2017-02-01 07:00:00.274000000

Change has been successfully cherry-picked as 2b6e3bbc823aa68d7aa5b7f3bb8ece1b2c284d0e by Natasha Sullivan

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