Konrad Windszus created SLING-3923:
--------------------------------------

             Summary: PostConstruct method may be called multiple times for one 
instance
                 Key: SLING-3923
                 URL: https://issues.apache.org/jira/browse/SLING-3923
             Project: Sling
          Issue Type: Bug
    Affects Versions: Sling Models Implementation 1.1.0
            Reporter: Konrad Windszus


The problem is in 
https://github.com/apache/sling/blob/trunk/bundles/extensions/models/impl/src/main/java/org/apache/sling/models/impl/ModelAdapterFactory.java#L732.

There all @PostConstruct annotated methods are being collected (starting from 
current class, but including also all super classes). Now you might end up with 
2 methods (one in the current and one in the super class).

The problem appears if those methods have the same signature (i.e. name and 
parametrization) because then you are not able to call the post construct in 
the super class (compare with 
https://blogs.oracle.com/sundararajan/entry/calling_overriden_superclass_method_on).

Therefore I would propose the following fix:
Only add post construct methods from superclasses if they have a different 
signature.



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

Reply via email to