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

Provide lock free access to BeanFactory methods by calling BF methods on the AbstractApplicationContext instance directly [SPR-11863] #16482

Closed
spring-projects-issues opened this issue Jun 10, 2014 · 2 comments
Assignees
Labels
type: enhancement A general enhancement
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented Jun 10, 2014

Lari Hotari opened SPR-11863 and commented

Profiling Grails 2.4.x applications shows a lot of blocking in org.springframework.context.support.AbstractApplicationContext.assertBeanFactoryActive

There's a discussion about this in SPR-10307 comments.

Juergen suggested to call BeanFactory methods on the BeanFactory instance returned from ConfigurableApplicationContext.getBeanFactory instead of calling the BeanFactory methods available on the AbstractApplicationContext instance. Another way to get hold of the "internal" BeanFactory instead of the ApplicationContext facade is to use BeanFactoryAware for injecting the BeanFactory instance and calling methods on that instance.

However I'd like to be able to use BeanFactory methods directly on the ApplicationContext instance instead without any performance overhead (synchronization).


Affects: 4.0.5

Issue Links:

Referenced from: commits fac2d80

@spring-projects-issues
Copy link
Collaborator Author

Juergen Hoeller commented

Lari, which ApplicationContext base class are you deriving from in that scenario? We turn assertBeanFactoryActive into a no-op in a few cases... where getBeanFactory() itself provides such a check already. However, that's not the case for GenericApplicationContext and co which always hold a BeanFactory.

Juergen

@spring-projects-issues
Copy link
Collaborator Author

Juergen Hoeller commented

AbstractApplicationContext uses AtomicBoolean instead of synchronization for its active/closed flags now. This also removes the unpleasant lock in assertBeanFactoryActive().

Juergen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants