You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@struts.apache.org by ya...@apache.org on 2021/03/23 16:00:12 UTC
[struts] branch master updated: [WW-5121] Fix: remove contention
during Scope.SINGLETON injection
This is an automated email from the ASF dual-hosted git repository.
yasserzamani pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/struts.git
The following commit(s) were added to refs/heads/master by this push:
new cb2c67e [WW-5121] Fix: remove contention during Scope.SINGLETON injection
new 49a4d6d Merge pull request #478 from davoustp/contention-in-singleton-injection-2.6.x
cb2c67e is described below
commit cb2c67e8085107e7c21dfdf20187e36d1bd5d864
Author: Pascal Davoust <pa...@eptica.com>
AuthorDate: Mon Mar 22 09:37:14 2021 +0100
[WW-5121] Fix: remove contention during Scope.SINGLETON injection
---
core/src/main/java/com/opensymphony/xwork2/inject/Scope.java | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/core/src/main/java/com/opensymphony/xwork2/inject/Scope.java b/core/src/main/java/com/opensymphony/xwork2/inject/Scope.java
index 86592bb..3974d6c 100644
--- a/core/src/main/java/com/opensymphony/xwork2/inject/Scope.java
+++ b/core/src/main/java/com/opensymphony/xwork2/inject/Scope.java
@@ -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