diff --git a/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/io/AutoSave.java b/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/io/AutoSave.java index 69d7109f0..29272bf0a 100644 --- a/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/io/AutoSave.java +++ b/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/io/AutoSave.java @@ -172,7 +172,7 @@ public void save(@Nullable Session session, boolean isIntermediate) throws Repos // either retry after some more nodes have been modified or after throttle // retry with next save() after another 10 nodes have been modified failedSaveThreshold = 10; - log.warn("Retry auto-save after {} modified nodes", failedSaveThreshold); + log.warn("Retry auto-save after {} more modified nodes", failedSaveThreshold); } } lastSave = numModified; @@ -201,7 +201,7 @@ private boolean saveWithBackoff(@NotNull Session session, boolean isIntermediate } } catch (RepositoryException e) { if (isPotentiallyTransientException(e) && isIntermediate) { - log.warn("could not auto-save due to potentially transient exception {}", e.getCause()); + log.warn("could not auto-save due to potentially transient exception {}", e.getCause().getMessage()); log.debug("auto save exception", e); return false; } else { diff --git a/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/io/Importer.java b/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/io/Importer.java index 3bb69fd46..8f0a32e28 100644 --- a/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/io/Importer.java +++ b/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/io/Importer.java @@ -844,7 +844,7 @@ private void commit(Session session, TxInfo info, LinkedList skipList) t } if (autoSave.needsSave()) { - autoSave.save(session, false); + autoSave.save(session, true); // this is only intermediate // save checkpoint cpTxInfo = info; cpAutosave = autoSave.copy(); diff --git a/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/ImportIT.java b/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/ImportIT.java index f439f8c51..595c81157 100644 --- a/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/ImportIT.java +++ b/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/ImportIT.java @@ -23,13 +23,20 @@ import java.io.IOException; import java.security.Principal; +import javax.jcr.AccessDeniedException; +import javax.jcr.InvalidItemStateException; +import javax.jcr.ItemExistsException; import javax.jcr.Node; +import javax.jcr.ReferentialIntegrityException; import javax.jcr.Repository; import javax.jcr.RepositoryException; import javax.jcr.Session; import javax.jcr.SimpleCredentials; +import javax.jcr.lock.LockException; import javax.jcr.nodetype.ConstraintViolationException; +import javax.jcr.nodetype.NoSuchNodeTypeException; import javax.jcr.nodetype.NodeType; +import javax.jcr.version.VersionException; import org.apache.commons.lang3.exception.ExceptionUtils; import org.apache.jackrabbit.api.JackrabbitSession; @@ -422,4 +429,16 @@ public void testKeepNodeTypeForFolderAggregate() throws IOException, RepositoryE assertNodeHasPrimaryType("/testroot/myfolder", JcrConstants.NT_UNSTRUCTURED); assertNodeHasPrimaryType("/testroot/myfolder/mychild", JcrConstants.NT_UNSTRUCTURED); } + + @Test + public void testEnhancedFileAggregatePackageWithIntermediateSaves() throws IOException, ConfigurationException, AccessDeniedException, ItemExistsException, ReferentialIntegrityException, ConstraintViolationException, InvalidItemStateException, VersionException, LockException, NoSuchNodeTypeException, RepositoryException { + ImportOptions opts = getDefaultOptions(); + opts.setAutoSaveThreshold(1); // + Importer importer = new Importer(opts); + try (Archive archive = getFileArchive("/test-packages/enhanced_file_aggregate.zip")) { + archive.open(true); + importer.run(archive, admin.getRootNode()); + admin.save(); + } + } } \ No newline at end of file diff --git a/vault-core/src/test/resources/test-packages/enhanced_file_aggregate.zip/META-INF/vault/config.xml b/vault-core/src/test/resources/test-packages/enhanced_file_aggregate.zip/META-INF/vault/config.xml new file mode 100644 index 000000000..59e3a4a78 --- /dev/null +++ b/vault-core/src/test/resources/test-packages/enhanced_file_aggregate.zip/META-INF/vault/config.xml @@ -0,0 +1,93 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/vault-core/src/test/resources/test-packages/enhanced_file_aggregate.zip/META-INF/vault/filter.xml b/vault-core/src/test/resources/test-packages/enhanced_file_aggregate.zip/META-INF/vault/filter.xml new file mode 100644 index 000000000..e833718a1 --- /dev/null +++ b/vault-core/src/test/resources/test-packages/enhanced_file_aggregate.zip/META-INF/vault/filter.xml @@ -0,0 +1,4 @@ + + + + diff --git a/vault-core/src/test/resources/test-packages/enhanced_file_aggregate.zip/META-INF/vault/properties.xml b/vault-core/src/test/resources/test-packages/enhanced_file_aggregate.zip/META-INF/vault/properties.xml new file mode 100644 index 000000000..f57b010d2 --- /dev/null +++ b/vault-core/src/test/resources/test-packages/enhanced_file_aggregate.zip/META-INF/vault/properties.xml @@ -0,0 +1,13 @@ + + + +root +true +enhanced-file-aggregate-package +2022-05-26T10:38:55.609Z +1.0.0 +application +false +testpackages +test package containing enhanced file aggregate + diff --git a/vault-core/src/test/resources/test-packages/enhanced_file_aggregate.zip/META-INF/vault/settings.xml b/vault-core/src/test/resources/test-packages/enhanced_file_aggregate.zip/META-INF/vault/settings.xml new file mode 100644 index 000000000..61c1bea29 --- /dev/null +++ b/vault-core/src/test/resources/test-packages/enhanced_file_aggregate.zip/META-INF/vault/settings.xml @@ -0,0 +1,21 @@ + + + + + + \ No newline at end of file diff --git a/vault-core/src/test/resources/test-packages/enhanced_file_aggregate.zip/jcr_root/apps/testnode/.content.xml b/vault-core/src/test/resources/test-packages/enhanced_file_aggregate.zip/jcr_root/apps/testnode/.content.xml new file mode 100644 index 000000000..c33c1efd8 --- /dev/null +++ b/vault-core/src/test/resources/test-packages/enhanced_file_aggregate.zip/jcr_root/apps/testnode/.content.xml @@ -0,0 +1,9 @@ + + + + + + + + diff --git a/vault-core/src/test/resources/test-packages/enhanced_file_aggregate.zip/jcr_root/apps/testnode/tika/config.xml b/vault-core/src/test/resources/test-packages/enhanced_file_aggregate.zip/jcr_root/apps/testnode/tika/config.xml new file mode 100644 index 000000000..b6900ba3a --- /dev/null +++ b/vault-core/src/test/resources/test-packages/enhanced_file_aggregate.zip/jcr_root/apps/testnode/tika/config.xml @@ -0,0 +1,11 @@ + + + + + + + text/plain + + + + \ No newline at end of file