Author: rgielen
Date: Sat Sep 7 13:26:25 2013
New Revision: 1520763
URL: http://svn.apache.org/r1520763
Log:
WW-4193 - Patch by Christoph Nenning
With this patch it is checked if devMode is active and if logMissingProperties
is enabled before the exception is logged
- refactored shouldLogNoSuchPropertyWarning() to
shouldLogMissingPropertyWarning() and using it to handle MethodFailedExceptions.
- updated void handleOgnlException(String expr, Object value, boolean
throwExceptionOnFailure, OgnlException e) to use it.
Modified:
struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/OgnlValueStack.java
Modified:
struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/OgnlValueStack.java
URL:
http://svn.apache.org/viewvc/struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/OgnlValueStack.java?rev=1520763&r1=1520762&r2=1520763&view=diff
==============================================================================
---
struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/OgnlValueStack.java
(original)
+++
struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/OgnlValueStack.java
Sat Sep 7 13:26:25 2013
@@ -203,10 +203,15 @@ public class OgnlValueStack implements S
}
private void handleOgnlException(String expr, Object value, boolean
throwExceptionOnFailure, OgnlException e) {
- String msg = "Error setting expression '" + expr + "' with value '" +
value + "'";
- if (LOG.isWarnEnabled()) {
+ boolean shouldLog = shouldLogMissingPropertyWarning(e);
+ String msg = null;
+ if (throwExceptionOnFailure || shouldLog) {
+ msg = "Error setting expression '" + expr + "' with value '" +
value + "'";
+ }
+ if (shouldLog) {
LOG.warn(msg, e);
- }
+ }
+
if (throwExceptionOnFailure) {
throw new XWorkException(msg, e);
}
@@ -320,7 +325,7 @@ public class OgnlValueStack implements S
private Object handleOgnlException(String expr, boolean
throwExceptionOnFailure, OgnlException e) {
Object ret = findInContext(expr);
if (ret == null) {
- if (shouldLogNoSuchPropertyWarning(e)) {
+ if (shouldLogMissingPropertyWarning(e)) {
LOG.warn("Could not find property [" +
((NoSuchPropertyException) e).getName() + "]");
}
if (throwExceptionOnFailure) {
@@ -330,8 +335,9 @@ public class OgnlValueStack implements S
return ret;
}
- private boolean shouldLogNoSuchPropertyWarning(OgnlException e) {
- return e instanceof NoSuchPropertyException && devMode &&
logMissingProperties;
+ private boolean shouldLogMissingPropertyWarning(OgnlException e) {
+ return (e instanceof NoSuchPropertyException || e instanceof
MethodFailedException)
+ && devMode && logMissingProperties;
}
private Object tryFindValue(String expr, Class asType) throws
OgnlException {