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

Dirty writes and SimpleThreadScope leaking across contexts [SPR-7463] #12121

Closed
spring-projects-issues opened this issue Aug 14, 2010 · 3 comments
Labels
type: bug A general bug
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

Dave Syer opened SPR-7463 and commented

Two ApplicationContexts having bean definitions with the same name can share a thread and they will then also share a bean instance. It's a dirty write: the first context to use the thread inserts its version of the bean and the other loses. The consequence is at best a memory leak and at worst a security problem, and in all cases a source of strange application behaviour.

SimpleThreadScope should clear its state on destroy() - it should also segregate it by ApplicationContext.id. It would be nice if it supported destruction callbacks for its beans as well, but at least to be useful in practice it should be a DisposableBean which clears and re-initializes its thread local state when the context closes down.


Affects: 3.0 GA

Referenced from: commits 5109501

@spring-projects-issues
Copy link
Collaborator Author

Dave Syer commented

An even simpler change: just make the thread local an instance variable (not static). Can we do this for 3.0.4?

@spring-projects-issues
Copy link
Collaborator Author

Chris Beams commented

Go ahead, please. Won't be hard to back out such a change if there's some issue with this approach. For some reason I couldn't assign this to you... just comment when it's committed.

@spring-projects-issues
Copy link
Collaborator Author

Dave Syer commented

Changed to instance variable from static

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

No branches or pull requests

1 participant