JavaSDK CouchbaseClient.incr throws 'Non-numeric server-side value for inc or decr' error

I’m using getting an error ‘Non-numeric server-side value for inc or decr’ while incr a counter using Java SDK 1.4.2. Here’s the test code:

  couchbaseClient.set("counterTest", 100);
  couchbaseClient.incr("counterTest", 1, 0);

call stack:
Thread [Memcached IO over {MemcachedConnection to localhost/}] (Suspended (breakpoint at line 1761 in MemcachedClient$11))
owns: MutatorOperationImpl (id=52)
MemcachedClient$11.receivedStatus(OperationStatus) line: 1761
MutatorOperationImpl(OperationImpl).finishedPayload(byte[]) line: 212
MutatorOperationImpl(OperationImpl).readPayloadFromBuffer(ByteBuffer) line: 196
MutatorOperationImpl(OperationImpl).readFromBuffer(ByteBuffer) line: 139
CouchbaseConnection(MemcachedConnection).readBufferAndLogMetrics(Operation, ByteBuffer, MemcachedNode) line: 860
CouchbaseConnection(MemcachedConnection).handleReads(MemcachedNode) line: 839
CouchbaseConnection(MemcachedConnection).handleReadsAndWrites(SelectionKey, MemcachedNode) line: 719
CouchbaseConnection(MemcachedConnection).handleIO(SelectionKey) line: 682
CouchbaseConnection(MemcachedConnection).handleIO() line: 436 line: 321

What’s wrong with the code? Is it an encoding issue?


Using IntegerTranscoder gives the same result:

couchbaseClient.set(“counterTest”, 0, 100, new IntegerTranscoder());
couchbaseClient.incr(“counterTest”, 1, 0);

Can anyone help?



I could not reproduce this. I advise you to initialize your counter using the incr method instead of the set method.

I would probably do this instead:

couchbaseClient.incr(“counterTest”, 0, 100);
couchbaseClient.incr(“counterTest”, 1);

Is there a reason why you want to use set?
Also can you tell me which version of Couchbase and what kind of bucket you are using?