mirror of
https://github.com/apache/struts.git
synced 2026-08-18 04:56:58 +00:00
decouple logMissingProperties from devMode (WW-4999)
This commit is contained in:
@@ -182,8 +182,7 @@ public class OgnlValueStack implements Serializable, ValueStack, ClearableValueS
|
|||||||
|
|
||||||
private void trySetValue(String expr, Object value, boolean throwExceptionOnFailure, Map<String, Object> context) throws OgnlException {
|
private void trySetValue(String expr, Object value, boolean throwExceptionOnFailure, Map<String, Object> context) throws OgnlException {
|
||||||
context.put(XWorkConverter.CONVERSION_PROPERTY_FULLNAME, expr);
|
context.put(XWorkConverter.CONVERSION_PROPERTY_FULLNAME, expr);
|
||||||
context.put(REPORT_ERRORS_ON_NO_PROP, throwExceptionOnFailure || (devMode && logMissingProperties)
|
context.put(REPORT_ERRORS_ON_NO_PROP, throwExceptionOnFailure || logMissingProperties ? Boolean.TRUE : Boolean.FALSE);
|
||||||
? Boolean.TRUE : Boolean.FALSE);
|
|
||||||
ognlUtil.setValue(expr, context, root, value);
|
ognlUtil.setValue(expr, context, root, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -247,7 +246,7 @@ public class OgnlValueStack implements Serializable, ValueStack, ClearableValueS
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void setupExceptionOnFailure(boolean throwExceptionOnFailure) {
|
protected void setupExceptionOnFailure(boolean throwExceptionOnFailure) {
|
||||||
if (throwExceptionOnFailure || (devMode && logMissingProperties)) {
|
if (throwExceptionOnFailure || logMissingProperties) {
|
||||||
context.put(THROW_EXCEPTION_ON_FAILURE, true);
|
context.put(THROW_EXCEPTION_ON_FAILURE, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -342,7 +341,7 @@ public class OgnlValueStack implements Serializable, ValueStack, ClearableValueS
|
|||||||
protected boolean shouldLogMissingPropertyWarning(OgnlException e) {
|
protected boolean shouldLogMissingPropertyWarning(OgnlException e) {
|
||||||
return (e instanceof NoSuchPropertyException ||
|
return (e instanceof NoSuchPropertyException ||
|
||||||
(e instanceof MethodFailedException && e.getReason() instanceof NoSuchMethodException))
|
(e instanceof MethodFailedException && e.getReason() instanceof NoSuchMethodException))
|
||||||
&& devMode && logMissingProperties;
|
&& logMissingProperties;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Object tryFindValue(String expr, Class asType) throws OgnlException {
|
private Object tryFindValue(String expr, Class asType) throws OgnlException {
|
||||||
|
|||||||
@@ -247,7 +247,6 @@ public class OgnlValueStackTest extends XWorkTestCase {
|
|||||||
|
|
||||||
public void testLogMissingProperties() {
|
public void testLogMissingProperties() {
|
||||||
OgnlValueStack vs = createValueStack();
|
OgnlValueStack vs = createValueStack();
|
||||||
vs.setDevMode("true");
|
|
||||||
vs.setLogMissingProperties("true");
|
vs.setLogMissingProperties("true");
|
||||||
|
|
||||||
Dog dog = new Dog();
|
Dog dog = new Dog();
|
||||||
@@ -278,7 +277,6 @@ public class OgnlValueStackTest extends XWorkTestCase {
|
|||||||
|
|
||||||
public void testNotLogUserExceptionsAsMissingProperties() {
|
public void testNotLogUserExceptionsAsMissingProperties() {
|
||||||
OgnlValueStack vs = createValueStack();
|
OgnlValueStack vs = createValueStack();
|
||||||
vs.setDevMode("true");
|
|
||||||
vs.setLogMissingProperties("true");
|
vs.setLogMissingProperties("true");
|
||||||
|
|
||||||
Dog dog = new Dog();
|
Dog dog = new Dog();
|
||||||
@@ -300,13 +298,7 @@ public class OgnlValueStackTest extends XWorkTestCase {
|
|||||||
vs.findValue("getBite()", false);
|
vs.findValue("getBite()", false);
|
||||||
vs.findValue("getBite()", void.class, false);
|
vs.findValue("getBite()", void.class, false);
|
||||||
|
|
||||||
assertEquals(8, testAppender.logEvents.size());
|
assertEquals(0, testAppender.logEvents.size());
|
||||||
for (int i = 0; i < testAppender.logEvents.size(); i += 2) {
|
|
||||||
assertTrue(testAppender.logEvents.get(i).getMessage().getFormattedMessage()
|
|
||||||
.startsWith("Caught an exception while evaluating expression '"));
|
|
||||||
assertEquals("NOTE: Previous warning message was issued due to devMode set to true.",
|
|
||||||
testAppender.logEvents.get(i + 1).getMessage().getFormattedMessage());
|
|
||||||
}
|
|
||||||
} finally {
|
} finally {
|
||||||
testAppender.stop();
|
testAppender.stop();
|
||||||
logger.removeAppender(testAppender);
|
logger.removeAppender(testAppender);
|
||||||
|
|||||||
Reference in New Issue
Block a user