rishabhdaim commented on code in PR #920:
URL: https://github.com/apache/jackrabbit-oak/pull/920#discussion_r1194786003


##########
oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentStore.java:
##########
@@ -540,4 +542,33 @@ default <T extends Document> List<T> query(final 
Collection<T> collection,
             return newDocument;
         }).collect(Collectors.toList());
     }
+
+    /**
+     * Performs a conditional update (e.g. using
+     * {@link UpdateOp.Condition.Type#EXISTS} and only update the
+     * document if the condition is <code>true</code>. The returned documents 
are
+     * immutable.
+     * <p>
+     * In case of a {@code DocumentStoreException} (e.g. when a communication
+     * error occurs) only some updates may have been applied. In this case
+     * it is the responsibility of the caller to check which {@link UpdateOp}s
+     * were applied and take appropriate action. The implementation however 
ensures
+     * that the result of the operations are properly reflected in the document
+     * cache. That is, an implementation could simply evict the documents 
related
+     * to the given update operations from the cache.
+     *
+     * @param <T> the document type
+     * @param collection the collection
+     * @param updateOps the update operation List
+     * @return the list containing old documents or <code>null</code> if the 
condition is not met
+     *         or if the document wasn't found. The order in the result list 
reflects the order
+     *         in the updateOps parameter
+     * @throws DocumentStoreException if the operation failed. E.g. because of
+     *          an I/O error.
+     */
+    @NotNull
+    default <T extends Document> List<T> findAndUpdate(final @NotNull 
Collection<T> collection,
+                                                       final @NotNull 
List<UpdateOp> updateOps) throws DocumentStoreException {

Review Comment:
   I think it's a small step in the right direction (avoiding nulls) and 
instead of removing `@NotNull`here, we should create a new ticket to update the 
existing methods if possible.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to