You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by re...@apache.org on 2026/04/28 11:57:04 UTC
(jackrabbit-oak) 01/01: OAK-12198: test that findAndUpdate does not return stale document
This is an automated email from the ASF dual-hosted git repository.
reschke pushed a commit to branch OAK-12198
in repository https://gitbox.apache.org/repos/asf/jackrabbit-oak.git
commit 451b674c32f0824f221a1df21a152604592ad8b8
Author: Julian Reschke <ju...@gmx.de>
AuthorDate: Tue Apr 28 12:56:43 2026 +0100
OAK-12198: test that findAndUpdate does not return stale document
---
.../plugins/document/BasicDocumentStoreTest.java | 27 ++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/BasicDocumentStoreTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/BasicDocumentStoreTest.java
index e41b250c67..c0021d6825 100644
--- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/BasicDocumentStoreTest.java
+++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/BasicDocumentStoreTest.java
@@ -1329,6 +1329,33 @@ public class BasicDocumentStoreTest extends AbstractDocumentStoreTest {
assertNull(ds.getIfCached(Collection.NODES, id));
}
+ @Test
+ public void correctVersionOfDocumentAfterWritingThroughCache() {
+ String id = Utils.getIdFromPath("/cacheMeCorrectly");
+
+ String prop1 = "foo", prop2 = "bar";
+
+ // create test document
+ UpdateOp up = new UpdateOp(id, true);
+ up.set(prop1, "17");
+ ds.create(Collection.NODES, List.of(up));
+
+ // read back
+ NodeDocument testDoc = ds.find(Collection.NODES, id);
+ assertNotNull("test doc not found", testDoc);
+ assertNull("test prop " + prop2 + " should not be present", testDoc.get(prop2));
+
+ // add test prop
+ UpdateOp up2 = new UpdateOp(id, true);
+ up2.set(prop2, "42");
+ ds.findAndUpdate(Collection.NODES, up2);
+
+ // verify
+ NodeDocument testDoc2 = ds.find(Collection.NODES, id);
+ assertNotNull("test doc not found", testDoc2);
+ assertNotNull("test prop " + prop1 + " should be present", testDoc2.get(prop2));
+ }
+
private UpdateOp newDocument(String path, long modified) {
String id = Utils.getIdFromPath(path);
UpdateOp op = new UpdateOp(id, true);