Index: oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/counter/NodeCounterEditor.java IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/counter/NodeCounterEditor.java (revision 1867178) +++ oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/counter/NodeCounterEditor.java (date 1568904620905) @@ -153,13 +153,17 @@ } } - public void leaveNew(NodeState before, NodeState after) throws CommitFailedException { + private void leaveNew(NodeState before, NodeState after) throws CommitFailedException { if (countOffsets.isEmpty()) { return; } root.callback.indexUpdate(); for (Map.Entry e : countOffsets.entrySet()) { - NodeBuilder builder = getBuilder(e.getKey()); + Mount mount = e.getKey(); + if (mount.isReadOnly()) { + continue; + } + NodeBuilder builder = getBuilder(mount); int countOffset = e.getValue(); PropertyState p = builder.getProperty(COUNT_HASH_PROPERTY_NAME); Index: oak-lucene/src/test/java/org/apache/jackrabbit/oak/composite/CompositeNodeStoreLuceneIndexTest.java IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- oak-lucene/src/test/java/org/apache/jackrabbit/oak/composite/CompositeNodeStoreLuceneIndexTest.java (revision 1867178) +++ oak-lucene/src/test/java/org/apache/jackrabbit/oak/composite/CompositeNodeStoreLuceneIndexTest.java (date 1568904126672) @@ -18,7 +18,6 @@ */ package org.apache.jackrabbit.oak.composite; - import com.google.common.collect.Lists; import org.apache.jackrabbit.api.JackrabbitSession; import org.apache.jackrabbit.oak.plugins.index.IndexConstants; @@ -47,7 +46,9 @@ import static org.apache.jackrabbit.oak.plugins.index.lucene.TestUtil.shutdown; import static org.hamcrest.CoreMatchers.containsString; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertThat; +import static org.junit.Assert.fail; @SuppressWarnings("ConstantConditions") public class CompositeNodeStoreLuceneIndexTest extends CompositeNodeStoreQueryTestBase { @@ -106,15 +107,39 @@ * with the same index node already existing in the read-only part already. */ @Test - public void addIndexInReadWriteWithIndexExistinginReadOnly() throws Exception { + public void addIndexInReadWriteWithIndexExistingReadOnly() throws Exception { + repoV1.setupIndexAndContentInRepo("luceneTest", "foo", true, VERSION_1); + repoV1.cleanup(); + } + + @Test + public void reindexCounterIndex() throws Exception { repoV1.setupIndexAndContentInRepo("luceneTest", "foo", true, VERSION_1); - repoV1.cleanup(); + try { + repoV1.setupIndexAndContentInRepo("luceneTest", "foo", true, VERSION_1); + fail(); + } catch (Exception e) { + Session s = repoV1.getSession(); + Node c = s.getRootNode().getNode(INDEX_DEFINITIONS_NAME).getNode("counter"); + + c.setProperty("async", (String) null); + c.setProperty("resolution", 1); + c.setProperty("reindex", true); + s.save(); + + // retrieve counter again (maybe not needed) + c = s.getRootNode().getNode(INDEX_DEFINITIONS_NAME).getNode("counter"); + + assertFalse(c.getProperty("reindex").getBoolean()); + } finally { + repoV1.cleanup(); + } } /** * Given a composite jcr repo with a lucene index with indexed data from both read only and read write parts * We create a V2 of this repo which will have the lucene index removed - - * Expected behaviour - The same query that returned resutls from both readonly + * Expected behaviour - The same query that returned results from both readonly * and readwrite in V1 should now return * results - but it would be a traversal query and not use the index . */ Index: oak-lucene/src/test/java/org/apache/jackrabbit/oak/composite/CompositeNodeStoreQueryTestBase.java IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- oak-lucene/src/test/java/org/apache/jackrabbit/oak/composite/CompositeNodeStoreQueryTestBase.java (revision 1867178) +++ oak-lucene/src/test/java/org/apache/jackrabbit/oak/composite/CompositeNodeStoreQueryTestBase.java (date 1568904337488) @@ -89,7 +89,7 @@ import org.jetbrains.annotations.Nullable; import org.junit.After; import org.junit.Before; -import org.junit.Rule; +import org.junit.ClassRule; import org.junit.rules.TemporaryFolder; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; @@ -134,8 +134,8 @@ protected IndexCopier indexCopier; protected Oak oak; - @Rule - public TemporaryFolder temporaryFolder = new TemporaryFolder(new File("target")); + @ClassRule + public final static TemporaryFolder TEMPORARY_FOLDER = new TemporaryFolder(new File("target")); @Parameters(name="Root: {0}, Mounts: {1}") public static Collection data() { @@ -242,7 +242,7 @@ return oak; } try { - indexCopier = new IndexCopier(executorService, temporaryFolder.getRoot()); + indexCopier = new IndexCopier(executorService, TEMPORARY_FOLDER.getRoot()); } catch (IOException e) { throw new RuntimeException(); } @@ -278,7 +278,7 @@ Oak getOakRepo(NodeStore store, MountInfoProvider mip) { try { - indexCopier = new IndexCopier(executorService, temporaryFolder.getRoot()); + indexCopier = new IndexCopier(executorService, TEMPORARY_FOLDER.getRoot()); } catch (IOException e) { throw new RuntimeException(); } @@ -412,7 +412,7 @@ } } - static enum NodeStoreKind { + enum NodeStoreKind { MEMORY { @Override public NodeStoreRegistration create(String name) { @@ -460,13 +460,12 @@ throw new IllegalStateException("instance already created"); } - // TODO - don't use Unix directory separators String directoryName = name != null ? "segment-" + name : "segment"; - storePath = new File("target/classes/" + directoryName); + storePath = TEMPORARY_FOLDER.newFolder(directoryName); //String blobStoreDirectoryName = name != null ? "blob-" + name : "blob"; String blobStoreDirectoryName = "blob" ; - blobStorePath = "target/classes/" + blobStoreDirectoryName; + blobStorePath = TEMPORARY_FOLDER.getRoot().getAbsolutePath() + blobStoreDirectoryName; BlobStore blobStore = new FileBlobStore(blobStorePath); @@ -501,7 +500,7 @@ @Override public NodeStore get() throws Exception { RDBOptions options = new RDBOptions().dropTablesOnClose(true); - String jdbcUrl = "jdbc:h2:file:./target/classes/document"; + String jdbcUrl = "jdbc:h2:file:" + TEMPORARY_FOLDER.getRoot().getAbsolutePath() + "/document"; if ( name != null ) { jdbcUrl += "-" + name; }