Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
Sling Models Implementation 1.1.0
-
None
Description
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.