[JCBC-181] Misleading exception when replica server not found Created: 13/Dec/12  Updated: 31/Jan/13  Resolved: 31/Jan/13

Status: Resolved
Project: Couchbase Java Client
Component/s: Core
Affects Version/s: 1.1.0
Fix Version/s: 1.1.2
Security Level: Public

Type: Improvement Priority: Minor
Reporter: schp Assignee: Michael Nitschinger
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates JCBC-223 Cannot use Persist.ONE/MASTER on a si... Resolved

 Description   
If the number of Couchbase servers is not enough to provide the required number of replicas (e.g. when installing a stand-alone server and forgetting to uncheck the 'Enable replicas' option), observe throws an ArrayIndexOutOfBoundsException. An exception with a more descriptive name would indicate the error cause more clearly.

An example stack trace:

ArrayIndexOutOfBoundsException: -1
     java.util.ArrayList.elementData(ArrayList.java:371)
     java.util.ArrayList.get(ArrayList.java:384)
     com.couchbase.client.vbucket.config.DefaultConfig.getServer(DefaultConfig.java:81)
     com.couchbase.client.vbucket.VBucketNodeLocator.getServerByIndex(VBucketNodeLocator.java:112)
     com.couchbase.client.CouchbaseClient.observe(CouchbaseClient.java:1621)
     com.couchbase.client.CouchbaseClient.observePoll(CouchbaseClient.java:1750)
     com.couchbase.client.CouchbaseClient.set(CouchbaseClient.java:1199)
     ...
Generated at Thu Sep 18 18:49:10 CDT 2014 using JIRA 5.2.4#845-sha1:c9f4cc41abe72fb236945343a1f485c2c844dac9.