This is an automated email from the ASF dual-hosted git repository.

thomasm pushed a commit to branch OAK-10518
in repository https://gitbox.apache.org/repos/asf/jackrabbit-oak.git


The following commit(s) were added to refs/heads/OAK-10518 by this push:
     new f40b18c9ad OAK-10518 IndexInfo should have a isActive() method
f40b18c9ad is described below

commit f40b18c9ad5be11fd97d433637933f7442ef0c5c
Author: Thomas Mueller <[email protected]>
AuthorDate: Thu Oct 26 10:27:17 2023 +0200

    OAK-10518 IndexInfo should have a isActive() method
---
 .../oak/plugins/index/IndexInfoServiceImpl.java    |  4 +++-
 .../composite/blueGreen/CustomizedIndexTest.java   | 27 ++++++++++++++--------
 .../plugins/index/search/spi/query/IndexName.java  |  1 +
 3 files changed, 21 insertions(+), 11 deletions(-)

diff --git 
a/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexInfoServiceImpl.java
 
b/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexInfoServiceImpl.java
index 507350edd8..c263bc767a 100644
--- 
a/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexInfoServiceImpl.java
+++ 
b/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexInfoServiceImpl.java
@@ -76,7 +76,9 @@ public class IndexInfoServiceImpl implements IndexInfoService{
             public IndexInfo apply(String indexPath) {
                 try {
                     IndexInfo info = getInfo(indexPath);
-                    info.setActive(activeIndexes.contains(indexPath));
+                    if (info != null) {
+                        info.setActive(activeIndexes.contains(indexPath));
+                    }
                     return info;
                 } catch (Exception e) {
                     log.warn("Error occurred while capturing IndexInfo for 
path {}", indexPath, e);
diff --git 
a/oak-lucene/src/test/java/org/apache/jackrabbit/oak/composite/blueGreen/CustomizedIndexTest.java
 
b/oak-lucene/src/test/java/org/apache/jackrabbit/oak/composite/blueGreen/CustomizedIndexTest.java
index 21cc263682..3eac5e3399 100644
--- 
a/oak-lucene/src/test/java/org/apache/jackrabbit/oak/composite/blueGreen/CustomizedIndexTest.java
+++ 
b/oak-lucene/src/test/java/org/apache/jackrabbit/oak/composite/blueGreen/CustomizedIndexTest.java
@@ -23,6 +23,7 @@ import static org.junit.Assert.assertEquals;
 import java.io.File;
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.Collections;
 
 import javax.jcr.Node;
@@ -91,13 +92,19 @@ public class CustomizedIndexTest {
     private void compositeLibs1() throws Exception {
         Persistence p = Persistence.openComposite(globalDir, libs1Dir, config);
         IndexUtils.checkLibsIsReadOnly(p);
+        assertEquals("[/oak:index/lucene]",
+                getActiveLuceneIndexes(p).toString());
+        
p.session.getRootNode().getNode("oak:index").getNode("lucene").remove();
+        p.session.save();
+        assertEquals("[]",
+                getActiveLuceneIndexes(p).toString());
         IndexUtils.createIndex(p, "test-1", "foo", 10);
         IndexUtils.assertQueryUsesIndexAndReturns(p,
                 "/jcr:root//*[@foo] order by @jcr:path",
                 "test-1",
                 "[/content/test, /libs/test]");
-        assertEquals("[/oak:index/lucene, /oak:index/test-1]",
-                getActiveLuceneIndexes(p));
+        assertEquals("[/oak:index/test-1]",
+                getActiveLuceneIndexes(p).toString());
         p.close();
     }
 
@@ -113,7 +120,7 @@ public class CustomizedIndexTest {
                 "test-2",
                 "[/content/test, /libs/test2]");
         assertEquals("[/oak:index/lucene, /oak:index/test-2]",
-                getActiveLuceneIndexes(p));
+                getActiveLuceneIndexes(p).toString());
         p.close();
 
         // the new index must not be used in the old version (with libs1)
@@ -123,7 +130,7 @@ public class CustomizedIndexTest {
                 "test-1",
                 "[/content/test, /libs/test]");
         assertEquals("[/oak:index/lucene, /oak:index/test-1]",
-                getActiveLuceneIndexes(p));
+                getActiveLuceneIndexes(p).toString());
         p.close();
     }
 
@@ -146,7 +153,7 @@ public class CustomizedIndexTest {
                 "test-2-custom-1",
                 "[/content/test]");
         assertEquals("[/oak:index/lucene, /oak:index/test-2-custom-1]",
-                getActiveLuceneIndexes(p));
+                getActiveLuceneIndexes(p).toString());
         p.close();
 
         // the merged index is not used in the old version (with libs1)
@@ -167,7 +174,7 @@ public class CustomizedIndexTest {
                 "test-2-custom-1",
                 "[/content/test]");
         assertEquals("[/oak:index/lucene, /oak:index/test-2-custom-1]",
-                getActiveLuceneIndexes(p));
+                getActiveLuceneIndexes(p).toString());
         p.close();
     }
 
@@ -221,7 +228,7 @@ public class CustomizedIndexTest {
                 "test-3-custom-1",
                 "[/content/test]");
         assertEquals("[/oak:index/lucene, /oak:index/test-3-custom-1]",
-                getActiveLuceneIndexes(p));
+                getActiveLuceneIndexes(p).toString());
     }
 
     private void createFolders() throws IOException {
@@ -233,11 +240,11 @@ public class CustomizedIndexTest {
         indexDir = tempDir.newFolder("index");
     }
 
-    private static String getActiveLuceneIndexes(Persistence p) {
+    private static Collection<String> getActiveLuceneIndexes(Persistence p) {
         return getActiveLuceneIndexes(p.getCompositeNodestore(), 
p.getMountInfoProvider());
     }
 
-    private static String getActiveLuceneIndexes(NodeStore ns, 
MountInfoProvider m) {
+    private static Collection<String> getActiveLuceneIndexes(NodeStore ns, 
MountInfoProvider m) {
         ArrayList<String> list = new ArrayList<>();
         IndexInfoServiceImpl indexService = new IndexInfoServiceImpl(ns,
                 new IndexPathServiceImpl(ns, m));
@@ -251,7 +258,7 @@ public class CustomizedIndexTest {
             list.add(info.getIndexPath());
         }
         Collections.sort(list);
-        return list.toString();
+        return list;
     }
 
 }
diff --git 
a/oak-search/src/main/java/org/apache/jackrabbit/oak/plugins/index/search/spi/query/IndexName.java
 
b/oak-search/src/main/java/org/apache/jackrabbit/oak/plugins/index/search/spi/query/IndexName.java
index 303a665fd2..b19fb0f174 100644
--- 
a/oak-search/src/main/java/org/apache/jackrabbit/oak/plugins/index/search/spi/query/IndexName.java
+++ 
b/oak-search/src/main/java/org/apache/jackrabbit/oak/plugins/index/search/spi/query/IndexName.java
@@ -36,6 +36,7 @@ import org.slf4j.LoggerFactory;
  * @deprecated
  * Use oak-core org.apache.jackrabbit.oak.plugins.index.IndexName instead.
  */
+@Deprecated(since = "1.60.0", forRemoval = true)
 public class IndexName implements Comparable<IndexName> {
 
     private final static Logger LOG = LoggerFactory.getLogger(IndexName.class);

Reply via email to