You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-dev@jackrabbit.apache.org by "reschke (via GitHub)" <gi...@apache.org> on 2025/04/11 07:15:21 UTC
[PR] OAK-11654: Remove usage of Guava Suppliers.ofInstance [jackrabbit-oak]
reschke opened a new pull request, #2224:
URL: https://github.com/apache/jackrabbit-oak/pull/2224
(no comment)
--
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: oak-dev-unsubscribe@jackrabbit.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] OAK-11654: Remove usage of Guava Suppliers.ofInstance [jackrabbit-oak]
Posted by "reschke (via GitHub)" <gi...@apache.org>.
reschke commented on code in PR #2224:
URL: https://github.com/apache/jackrabbit-oak/pull/2224#discussion_r2039179901
##########
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:
It might be caused that the same instance is expected, but it needs to be created later on; thus `memoize()` - trying that right now.
--
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: oak-dev-unsubscribe@jackrabbit.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] OAK-11654: Remove usage of Guava Suppliers.ofInstance [jackrabbit-oak]
Posted by "reschke (via GitHub)" <gi...@apache.org>.
reschke commented on code in PR #2224:
URL: https://github.com/apache/jackrabbit-oak/pull/2224#discussion_r2039089167
##########
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:
Strange. This change is causing the test failures. What is going on here???
cc @mbaedke @rishabhdaim @thomasmueller
--
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: oak-dev-unsubscribe@jackrabbit.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] OAK-11654: Remove usage of Guava Suppliers.ofInstance [jackrabbit-oak]
Posted by "rishabhdaim (via GitHub)" <gi...@apache.org>.
rishabhdaim commented on code in PR #2224:
URL: https://github.com/apache/jackrabbit-oak/pull/2224#discussion_r2041650628
##########
oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreBuilder.java:
##########
@@ -534,13 +534,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:
okk, got it, thanks
--
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: oak-dev-unsubscribe@jackrabbit.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] OAK-11654: Remove usage of Guava Suppliers.ofInstance [jackrabbit-oak]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #2224:
URL: https://github.com/apache/jackrabbit-oak/pull/2224#issuecomment-2796056404
# Commit-Check ✔️
--
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: oak-dev-unsubscribe@jackrabbit.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] OAK-11654: Remove usage of Guava Suppliers.ofInstance [jackrabbit-oak]
Posted by "reschke (via GitHub)" <gi...@apache.org>.
reschke commented on code in PR #2224:
URL: https://github.com/apache/jackrabbit-oak/pull/2224#discussion_r2039238431
##########
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:
Maybe:
~~~
private DocumentStore memoizedDocumentStore = null;
protected Supplier<DocumentStore> documentStoreSupplier = () -> memoizedDocumentStore = Objects.requireNonNullElse(memoizedDocumentStore, new MemoryDocumentStore());
~~~
--
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: oak-dev-unsubscribe@jackrabbit.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] OAK-11654: Remove usage of Guava Suppliers.ofInstance [jackrabbit-oak]
Posted by "reschke (via GitHub)" <gi...@apache.org>.
reschke merged PR #2224:
URL: https://github.com/apache/jackrabbit-oak/pull/2224
--
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: oak-dev-unsubscribe@jackrabbit.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] OAK-11654: Remove usage of Guava Suppliers.ofInstance [jackrabbit-oak]
Posted by "reschke (via GitHub)" <gi...@apache.org>.
reschke commented on code in PR #2224:
URL: https://github.com/apache/jackrabbit-oak/pull/2224#discussion_r2039156144
##########
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:
I tried that and that did not solve the problem.
--
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: oak-dev-unsubscribe@jackrabbit.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] OAK-11654: Remove usage of Guava Suppliers.ofInstance [jackrabbit-oak]
Posted by "reschke (via GitHub)" <gi...@apache.org>.
reschke commented on code in PR #2224:
URL: https://github.com/apache/jackrabbit-oak/pull/2224#discussion_r2041628475
##########
oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreBuilder.java:
##########
@@ -534,13 +534,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:
Why? It seems that although this looks similar, the actual requirements are different.
--
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: oak-dev-unsubscribe@jackrabbit.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] OAK-11654: Remove usage of Guava Suppliers.ofInstance [jackrabbit-oak]
Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #2224:
URL: https://github.com/apache/jackrabbit-oak/pull/2224#issuecomment-2796652814
## [](https://sonarcloud.io/dashboard?id=org.apache.jackrabbit%3Ajackrabbit-oak&pullRequest=2224) **Quality Gate passed**
Issues
 [4 New issues](https://sonarcloud.io/project/issues?id=org.apache.jackrabbit%3Ajackrabbit-oak&pullRequest=2224&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [0 Accepted issues](https://sonarcloud.io/project/issues?id=org.apache.jackrabbit%3Ajackrabbit-oak&pullRequest=2224&issueStatuses=ACCEPTED)
Measures
 [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=org.apache.jackrabbit%3Ajackrabbit-oak&pullRequest=2224&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [100.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=org.apache.jackrabbit%3Ajackrabbit-oak&pullRequest=2224&metric=new_coverage&view=list)
 [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=org.apache.jackrabbit%3Ajackrabbit-oak&pullRequest=2224&metric=new_duplicated_lines_density&view=list)
[See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=org.apache.jackrabbit%3Ajackrabbit-oak&pullRequest=2224)
--
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: oak-dev-unsubscribe@jackrabbit.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] OAK-11654: Remove usage of Guava Suppliers.ofInstance [jackrabbit-oak]
Posted by "reschke (via GitHub)" <gi...@apache.org>.
reschke commented on code in PR #2224:
URL: https://github.com/apache/jackrabbit-oak/pull/2224#discussion_r2039135985
##########
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:
Apparently because it gets overwritten in other classes. Backing out this change, but I still don't get what's wrong here.
@mreutegg maybe?
--
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: oak-dev-unsubscribe@jackrabbit.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] OAK-11654: Remove usage of Guava Suppliers.ofInstance [jackrabbit-oak]
Posted by "reschke (via GitHub)" <gi...@apache.org>.
reschke commented on code in PR #2224:
URL: https://github.com/apache/jackrabbit-oak/pull/2224#discussion_r2039154485
##########
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:
I prefer return statements at the same identation level.
--
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: oak-dev-unsubscribe@jackrabbit.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] OAK-11654: Remove usage of Guava Suppliers.ofInstance [jackrabbit-oak]
Posted by "reschke (via GitHub)" <gi...@apache.org>.
reschke commented on code in PR #2224:
URL: https://github.com/apache/jackrabbit-oak/pull/2224#discussion_r2039158040
##########
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:
yes, that code is similar but it does not appear to have test coverage...
--
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: oak-dev-unsubscribe@jackrabbit.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] OAK-11654: Remove usage of Guava Suppliers.ofInstance [jackrabbit-oak]
Posted by "reschke (via GitHub)" <gi...@apache.org>.
reschke commented on code in PR #2224:
URL: https://github.com/apache/jackrabbit-oak/pull/2224#discussion_r2039238431
##########
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:
Maybe:
~~~
private DocumentStore memoizedDocumentStore = null;
protected Supplier<DocumentStore> documentStoreSupplier = () -> memoizedDocumentStore = Objects.requireNonNullElse(memoizedDocumentStore, new MemoryDocumentStore());
~~~
This might be the shortest way to do that just with JDK, at least for simple cases.
We have roughly 10 non-case uses of `memoize` - so we'll have to discuss how to adress these.
--
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: oak-dev-unsubscribe@jackrabbit.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] OAK-11654: Remove usage of Guava Suppliers.ofInstance [jackrabbit-oak]
Posted by "rishabhdaim (via GitHub)" <gi...@apache.org>.
rishabhdaim commented on code in PR #2224:
URL: https://github.com/apache/jackrabbit-oak/pull/2224#discussion_r2041075881
##########
oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreBuilder.java:
##########
@@ -534,13 +534,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:
It should be replaced with `memoize` as well.
--
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: oak-dev-unsubscribe@jackrabbit.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] OAK-11654: Remove usage of Guava Suppliers.ofInstance [jackrabbit-oak]
Posted by "rishabhdaim (via GitHub)" <gi...@apache.org>.
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: oak-dev-unsubscribe@jackrabbit.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] OAK-11654: Remove usage of Guava Suppliers.ofInstance [jackrabbit-oak]
Posted by "reschke (via GitHub)" <gi...@apache.org>.
reschke commented on code in PR #2224:
URL: https://github.com/apache/jackrabbit-oak/pull/2224#discussion_r2039171535
##########
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:
Try:
~~~
diff --git a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreBuilder.java b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreBuilder.java
index 884ce2d881..4d760bedcc 100644
--- a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreBuilder.java
+++ b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreBuilder.java
@@ -35,7 +35,6 @@ import java.util.concurrent.TimeUnit;
import java.util.function.Predicate;
import java.util.function.Supplier;
-import org.apache.jackrabbit.guava.common.base.Suppliers;
import org.apache.jackrabbit.guava.common.cache.Cache;
import org.apache.jackrabbit.guava.common.cache.CacheBuilder;
import org.apache.jackrabbit.guava.common.cache.RemovalCause;
@@ -117,8 +116,10 @@ public class DocumentNodeStoreBuilder<T extends DocumentNodeStoreBuilder<T>> {
*/
static final int UPDATE_LIMIT = Integer.getInteger("update.limit", DEFAULT_UPDATE_LIMIT);
- protected Supplier<DocumentStore> documentStoreSupplier = Suppliers.ofInstance(new MemoryDocumentStore());
- protected Supplier<BlobStore> blobStoreSupplier;
+ private static DocumentStore defaultDocumentStore = new MemoryDocumentStore();
+ protected Supplier<DocumentStore> documentStoreSupplier = () -> defaultDocumentStore;
+ private static BlobStore defaultBlobStore = new MemoryBlobStore();
+ protected Supplier<BlobStore> blobStoreSupplier = () -> defaultBlobStore;
private DiffCache diffCache;
private int clusterId = Integer.getInteger("oak.documentMK.clusterId", 0);
private int asyncDelay = 1000;
@@ -539,9 +540,6 @@ public class DocumentNodeStoreBuilder<T extends DocumentNodeStoreBuilder<T>> {
}
public BlobStore getBlobStore() {
- if (blobStoreSupplier == null) {
- blobStoreSupplier = () -> new MemoryBlobStore();
- }
BlobStore blobStore = blobStoreSupplier.get();
configureBlobStore(blobStore);
return blobStore;
~~~
--
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: oak-dev-unsubscribe@jackrabbit.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] OAK-11654: Remove usage of Guava Suppliers.ofInstance [jackrabbit-oak]
Posted by "reschke (via GitHub)" <gi...@apache.org>.
reschke commented on code in PR #2224:
URL: https://github.com/apache/jackrabbit-oak/pull/2224#discussion_r2039238431
##########
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:
Maybe:
~~~
private DocumentStore memoizedDocumentStore = null;
protected Supplier<DocumentStore> documentStoreSupplier = () -> memoizedDocumentStore = Objects.requireNonNullElse(memoizedDocumentStore, new MemoryDocumentStore());
~~~
This might be the shortest way to do that just with JDK, at least for simple cases.
We have roughly 10 non-case uses of `memoize` - so we'll have to discuss how to address these.
--
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: oak-dev-unsubscribe@jackrabbit.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] OAK-11654: Remove usage of Guava Suppliers.ofInstance [jackrabbit-oak]
Posted by "reschke (via GitHub)" <gi...@apache.org>.
reschke commented on code in PR #2224:
URL: https://github.com/apache/jackrabbit-oak/pull/2224#discussion_r2041702245
##########
oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreBuilder.java:
##########
@@ -534,13 +534,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:
ack :-)
--
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: oak-dev-unsubscribe@jackrabbit.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org