From 304e0ab73851d1505570271f17a2874f2332c6c7 Mon Sep 17 00:00:00 2001 From: Konrad Windszus Date: Wed, 15 Nov 2023 17:44:21 +0100 Subject: [PATCH] Do not try to set a default for Collection fields in Sling Models This prevents the error "WARN org.apache.sling.models.impl.ModelAdapterFactory - Cannot provide default for java.util.List" being issued due to https://issues.apache.org/jira/browse/SLING-11812 This closes #3209 --- CHANGELOG.md | 3 +++ .../replication/dispatcher/impl/DispatcherFlushModelImpl.java | 4 ++-- .../acs/commons/wcm/components/impl/TwitterFeedModelImpl.java | 1 - 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 05007e5a0d..d712dfd20a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com) ## Unreleased ([details][unreleased changes details]) +## Added + +- #3209 - WARN org.apache.sling.models.impl.ModelAdapterFactory - Cannot provide default for java.util.List ## 6.3.0 - 2023-10-25 diff --git a/bundle/src/main/java/com/adobe/acs/commons/replication/dispatcher/impl/DispatcherFlushModelImpl.java b/bundle/src/main/java/com/adobe/acs/commons/replication/dispatcher/impl/DispatcherFlushModelImpl.java index 4b540724c6..8b38cae5d4 100644 --- a/bundle/src/main/java/com/adobe/acs/commons/replication/dispatcher/impl/DispatcherFlushModelImpl.java +++ b/bundle/src/main/java/com/adobe/acs/commons/replication/dispatcher/impl/DispatcherFlushModelImpl.java @@ -33,6 +33,7 @@ import java.util.Arrays; import java.util.Collection; +import java.util.Collections; import java.util.List; @Model( @@ -53,7 +54,6 @@ public class DispatcherFlushModelImpl implements DispatcherFlusherModel { private String replicationActionType; @ValueMapValue - @Default(values = {}) private List paths; @Override @@ -63,7 +63,7 @@ public String getActionType() { @Override public Collection getPaths() { - return paths; + return paths != null ? paths : Collections.emptyList(); } @Override diff --git a/bundle/src/main/java/com/adobe/acs/commons/wcm/components/impl/TwitterFeedModelImpl.java b/bundle/src/main/java/com/adobe/acs/commons/wcm/components/impl/TwitterFeedModelImpl.java index 45c0e59ba9..6ba9280516 100644 --- a/bundle/src/main/java/com/adobe/acs/commons/wcm/components/impl/TwitterFeedModelImpl.java +++ b/bundle/src/main/java/com/adobe/acs/commons/wcm/components/impl/TwitterFeedModelImpl.java @@ -46,7 +46,6 @@ public class TwitterFeedModelImpl implements TwitterFeedModel { private int limit; @ValueMapValue - @Default(values = {}) private List tweets; @PostConstruct