You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@struts.apache.org by ya...@apache.org on 2019/06/03 07:48:18 UTC
[struts] 04/05: decouple logMissingProperties from devMode (WW-4999)
This is an automated email from the ASF dual-hosted git repository.
yasserzamani pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/struts.git
commit eca9c34645882b7d28b5b2dab42c0c3b4a0b10a3
Author: Yasser Zamani <ya...@apache.org>
AuthorDate: Sat Jun 1 12:52:22 2019 +0430
decouple logMissingProperties from devMode (WW-4999)
(cherry picked from commit 9e01fbd)
---
.../main/java/com/opensymphony/xwork2/ognl/OgnlValueStack.java | 7 +++----
.../java/com/opensymphony/xwork2/ognl/OgnlValueStackTest.java | 10 +---------
2 files changed, 4 insertions(+), 13 deletions(-)
diff --git a/core/src/main/java/com/opensymphony/xwork2/ognl/OgnlValueStack.java b/core/src/main/java/com/opensymphony/xwork2/ognl/OgnlValueStack.java
index 3415b39..9fc7868 100644
--- a/core/src/main/java/com/opensymphony/xwork2/ognl/OgnlValueStack.java
+++ b/core/src/main/java/com/opensymphony/xwork2/ognl/OgnlValueStack.java
@@ -181,8 +181,7 @@ public class OgnlValueStack implements Serializable, ValueStack, ClearableValueS
private void trySetValue(String expr, Object value, boolean throwExceptionOnFailure, Map<String, Object> context) throws OgnlException {
context.put(XWorkConverter.CONVERSION_PROPERTY_FULLNAME, expr);
- context.put(REPORT_ERRORS_ON_NO_PROP, throwExceptionOnFailure || (devMode && logMissingProperties)
- ? Boolean.TRUE : Boolean.FALSE);
+ context.put(REPORT_ERRORS_ON_NO_PROP, throwExceptionOnFailure || logMissingProperties ? Boolean.TRUE : Boolean.FALSE);
ognlUtil.setValue(expr, context, root, value);
}
@@ -246,7 +245,7 @@ public class OgnlValueStack implements Serializable, ValueStack, ClearableValueS
}
protected void setupExceptionOnFailure(boolean throwExceptionOnFailure) {
- if (throwExceptionOnFailure || (devMode && logMissingProperties)) {
+ if (throwExceptionOnFailure || logMissingProperties) {
context.put(THROW_EXCEPTION_ON_FAILURE, true);
}
}
@@ -341,7 +340,7 @@ public class OgnlValueStack implements Serializable, ValueStack, ClearableValueS
protected boolean shouldLogMissingPropertyWarning(OgnlException e) {
return (e instanceof NoSuchPropertyException ||
(e instanceof MethodFailedException && e.getReason() instanceof NoSuchMethodException))
- && devMode && logMissingProperties;
+ && logMissingProperties;
}
private Object tryFindValue(String expr, Class asType) throws OgnlException {
diff --git a/core/src/test/java/com/opensymphony/xwork2/ognl/OgnlValueStackTest.java b/core/src/test/java/com/opensymphony/xwork2/ognl/OgnlValueStackTest.java
index e4b13a0..5fa8aa8 100644
--- a/core/src/test/java/com/opensymphony/xwork2/ognl/OgnlValueStackTest.java
+++ b/core/src/test/java/com/opensymphony/xwork2/ognl/OgnlValueStackTest.java
@@ -248,7 +248,6 @@ public class OgnlValueStackTest extends XWorkTestCase {
public void testLogMissingProperties() {
OgnlValueStack vs = createValueStack();
- vs.setDevMode("true");
vs.setLogMissingProperties("true");
Dog dog = new Dog();
@@ -279,7 +278,6 @@ public class OgnlValueStackTest extends XWorkTestCase {
public void testNotLogUserExceptionsAsMissingProperties() {
OgnlValueStack vs = createValueStack();
- vs.setDevMode("true");
vs.setLogMissingProperties("true");
Dog dog = new Dog();
@@ -301,13 +299,7 @@ public class OgnlValueStackTest extends XWorkTestCase {
vs.findValue("getBite()", false);
vs.findValue("getBite()", void.class, false);
- assertEquals(8, 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());
- }
+ assertEquals(0, testAppender.logEvents.size());
} finally {
testAppender.stop();
logger.removeAppender(testAppender);