Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
None
Description
The function below has a bug:
@Override public <K, V> boolean replace(AtomicCacheEntry<K, V, Long> entry, Serializer<K> keySerializer, Serializer<V> valueSerializer) throws IOException { final Long revision = entry.getRevision().orElse(0L); final String docId = toDocumentId(entry.getKey(), keySerializer); final Document doc = toDocument(docId, entry.getValue(), valueSerializer, revision); try { if (revision < 0) { // If the document does not exist yet, try to create one. try { bucket.insert(doc); return true; } catch (DocumentAlreadyExistsException e) { return false; }
final Long revision = entry.getRevision().orElse(0L);
should be
final Long revision = entry.getRevision().orElse(-1L);
otherwise a new document never gets created in the check
if (revision < 0) { // If the document does not exist yet, try to create one. try { bucket.insert(doc); return true; } catch (DocumentAlreadyExistsException e) { return false; }
I have tested the code change locally and it works properly...
--John