Skip to content

Commit

Permalink
Streamline code to not execute code when an attribute is not null
Browse files Browse the repository at this point in the history
WW-1959

git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/trunk@556503 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
Donald J. Brown committed Jul 16, 2007
1 parent 484a383 commit 1cec0e8
Showing 1 changed file with 18 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,24 +63,26 @@ public Object getAttribute(String s) {
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();
}
if (attribute == null) {
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);
// note: we don't let # come through or else a request for
// #attr.foo or #request.foo could cause an endless loop
if (!alreadyIn && 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);
}
} finally {
ctx.put("__requestWrapper.getAttribute", Boolean.FALSE);
}
}
return attribute;
Expand Down

0 comments on commit 1cec0e8

Please sign in to comment.