Couchbase Java SDK: 3.2.2
Getting the below runtime exception
com.couchbase.client.core.error.EncodingFailureException: Serializing of content + GetResult{content={"executionDate":"04/02/2022", "type":"batch"}, flags=0x2000000, cas=.....,} to JSON failed
in the below line of code
couchbaseDB.getActiveBucket().getDefaultCollection().replace(key, result);
Can somebody help
@mehak28 you cannot pass the full GetResult into the replace operation - you need to just send the content of the result.
String id = "airline_10";
GetResult result = collection.get(id);
JsonObject content = result.contentAsObject();
content.put("modified", "mymodifiedvalue");
collection.replace(id, content, replaceOptions().cas(result.cas()));
You don’t need to send the cas if you don’t care if someone else modified the same doc in the meantime.
1 Like
Thanks @daschl , it solved my problem.