Unused code easy to remove on StrutsRequestWrapper
--------------------------------------------------
Key: WW-1959
URL: https://issues.apache.org/struts/browse/WW-1959
Project: Struts 2
Issue Type: Improvement
Components: Dispatch
Affects Versions: 2.0.7, 2.0.6, 2.0.5, 2.0.4, 2.0.3, 2.0.2, 2.0.1, 2.0.0, 2.0.8, 2.0.9,
2.1.0, 2.1.x, Future
Reporter: Mike Baroukh
Priority: Trivial
in StrutsRequestWrapper, we can see :
ActionContext ctx = ActionContext.getContext();
Object attribute = super.getAttribute(s);
boolean alreadyIn = false;
Boolean b = (Boolean) ctx.get("__requestWrapper.getAttribute");
if (b != null) {
alreadyIn = b.booleanValue();
}
// note: we don't let # come through or else a request for
// #attr.foo or #request.foo could cause an endless loop
if (!alreadyIn && attribute == null && s.indexOf("#") == -1) {
try {
// If not found, then try the ValueStack
ctx.put("__requestWrapper.getAttribute", Boolean.TRUE);
ValueStack stack = ctx.getValueStack();
if (stack != null) {
attribute = stack.findValue(s);
}
} finally {
ctx.put("__requestWrapper.getAttribute", Boolean.FALSE);
}
}
return attribute;
}
so the bloc
boolean alreadyIn = false;
Boolean b = (Boolean) ctx.get("__requestWrapper.getAttribute");
if (b != null) {
alreadyIn = b.booleanValue();
}
is not used if attribute isn't null.
So I propose to replace with
Object attribute = super.getAttribute(s);
if (attribute==null) {
Boolean b = (Boolean) ctx.get("__requestWrapper.getAttribute");
// note: we don't let # come through or else a request for
// #attr.foo or #request.foo could cause an endless loop
if ( (!Boolean.TRUE.equals(b) && attribute == null && s.indexOf("#")
== -1) {
try {
// If not found, then try the ValueStack
I know it's a small enhancement, but getAttribute() is called a lot and all calls cumulated
can improve significantly ...
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
|