Author: reschke
Date: Thu Apr 11 07:11:41 2019
New Revision: 1857299
URL: http://svn.apache.org/viewvc?rev=1857299&view=rev
Log:
OAK-8207: Read-only DocumentNodeStore tries to create root document (ported to
1.0)
Modified:
jackrabbit/oak/branches/1.10/ (props changed)
jackrabbit/oak/branches/1.10/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStore.java
jackrabbit/oak/branches/1.10/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreTest.java
Propchange: jackrabbit/oak/branches/1.10/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Apr 11 07:11:41 2019
@@ -1,3 +1,3 @@
/jackrabbit/oak/branches/1.0:1665962
-/jackrabbit/oak/trunk:1850874,1850882,1851236,1851253,1851451,1851533-1851535,1851619,1852052,1852084,1852120,1852451,1852492-1852493,1852528,1852582,1852584,1852601,1852920,1853141,1853229,1853393,1853429,1853433,1853441,1853866,1853868,1853870,1853893,1853969,1853997,1854034,1854044,1854055,1854058,1854113,1854373,1854377,1854380,1854385,1854401,1854403,1854455,1854461-1854462,1854466,1854468,1854515,1854533,1854539,1854701,1854773-1854774,1854827,1854848,1854859,1854930,1854990-1854991,1855032,1855221,1855477-1855478,1855776,1857010,1857104,1857159,1857253,1857294
+/jackrabbit/oak/trunk:1850874,1850882,1851236,1851253,1851451,1851533-1851535,1851619,1852052,1852084,1852120,1852451,1852492-1852493,1852528,1852582,1852584,1852601,1852920,1853141,1853229,1853393,1853429,1853433,1853441,1853866,1853868,1853870,1853893,1853969,1853997,1854034,1854044,1854055,1854058,1854113,1854373,1854377,1854380,1854385,1854401,1854403,1854455,1854461-1854462,1854466,1854468,1854515,1854533,1854539,1854701,1854773-1854774,1854827,1854848,1854859,1854930,1854990-1854991,1855032,1855221,1855477-1855478,1855776,1857010,1857104,1857159,1857212,1857238,1857253,1857294
/jackrabbit/trunk:1345480
Modified:
jackrabbit/oak/branches/1.10/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStore.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.10/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStore.java?rev=1857299&r1=1857298&r2=1857299&view=diff
==============================================================================
---
jackrabbit/oak/branches/1.10/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStore.java
(original)
+++
jackrabbit/oak/branches/1.10/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStore.java
Thu Apr 11 07:11:41 2019
@@ -614,6 +614,11 @@ public final class DocumentNodeStore
// check if root node exists
NodeDocument rootDoc = store.find(NODES, Utils.getIdFromPath("/"));
if (rootDoc == null) {
+ if (readOnlyMode) {
+ throw new DocumentStoreException("Unable to initialize a " +
+ "read-only DocumentNodeStore. The DocumentStore nodes
" +
+ "collection does not have a root document.");
+ }
// root node is missing: repository is not initialized
Revision commitRev = newRevision();
RevisionVector head = new RevisionVector(commitRev);
Modified:
jackrabbit/oak/branches/1.10/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreTest.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.10/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreTest.java?rev=1857299&r1=1857298&r2=1857299&view=diff
==============================================================================
---
jackrabbit/oak/branches/1.10/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreTest.java
(original)
+++
jackrabbit/oak/branches/1.10/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreTest.java
Thu Apr 11 07:11:41 2019
@@ -3853,6 +3853,19 @@ public class DocumentNodeStoreTest {
assertFalse(info.isActive());
}
+ @Test
+ public void readOnlyOnEmptyDocumentStore() {
+ DocumentStore store = new MemoryDocumentStore();
+ try {
+ builderProvider.newBuilder().setDocumentStore(store)
+ .setReadOnlyMode().build();
+ fail("must fail with DocumentStoreException");
+ } catch (Exception e) {
+ // must not hit last line of defence (ReadOnlyDocumentStoreWrapper)
+ assertFalse(Throwables.getRootCause(e) instanceof
UnsupportedOperationException);
+ }
+ }
+
private void getChildNodeCountTest(int numChildren,
Iterable<Long> maxValues,
Iterable<Long> expectedValues)