[
https://issues.apache.org/jira/browse/OAK-7983?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16740194#comment-16740194
]
Vikas Saurabh commented on OAK-7983:
------------------------------------
[~teofili], while I kind of prefer revert but there's also an option to avoid
full revert but only disable lazy loading. The diff would look something like
this:
{noformat}
diff --git
a/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LucenePropertyIndex.java
b/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LucenePropertyIndex.java
index 4fa6dc652b..f726cfd68a 100644
---
a/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LucenePropertyIndex.java
+++
b/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LucenePropertyIndex.java
@@ -694,7 +694,7 @@ public class LucenePropertyIndex extends FulltextIndex {
@Override
protected LazyLuceneIndexNode acquireIndexNode(String indexPath) {
- return new LazyLuceneIndexNode(tracker, indexPath);
+ return LazyLuceneIndexNode.getLazyNodeOrNull(tracker, indexPath);
}
@Override
@@ -1565,12 +1565,21 @@ public class LucenePropertyIndex extends FulltextIndex {
*/
static class LazyLuceneIndexNode implements LuceneIndexNode {
- private static boolean NON_LAZY =
Boolean.getBoolean("oak.lucene.nonLazyIndex");
+ private static boolean NON_LAZY =
Boolean.parseBoolean(System.getProperty("oak.lucene.nonLazyIndex", "true"));
private AtomicBoolean released = new AtomicBoolean();
private IndexTracker tracker;
private String indexPath;
private volatile LuceneIndexNode indexNode;
+ static LazyLuceneIndexNode getLazyNodeOrNull(IndexTracker tracker,
String indexPath) {
+ LazyLuceneIndexNode ret = new LazyLuceneIndexNode(tracker,
indexPath);
+ if (NON_LAZY && ret.getIndexNode() == null) {
+ return null;
+ }
+
+ return ret;
+ }
+
LazyLuceneIndexNode(IndexTracker tracker, String indexPath) {
this.tracker = tracker;
this.indexPath = indexPath;
{noformat}
Do note, that simply setting {{true}} to {{oak.lucene.nonLazyIndex}} system
property wouldn't have sufficed.
> LazyLuceneIndexNode#getIndexNode can cause NPE
> ----------------------------------------------
>
> Key: OAK-7983
> URL: https://issues.apache.org/jira/browse/OAK-7983
> Project: Jackrabbit Oak
> Issue Type: Bug
> Components: lucene
> Affects Versions: 1.9.13
> Reporter: Tommaso Teofili
> Priority: Major
> Attachments: OAK-7983.0.patch
>
>
> Changes for OAK-7947 have introduced a LazyLuceneIndexNode. Its methods call
> for IndexTracker#findIndexNode and #acquireIndexNode which can return `null`,
> however no proper checks are performed.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)