Author: mrdon Date: Sun Jul 15 22:11:44 2007 New Revision: 556503 URL: http://svn.apache.org/viewvc?view=rev&rev=556503 Log: Streamline code to not execute code when an attribute is not null WW-1959
Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/StrutsRequestWrapper.java Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/StrutsRequestWrapper.java URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/StrutsRequestWrapper.java?view=diff&rev=556503&r1=556502&r2=556503 ============================================================================== --- struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/StrutsRequestWrapper.java (original) +++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/StrutsRequestWrapper.java Sun Jul 15 22:11:44 2007 @@ -63,24 +63,26 @@ 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;