Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InitDestroyAnnotationBeanPostProcessor is flipping the initialization order [SPR-6344] #11010

Closed
spring-projects-issues opened this issue Nov 13, 2009 · 2 comments
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: bug A general bug
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

Kenny MacLeod opened SPR-6344 and commented

As of RC1, the order in which bean init methods are being executed has been reversed, compared to the behaviour in 2.5.6 and M4.

Specifically, InitDestroyAnnotationBeanPostProcessor.LifecycleMetadata.addInitMethod is now adding each successive init method to the front of the list. Prior versions added it to the end.

This manifests itself as a problem in code where there are multiple init methods (e.g. multiple @PostConstruct methods) in one class. We have code where we're relying on those methods being executed in order, as returned by the reflection API. If there's executed in reverse order, it all breaks.

Is there a reason these methods are being explicitly reversed?


Affects: 3.0 RC1, 3.0 RC2

Referenced from: commits 3b9605b

@spring-projects-issues
Copy link
Collaborator Author

Kenny MacLeod commented

Happens with RC2 also.

@spring-projects-issues
Copy link
Collaborator Author

Juergen Hoeller commented

We're processing init methods top down now: base class first, then sub class, etc - and at each hierarchy level, we're processing them in the order of declaration. For destroy methods, it's the same but going through the hierarchy bottom up.

In previous 3.0 milestones, we tried to do proper init method hierarchy traversal from top down (which we didn't do before, always going bottom up in 2.5) but accidentally also reversed the order at each hierarchy level. This should be fixed in trunk now.

Juergen

@spring-projects-issues spring-projects-issues added type: bug A general bug in: core Issues in core modules (aop, beans, core, context, expression) labels Jan 11, 2019
@spring-projects-issues spring-projects-issues added this to the 3.0 RC3 milestone Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: bug A general bug
Projects
None yet
Development

No branches or pull requests

2 participants