DESCRIPTION

JCBC-591 : if bucket was closed, operations will throw a BucketClosedException

Motivation
-----------
When calling close() on a Bucket, one expects not to be able to use the bucket
operations anymore. However the bucket doesn't fail gracefully and instead
attempt to perform the operation, which results in a TimeoutException from the
underlying AsyncBucket after a delay.

Modifications
-------------
The CouchbaseAsyncBucket has been refactored. When close() operation is performed,
an internal flag is set, which can be seen through isClosed() method.

Operations that previously sent a request to the core now go through a
checkedSend method that will check the closed status. If closed, it will return
an Observable that just fails immediately with a BucketClosedException instead
of forwarding the request to the core.

Users can be impacted if they were watching for TimeoutExceptions specifically
to detect a closed bucket.

Result
------
Blocking operations on a closed bucket immediately throw a BucketClosedException.
Async operation call the subscriber's onError method with BucketClosedException.

Change-Id: Ia6de60a882ef6d81cc807a7205bb1c1002e7df42


COMMENTS

author: Estrella Humphrey
date: 2014-10-15 17:29:27.112000000

Uploaded patch set 2.

-------------------------------------
author: Estrella Humphrey
date: 2014-10-15 17:32:57.039000000

Patch Set 2: Verified+1

reworked into a checkedSend method to replace calls to core.send, wrapping a check for closed status and failing the returned observable instead of throwing the exception.

corrected formatting and javadocs issues

-------------------------------------
author: Cory Peck
date: 2014-10-15 17:34:41.751000000

Patch Set 2:

(2 comments)

Line:142, src/main/java/com/couchbase/client/java/CouchbaseAsyncBucket.java -> I don't think `this` keyword is necessary here

Line:241, src/main/java/com/couchbase/client/java/CouchbaseAsyncBucket.java -> why didn't you use checkedSend() here?

-------------------------------------
author: Estrella Humphrey
date: 2014-10-15 17:45:51.619000000

Patch Set 2:

(2 comments)

Line:142, src/main/java/com/couchbase/client/java/CouchbaseAsyncBucket.java -> need to specify the type with a <GetResponse> construct, and ide complains if not after a dot, thus this (unless I'm missing a suitable syntax)

Line:241, src/main/java/com/couchbase/client/java/CouchbaseAsyncBucket.java -> fail fast, call failure condition check once.
skipped lines below include an else statement and ultimate manipulation of the observable produced by either conditional branch, all of which is unneeded if bucket is closed.

-------------------------------------
author: Cory Peck
date: 2014-10-15 18:04:52.047000000

Patch Set 2: Code-Review+2

-------------------------------------
author: Natasha Sullivan
date: 2014-10-16 05:02:14.458000000

Patch Set 2: Code-Review-1

Great, I like that much more :)

One thing though:

can you add some integration tests (probably to the connection test ones) where you close a bucket and then run an op and verify (once async and one sync) that it correctly throws?

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