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

Robert Munteanu commented on SLING-11507:
-----------------------------------------

I can definitely extend this to static methods.  It is less clear to me though 
if we should do that though, as the method may be written in a thread-safe way.

It's also not clear to me if we should check for other annotations like 
{{@Inject}}, which increases the chance to conflict with other libraries. 
Should we check that the top-level class is annotated with with {{@Model}} ?

> Field injection should not inject static fields
> -----------------------------------------------
>
>                 Key: SLING-11507
>                 URL: https://issues.apache.org/jira/browse/SLING-11507
>             Project: Sling
>          Issue Type: Task
>          Components: Sling Models
>    Affects Versions: Models Impl 1.4.14
>            Reporter: Joerg Hoh
>            Priority: Major
>             Fix For: Sling Models Implementation 1.5
>
>          Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> Currently this injection works:
> {noformat}
>         @SlingObject
>         private static ResourceResolver resourceResolver;
> {noformat}
> but it should not. Sling Models are Pojos and injection must never inject 
> into static fields. Instead it should throw an exception and an error message 
> indicating the problem (another option would be to refuse the injection with 
> a proper error message).



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

Reply via email to