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

Konrad Windszus commented on SLING-4767:
----------------------------------------

The error handling was changed again in SLING-5389. See the issue there how 
this is done exactly. In any case if the injection is either optional or has a 
default value the exception is only logged as DEBUG (which fulfills the 
requirement of this issue).

> Optional sub models are logged as warn if they cannot be adapted
> ----------------------------------------------------------------
>
>                 Key: SLING-4767
>                 URL: https://issues.apache.org/jira/browse/SLING-4767
>             Project: Sling
>          Issue Type: Improvement
>            Reporter: Georg Henzler
>            Assignee: Konrad Windszus
>             Fix For: Sling Models API 1.2.0, Sling Models Impl 1.2.0
>
>
> Currently Sling Models logs the example model \[1] as warning \[2] if the sub 
> model image does not exist. This really should be a debug log as it is 
> totally fine if in optional field cannot be set?
> \[1]
> {code}
> com......mediagallery.MediaGalleryElement
> ...
>     @Inject
>     @Optional
>     @Named(value = ".")
>     private Image image;
> {code}
> \[2] 
> org.apache.sling.models.impl.ModelAdapterFactory.injectElement(InjectableElement,
>  Object, Model, DisposalCallbackRegistry, InjectCallback)
> {code}
>                 // log previous injection error, if there was any
>                 if (lastInjectionException != null) {
>                     log.warn("Although falling back to default value worked, 
> injection into {} failed because of: " + lastInjectionException.getMessage(), 
> element.getAnnotatedElement(), lastInjectionException);
>                 }
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to