1

I have a springBoot 2.1.9.RELEASE application that uses Spring Data for Couchbase But when I use the Atomic counters in Couchbase to Increment a counter with 1

bucket.counter(doc.getId(), 1);

I got an exception

com.couchbase.client.core.CouchbaseException: INVALID_ARGUMENTS
...Caused by: rx.exceptions.OnErrorThrowable$OnNextValue: OnError while emitting onNext value: com.couchbase.client.core.message.kv.CounterResponse.class
    at rx.exceptions.OnErrorThrowable.addValueAsLastCause(OnErrorThrowable.java:118)
    at rx.internal.operators.OnSubscribeMap$MapSubscriber.onNext(OnSubscribeMap.java:73)
    ... 22 common frames omitted

I also have tried

try {
            bucket.counter(docId, 1);
        } catch (CouchbaseException e) {
            if ("INVALID_ARGUMENTS".equalsIgnoreCase(e.getMessage())) {
                LegacyDocument legacyDocument = rqmBucket.get(LegacyDocument.create(docId));
                String s = legacyDocument.content().toString();
                Long value = Long.parseLong(s) + 1;
                bucket.upsert(JsonLongDocument.create(docId, value));
            }
        }

but I got at a java.lang.NumberFormatException because legacyDocument.content() gives me all the Json doc. :

"{"hostel":{"address":15..."
Sandro Rey
  • 2,429
  • 13
  • 36
  • 80

0 Answers0