mirror of
https://github.com/apache/struts.git
synced 2026-08-06 15:17:00 +00:00
WW-4789 WW-3788 Avoids unneeded binds to ThreadLocal
This commit is contained in:
@@ -242,7 +242,7 @@ public class ActionContext implements Serializable {
|
||||
* @return the context map.
|
||||
*/
|
||||
public Map<String, Object> getContextMap() {
|
||||
return getContext().context;
|
||||
return context;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -524,7 +524,7 @@ public class ActionContext implements Serializable {
|
||||
|
||||
public ActionContext withExtraContext(Map<String, Object> extraContext) {
|
||||
if (extraContext != null) {
|
||||
getContext().context.putAll(extraContext);
|
||||
context.putAll(extraContext);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -324,7 +324,6 @@ public class DefaultActionInvocation implements ActionInvocation {
|
||||
}
|
||||
|
||||
protected Map<String, Object> createContextMap() {
|
||||
ActionContext oldContext = ActionContext.getContext();
|
||||
ActionContext actionContext;
|
||||
|
||||
if (extraContext != null && extraContext.containsKey(ActionContext.VALUE_STACK)) {
|
||||
@@ -345,20 +344,11 @@ public class DefaultActionInvocation implements ActionInvocation {
|
||||
actionContext = stack.getActionContext();
|
||||
}
|
||||
|
||||
try {
|
||||
return actionContext
|
||||
.bind()
|
||||
.withExtraContext(extraContext)
|
||||
.withActionInvocation(this)
|
||||
.withContainer(container)
|
||||
.getContextMap();
|
||||
} finally {
|
||||
ActionContext.clear();
|
||||
if (oldContext != null) {
|
||||
LOG.debug("Re-binding the old context");
|
||||
oldContext.bind();
|
||||
}
|
||||
}
|
||||
return actionContext
|
||||
.withExtraContext(extraContext)
|
||||
.withActionInvocation(this)
|
||||
.withContainer(container)
|
||||
.getContextMap();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
*/
|
||||
package com.opensymphony.xwork2.ognl;
|
||||
|
||||
import com.opensymphony.xwork2.ActionContext;
|
||||
import com.opensymphony.xwork2.TextProvider;
|
||||
import com.opensymphony.xwork2.conversion.NullHandler;
|
||||
import com.opensymphony.xwork2.conversion.impl.XWorkConverter;
|
||||
@@ -65,40 +64,20 @@ public class OgnlValueStackFactory implements ValueStackFactory {
|
||||
ValueStack stack = new OgnlValueStack(xworkConverter, compoundRootAccessor, textProvider,
|
||||
containerAllowsStaticMethodAccess(), containerAllowsStaticFieldAccess());
|
||||
container.inject(stack);
|
||||
ActionContext oldContext = ActionContext.getContext();
|
||||
try {
|
||||
return stack.getActionContext()
|
||||
.bind()
|
||||
.withContainer(container)
|
||||
.withValueStack(stack)
|
||||
.getValueStack();
|
||||
} finally {
|
||||
ActionContext.clear();
|
||||
if (oldContext != null) {
|
||||
LOG.debug("Re-binding the old context");
|
||||
oldContext.bind();
|
||||
}
|
||||
}
|
||||
return stack.getActionContext()
|
||||
.withContainer(container)
|
||||
.withValueStack(stack)
|
||||
.getValueStack();
|
||||
}
|
||||
|
||||
public ValueStack createValueStack(ValueStack stack) {
|
||||
ValueStack result = new OgnlValueStack(stack, xworkConverter, compoundRootAccessor,
|
||||
containerAllowsStaticMethodAccess(), containerAllowsStaticFieldAccess());
|
||||
container.inject(result);
|
||||
ActionContext oldContext = ActionContext.getContext();
|
||||
try {
|
||||
return result.getActionContext()
|
||||
.bind()
|
||||
.withContainer(container)
|
||||
.withValueStack(result)
|
||||
.getValueStack();
|
||||
} finally {
|
||||
ActionContext.clear();
|
||||
if (oldContext != null) {
|
||||
LOG.debug("Re-binding the old context");
|
||||
oldContext.bind();
|
||||
}
|
||||
}
|
||||
return result.getActionContext()
|
||||
.withContainer(container)
|
||||
.withValueStack(result)
|
||||
.getValueStack();
|
||||
}
|
||||
|
||||
@Inject
|
||||
|
||||
Reference in New Issue
Block a user