adobe / aem-modernize-tools

A suite of tools to modernize your AEM Sites implementations off legacy features.
http://opensource.adobe.com/aem-modernize-tools/
Apache License 2.0
64 stars 42 forks source link

Repository Exception when Rule deletes node #119

Closed bstopp closed 2 years ago

bstopp commented 2 years ago

Expected Behaviour

If a rewrite rule removes the node it processes, then there should not be any errors when continuing to process nodes in the Job.

Actual Behaviour

When a node is deleted via a rule, the Service will attempt to maintain the order of the parent's children (or the deleted node's siblings). However the node having been deleted will throw a Repository exception due to item not found - since the node no longer exists to order.

Logs taken while reproducing problem

20.01.2022 18:41:19.545 *ERROR* [sling-threadpool-6987d6e0-972c-4870-a437-31cd8b7fbe91-(apache-sling-job-thread-pool)-19-AEM Modernize Tools Queue(com/adobe/aem/modernize/job/topic/convert/component)] com.adobe.aem.modernize.component.job.ComponentJobExecutor Component conversion resulted in an error
com.adobe.aem.modernize.RewriteException: Repository exception while performing rewrite operation.
    at com.adobe.aem.modernize.component.impl.ComponentRewriteRuleServiceImpl.apply(ComponentRewriteRuleServiceImpl.java:95) [com.adobe.aem.aem-modernize-tools.core:2.0.15.SNAPSHOT]
    at com.adobe.aem.modernize.component.job.ComponentJobExecutor.doProcess(ComponentJobExecutor.java:74) [com.adobe.aem.aem-modernize-tools.core:2.0.15.SNAPSHOT]
    at com.adobe.aem.modernize.job.AbstractConversionJobExecutor.process(AbstractConversionJobExecutor.java:82) [com.adobe.aem.aem-modernize-tools.core:2.0.15.SNAPSHOT]
    at org.apache.sling.event.impl.jobs.queues.JobQueueImpl.startJob(JobQueueImpl.java:351) [org.apache.sling.event:4.2.24]
    at org.apache.sling.event.impl.jobs.queues.JobQueueImpl.access$100(JobQueueImpl.java:60) [org.apache.sling.event:4.2.24]
    at org.apache.sling.event.impl.jobs.queues.JobQueueImpl$1.run(JobQueueImpl.java:287) [org.apache.sling.event:4.2.24]
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: javax.jcr.ItemNotFoundException: Not a child: featuredcontent
    at org.apache.jackrabbit.oak.jcr.delegate.NodeDelegate.orderBefore(NodeDelegate.java:375) [org.apache.jackrabbit.oak-jcr:1.40.0.T20211203153857-c006959]
    at org.apache.jackrabbit.oak.jcr.session.NodeImpl$6.performVoid(NodeImpl.java:339) [org.apache.jackrabbit.oak-jcr:1.40.0.T20211203153857-c006959]
    at org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate.performVoid(SessionDelegate.java:275) [org.apache.jackrabbit.oak-jcr:1.40.0.T20211203153857-c006959]
    at org.apache.jackrabbit.oak.jcr.session.NodeImpl.orderBefore(NodeImpl.java:330) [org.apache.jackrabbit.oak-jcr:1.40.0.T20211203153857-c006959]
    at com.adobe.aem.modernize.component.impl.ComponentRewriteRuleServiceImpl.applyTo(ComponentRewriteRuleServiceImpl.java:139) [com.adobe.aem.aem-modernize-tools.core:2.0.15.SNAPSHOT]
    at com.adobe.aem.modernize.component.impl.ComponentRewriteRuleServiceImpl.apply(ComponentRewriteRuleServiceImpl.java:92) [com.adobe.aem.aem-modernize-tools.core:2.0.15.SNAPSHOT]
    ... 8 common frames omitted