mirror of
https://github.com/apache/struts.git
synced 2026-08-06 07:06:58 +00:00
[WW-5121] Fix: remove contention during Scope.SINGLETON injection
This commit is contained in:
@@ -44,15 +44,17 @@ public enum Scope {
|
||||
@Override
|
||||
<T> InternalFactory<? extends T> scopeFactory(Class<T> type, String name, final InternalFactory<? extends T> factory) {
|
||||
return new InternalFactory<T>() {
|
||||
T instance;
|
||||
volatile T instance;
|
||||
|
||||
public T create(InternalContext context) {
|
||||
synchronized (context.getContainer()) {
|
||||
if (instance == null) {
|
||||
instance = InitializableFactory.wrapIfNeeded(factory).create(context);
|
||||
if (instance == null) {
|
||||
synchronized (context.getContainer()) {
|
||||
if (instance == null) {
|
||||
instance = InitializableFactory.wrapIfNeeded(factory).create(context);
|
||||
}
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user