You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by "Julian Sedding (Jira)" <ji...@apache.org> on 2020/09/28 09:14:00 UTC
[jira] [Commented] (SLING-9774) The ValueMapUtil#merge behavior is
different from the deprecated CompositeValueMap
[ https://issues.apache.org/jira/browse/SLING-9774?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17203108#comment-17203108 ]
Julian Sedding commented on SLING-9774:
---------------------------------------
[~enorman] A simpler fix that passes your test would be the following:
{code:java}
@Override
public Object get(final Object key) {
return valueMaps.stream()
.filter(vm -> vm.containsKey(key)) // SLING-9774
.findFirst()
.map(vm -> vm.get(key))
.orElse(null);
}
{code}
> The ValueMapUtil#merge behavior is different from the deprecated CompositeValueMap
> ----------------------------------------------------------------------------------
>
> Key: SLING-9774
> URL: https://issues.apache.org/jira/browse/SLING-9774
> Project: Sling
> Issue Type: Bug
> Affects Versions: API 2.23.0
> Reporter: Eric Norman
> Assignee: Eric Norman
> Priority: Major
> Fix For: API 2.23.2
>
>
> CompositeValueMap has been marked as deprecated and the recommendation was to replace those usages with ValueMapUtil#merge(ValueMap...)}
> Unfortunately it looks like implementation from ValueMapUtil#merge has different behavior when it comes to handling of entries in the map where the key is supplied but the value is null.
> My use case is that in a few places I have used the key=null behavior of CompositeValueMap to hide entries in a wrapped ValueMap and those uses cases don't work the same after switching to ValueMapUtil#merge(ValueMap...)}.
> To be compatible with the deprecated CompositeValueMap, the MergingValueMap#get impl should not automatically filter entries whose value is null. Instead it should only filter when the value is null and the map does not contain the key. A null value doesn't always mean that the map didn't have an entry for the key.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)