[jira] [Comment Edited] (SLING-12245) Sling Rewriter does not detect configuration changes coming in via move

2024-02-08 Thread Konrad Windszus (Jira)


[ 
https://issues.apache.org/jira/browse/SLING-12245?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17815614#comment-17815614
 ] 

Konrad Windszus edited comment on SLING-12245 at 2/8/24 10:42 AM:
--

This issue affects every ResourceChangeListener! I wouldn't want to implement 
such a logic in every implementation.
Some examples: 
# 
https://github.com/apache/sling-org-apache-sling-i18n/blob/262951b8a778757df0af8495ae71f3f264b8df30/src/main/java/org/apache/sling/i18n/impl/JcrResourceBundleProvider.java#L222
# 
https://github.com/apache/sling-org-apache-sling-xss/blob/16bb365c0116374c2a17340242189afb8ad38cd4/src/main/java/org/apache/sling/xss/impl/XSSFilterImpl.java#L372
# 
https://github.com/apache/sling-org-apache-sling-scripting-sightly/blob/690a818692bd08c3f6a49e842ea530cc3e60e3ad/src/main/java/org/apache/sling/scripting/sightly/impl/engine/ResourceBackedPojoChangeMonitor.java#L75
# 
https://github.com/apache/sling-org-apache-sling-event/blob/94680f155e8a88ea6b8f937656bdfd9c9c6a3cea/src/main/java/org/apache/sling/event/impl/jobs/scheduling/JobSchedulerImpl.java#L564
...


was (Author: kwin):
This issue affects every ResourceChangeListener! I wouldn't want to implement 
such a logic in every implementation.
Some examples: 
# 
https://github.com/apache/sling-org-apache-sling-i18n/blob/262951b8a778757df0af8495ae71f3f264b8df30/src/main/java/org/apache/sling/i18n/impl/JcrResourceBundleProvider.java#L222
# 
https://github.com/apache/sling-org-apache-sling-xss/blob/16bb365c0116374c2a17340242189afb8ad38cd4/src/main/java/org/apache/sling/xss/impl/XSSFilterImpl.java#L372

> Sling Rewriter does not detect configuration changes coming in via move
> ---
>
> Key: SLING-12245
> URL: https://issues.apache.org/jira/browse/SLING-12245
> Project: Sling
>  Issue Type: Improvement
>Affects Versions: Rewriter 1.3.10
>Reporter: Konrad Windszus
>Priority: Major
>
> If one renames/moves a JCR node from {{/apps/my/config/invalid-rewriter}} to 
> {{/apps/my/config/rewriter}} the new rewriter configuration is not being 
> detected by the {{ProcessorManagerImpl}} due to the 
> {{ResourceChangeListener}} only being configured to listen for changes below 
> the {{rewriter}} resource 
> (https://github.com/apache/sling-org-apache-sling-rewriter/blob/4d1952648e35e7001236f282040a78479f7726d4/src/main/java/org/apache/sling/rewriter/impl/ProcessorManagerImpl.java#L69).



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Comment Edited] (SLING-12245) Sling Rewriter does not detect configuration changes coming in via move

2024-02-08 Thread Konrad Windszus (Jira)


[ 
https://issues.apache.org/jira/browse/SLING-12245?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17815612#comment-17815612
 ] 

Konrad Windszus edited comment on SLING-12245 at 2/8/24 10:18 AM:
--

The receiver does not know if it is ADDED event due to a move operation or a 
regular ADDED event. Only in the former case a traversal is necessary. If you 
do it for every ADDED event outside the path there is a high chance that you 
treat the same configuration twice (e.g. when adding a configuration via 
content package) which will first trigger an ADDED event on the ancestor as 
well followed by the ADDED event on the actual configuration resource. It gets 
worse the more levels the ADDED event is away from the actually relevant 
resources (traversing each time adds a considerable load in the system and 
deduplication will be impossible)


was (Author: kwin):
The receiver does not know if it is ADDED event due to a move operation or a 
regular ADDED event. Only in the former case a traversal is necessary. If you 
do it for every ADDED event outside the path there is a high chance that you 
treat the same configuration twice (e.g. when adding a configuration via 
content package) which will first trigger an ADDED event on the ancestor as 
well followed by the ADDED event on the actual configuration resource.

> Sling Rewriter does not detect configuration changes coming in via move
> ---
>
> Key: SLING-12245
> URL: https://issues.apache.org/jira/browse/SLING-12245
> Project: Sling
>  Issue Type: Improvement
>Affects Versions: Rewriter 1.3.10
>Reporter: Konrad Windszus
>Priority: Major
>
> If one renames/moves a JCR node from {{/apps/my/config/invalid-rewriter}} to 
> {{/apps/my/config/rewriter}} the new rewriter configuration is not being 
> detected by the {{ProcessorManagerImpl}} due to the 
> {{ResourceChangeListener}} only being configured to listen for changes below 
> the {{rewriter}} resource 
> (https://github.com/apache/sling-org-apache-sling-rewriter/blob/4d1952648e35e7001236f282040a78479f7726d4/src/main/java/org/apache/sling/rewriter/impl/ProcessorManagerImpl.java#L69).



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Comment Edited] (SLING-12245) Sling Rewriter does not detect configuration changes coming in via move

2024-02-08 Thread Konrad Windszus (Jira)


[ 
https://issues.apache.org/jira/browse/SLING-12245?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17815578#comment-17815578
 ] 

Konrad Windszus edited comment on SLING-12245 at 2/8/24 8:50 AM:
-

Just to clarify: The ResourceChangeListener in 
https://github.com/apache/sling-org-apache-sling-rewriter/blob/4d1952648e35e7001236f282040a78479f7726d4/src/main/java/org/apache/sling/rewriter/impl/ProcessorManagerImpl.java#L134
 is notified both about REMOVED and ADDED *outside* the path (i.e. for the 
ancestor node) as the filter method in 
https://github.com/apache/sling-org-apache-sling-resourceresolver/blob/6cfe4c3cb3a532ebfcabe13ae0028b71fb20996e/src/main/java/org/apache/sling/resourceresolver/impl/observation/BasicObservationReporter.java#L205C39-L205C52
 doesn't consider the path restriction at all!

The only difference is that for REMOVED it is also notified about sub resources.

I don't think there is a reasonable fix inside the Sling Rewriter, but rather 
this requires a better approach in 
https://github.com/apache/sling-org-apache-sling-jcr-resource/blob/master/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceListener.java
 or 
https://github.com/apache/sling-org-apache-sling-jcr-resource/blob/master/src/main/java/org/apache/sling/jcr/resource/internal/JcrListenerBaseConfig.java
 to tackle node moves. Any other idea for fixing this except for another flag 
for Oak to also emit "NODE_ADDED" events for all moved child nodes?


was (Author: kwin):
Just to clarify: The ResourceChangeListener in 
https://github.com/apache/sling-org-apache-sling-rewriter/blob/4d1952648e35e7001236f282040a78479f7726d4/src/main/java/org/apache/sling/rewriter/impl/ProcessorManagerImpl.java#L134
 is notified both about REMOVED and ADDED *outside* the path (i.e. for the 
ancestor node) as the filter method in 
https://github.com/apache/sling-org-apache-sling-resourceresolver/blob/6cfe4c3cb3a532ebfcabe13ae0028b71fb20996e/src/main/java/org/apache/sling/resourceresolver/impl/observation/BasicObservationReporter.java#L205C39-L205C52
 doesn't consider the path restriction at all!

The only difference is that for REMOVED it is also notified about sub resources.

I don't think there is a reasonable fix inside the Sling Rewriter, but rather 
this requires a better approach in 
https://github.com/apache/sling-org-apache-sling-jcr-resource/blob/master/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceListener.java
 to tackle node moves. Any other idea for fixing this except for another flag 
for Oak to also emit "NODE_ADDED" events for all moved child nodes?

> Sling Rewriter does not detect configuration changes coming in via move
> ---
>
> Key: SLING-12245
> URL: https://issues.apache.org/jira/browse/SLING-12245
> Project: Sling
>  Issue Type: Improvement
>Affects Versions: Rewriter 1.3.10
>Reporter: Konrad Windszus
>Priority: Major
>
> If one renames/moves a JCR node from {{/apps/my/config/invalid-rewriter}} to 
> {{/apps/my/config/rewriter}} the new rewriter configuration is not being 
> detected by the {{ProcessorManagerImpl}} due to the 
> {{ResourceChangeListener}} only being configured to listen for changes below 
> the {{rewriter}} resource 
> (https://github.com/apache/sling-org-apache-sling-rewriter/blob/4d1952648e35e7001236f282040a78479f7726d4/src/main/java/org/apache/sling/rewriter/impl/ProcessorManagerImpl.java#L69).



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Comment Edited] (SLING-12245) Sling Rewriter does not detect configuration changes coming in via move

2024-02-07 Thread Konrad Windszus (Jira)


[ 
https://issues.apache.org/jira/browse/SLING-12245?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17815393#comment-17815393
 ] 

Konrad Windszus edited comment on SLING-12245 at 2/7/24 6:33 PM:
-

Debugging revealed the following:

When renaming a working rewriter pipeline config from 
{{/apps/system/config/rewriter2}} to {{/apps/system/config/rewriter}} the 
following {{ResourceChange}} is received:
{code}
ResourceChange[type=ADDED, path=/apps/system/config/rewriter, external=false]
{code}
which is ignored in {{ProcessorManagerImpl.onChange(...)}}

However when renaming a working rewriter pipeline config from 
{{/apps/system/config/rewriter}} to {{/apps/system/config/rewriter2}} the 
following {{ResourceChanges}} are received:
{code}
ResourceChange[type=REMOVED, path=/apps/system/config/rewriter, external=false]
ResourceChange[type=REMOVED, path=/apps/system/config/rewriter/custom, 
external=false]
{code}
which leads to removing the config at {{/apps/system/config/rewriter}} in 
{{ProcessorManagerImpl.onChange(...)}} (in case it was previously registered).

This is due to the fact how the JCR Event Listener is being registered in 
https://github.com/apache/sling-org-apache-sling-jcr-resource/blob/8fb5a3d44de01f05964028debcf24531f2f65747/src/main/java/org/apache/sling/jcr/resource/internal/JcrListenerBaseConfig.java#L104.

Looks like the OakEventFilter does not behave synchronously here, i.e. in case 
of renames only notifies about each removal of a subtree, but not for the 
addition for each addition of a subtree.


was (Author: kwin):
Debugging revealed the following:

When renaming a working rewriter pipeline config from 
{{/apps/system/config/rewriter2}} to {{/apps/system/config/rewriter}} the 
following {{ResourceChange}} is received:
{code}
ResourceChange[type=ADDED, path=/apps/system/config/rewriter, external=false]
{code}
which is ignored in {{ProcessorManagerImpl.onChange(...)}}

However when renaming a working rewriter pipeline config from 
{{/apps/system/config/rewriter}} to {{/apps/system/config/rewriter2}} the 
following {{ResourceChanges}} are received:
{code}
ResourceChange[type=REMOVED, path=/apps/system/config/rewriter, external=false]
ResourceChange[type=REMOVED, path=/apps/system/config/rewriter/custom, 
external=false]
{code}
which leads to removing the config at {{/apps/system/config/rewriter}} in 
{{ProcessorManagerImpl.onChange(...)}} (in case it was previously registered).

> Sling Rewriter does not detect configuration changes coming in via move
> ---
>
> Key: SLING-12245
> URL: https://issues.apache.org/jira/browse/SLING-12245
> Project: Sling
>  Issue Type: Improvement
>Affects Versions: Rewriter 1.3.10
>Reporter: Konrad Windszus
>Priority: Major
>
> If one renames/moves a JCR node from {{/apps/my/config/invalid-rewriter}} to 
> {{/apps/my/config/rewriter}} the new rewriter configuration is not being 
> detected by the {{ProcessorManagerImpl}} due to the 
> {{ResourceChangeListener}} only being configured to listen for changes below 
> the {{rewriter}} resource 
> (https://github.com/apache/sling-org-apache-sling-rewriter/blob/4d1952648e35e7001236f282040a78479f7726d4/src/main/java/org/apache/sling/rewriter/impl/ProcessorManagerImpl.java#L69).



--
This message was sent by Atlassian Jira
(v8.20.10#820010)