rishabhdaim commented on code in PR #2224:
URL: https://github.com/apache/jackrabbit-oak/pull/2224#discussion_r2039124628
##########
oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreBuilder.java:
##########
@@ -534,13 +533,13 @@ public DiffCache getDiffCache(int clusterId) {
* @return this
*/
public T setBlobStore(BlobStore blobStore) {
- this.blobStoreSupplier = ofInstance(blobStore);
+ this.blobStoreSupplier = () -> blobStore;
return thisBuilder();
}
public BlobStore getBlobStore() {
if (blobStoreSupplier == null) {
- blobStoreSupplier = ofInstance(new MemoryBlobStore());
+ blobStoreSupplier = () -> new MemoryBlobStore();
Review Comment:
```suggestion
private final BlobStore mbs = new MemoryBlobStore(); // create
at instance level
blobStoreSupplier = () -> mbs;
```
##########
oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStore.java:
##########
@@ -3803,11 +3801,11 @@ protected void execute(@NotNull DocumentNodeStore
nodeStore) {
}
private static Supplier<Integer> getDelay(DocumentNodeStore ns) {
- int delay = 0;
if (ns.getAsyncDelay() != 0) {
- delay = (int) SECONDS.toMillis(MODIFIED_IN_SECS_RESOLUTION);
+ return () -> (int)
SECONDS.toMillis(MODIFIED_IN_SECS_RESOLUTION);
+ } {
Review Comment:
`{` around second `return` call unnecessary.
##########
oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreBuilder.java:
##########
@@ -534,13 +533,13 @@ public DiffCache getDiffCache(int clusterId) {
* @return this
*/
public T setBlobStore(BlobStore blobStore) {
- this.blobStoreSupplier = ofInstance(blobStore);
+ this.blobStoreSupplier = () -> blobStore;
return thisBuilder();
}
public BlobStore getBlobStore() {
if (blobStoreSupplier == null) {
- blobStoreSupplier = ofInstance(new MemoryBlobStore());
+ blobStoreSupplier = () -> new MemoryBlobStore();
Review Comment:
same issue could happen here, we need to create an instance of `new
MemoryBlobStore` at instance level and pass that value in the `Supplier` lambda
expression.
##########
oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreBuilder.java:
##########
@@ -117,7 +116,7 @@ public class DocumentNodeStoreBuilder<T extends
DocumentNodeStoreBuilder<T>> {
*/
static final int UPDATE_LIMIT = Integer.getInteger("update.limit",
DEFAULT_UPDATE_LIMIT);
- protected Supplier<DocumentStore> documentStoreSupplier = ofInstance(new
MemoryDocumentStore());
+ protected Supplier<DocumentStore> documentStoreSupplier = () -> new
MemoryDocumentStore();
Review Comment:
This could be happening because `ofInstance(new MemoryDocumentStore())`
returns the same value but `() -> new MemoryDocumentStore()` returns an new
value of MemoryDocumentStore.
please check the below test where it fails for `documentStoreSupplier`.
> @Test
public void test() {
Supplier<DocumentStore> supplier = Suppliers.ofInstance(new
MemoryDocumentStore());
Supplier<DocumentStore> documentStoreSupplier = () -> new
MemoryDocumentStore();
Assert.assertTrue(supplier.get() == supplier.get());
Assert.assertTrue(documentStoreSupplier.get() ==
documentStoreSupplier.get());
}
##########
oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreBuilder.java:
##########
@@ -117,7 +116,7 @@ public class DocumentNodeStoreBuilder<T extends
DocumentNodeStoreBuilder<T>> {
*/
static final int UPDATE_LIMIT = Integer.getInteger("update.limit",
DEFAULT_UPDATE_LIMIT);
- protected Supplier<DocumentStore> documentStoreSupplier = ofInstance(new
MemoryDocumentStore());
+ protected Supplier<DocumentStore> documentStoreSupplier = () -> new
MemoryDocumentStore();
Review Comment:
```suggestion
private final DocumentStore ds = new MemoryDocumentStore();
protected Supplier<DocumentStore> documentStoreSupplier = () -> ds;
```
--
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]