Skip to content

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

@spring-projects-issues

Description

@spring-projects-issues

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions