You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by "Carsten Ziegeler (Jira)" <ji...@apache.org> on 2023/05/17 05:35:00 UTC

[jira] [Commented] (SLING-11883) JcrModifiableValueMap's cached copy of namespace prefixes is never refreshed

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

Carsten Ziegeler commented on SLING-11883:
------------------------------------------

I think it makes sense to refresh (clear) the cache in HelperData when RR.refresh is called

> JcrModifiableValueMap's cached copy of namespace prefixes is never refreshed
> ----------------------------------------------------------------------------
>
>                 Key: SLING-11883
>                 URL: https://issues.apache.org/jira/browse/SLING-11883
>             Project: Sling
>          Issue Type: Bug
>            Reporter: Amit Shrigondekar
>            Priority: Major
>
> Ran into this bug in patching metadata on a resource. Patched property has unregistered namespace. Since user session does not have enough permissions to create namespace, we used a service session to register a new namespace, after that refreshed the user session, and then created a new resource resolver from that user session. Now when we patch the metadata properties we use something similar to this
> {code:java}
> ModifiableValueMap valueMap = resource.get().adaptTo(ModifiableValueMap.class);  valueMap.put(propertyName, value);{code}
> `resolver.commit()` is called after patching. Commit does not recognize the registered namespace which causes an encoded colon in the property name. 
> Reason: 
> JcrModifiableValueMap (an implementation of ModifiableValueMap) uses [escapeKeyName function in HelperData|https://github.com/apache/sling-org-apache-sling-jcr-resource/blob/4ab953bf5debe2c60e1c531dc5f8f6aeb2d7414e/src/main/java/org/apache/sling/jcr/resource/internal/HelperData.java#L50] class which has a cached copy of namespace prefixes that never sees the latest changes.
> [https://github.com/apache/sling-org-apache-sling-jcr-resource/blob/a1f5532981a118470c74afdba217fa480c1e0cec/src/main/java/org/apache/sling/jcr/resource/internal/JcrModifiableValueMap.java#L65]



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