mirror of
https://github.com/apache/struts.git
synced 2026-08-05 22:56:59 +00:00
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. git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/trunk@1520763 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@@ -203,10 +203,15 @@ public class OgnlValueStack implements Serializable, ValueStack, ClearableValueS
|
||||
}
|
||||
|
||||
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 Serializable, ValueStack, ClearableValueS
|
||||
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 Serializable, ValueStack, ClearableValueS
|
||||
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 {
|
||||
|
||||
Reference in New Issue
Block a user