You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@struts.apache.org by "Brendan Le Ny (JIRA)" <ji...@apache.org> on 2014/11/25 12:16:12 UTC
[jira] [Updated] (WW-4424) When a property doesn't exists, the log
warn message always misses information
[ https://issues.apache.org/jira/browse/WW-4424?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Brendan Le Ny updated WW-4424:
------------------------------
Description:
As a developer, I write long JSPs and sometimes I make mistakes. For example, i can write the line underneath:
{code:xml}
<s:if test="ghamRestitution.moraHalfFoodFree">blah</s:if>
{code}
if the the field "moraHalfFoodFree" doesn't exists on bean "ghamRestitution", XWork raise a warn such as:
{quote}
2014/11/25 11:45:08 WARN (CommonsLogger.java:56) warn Could not find property [null]
{quote}
The problem is that the message always say "Count not find property [null]" and it's very hard for the developer to know where the bug is in a long JSP.
{code:title=com.opensymphony.xwork2.ognl.OgnlValueStack}
private Object handleOgnlException(String expr, boolean throwExceptionOnFailure, OgnlException e) {
Object ret = findInContext(expr);
if (ret == null) {
if (shouldLogMissingPropertyWarning(e)) {
LOG.warn("Could not find property [" + ((NoSuchPropertyException) e).getName() + "]");
}
if (throwExceptionOnFailure) {
throw new XWorkException(e);
}
}
return ret;
}
{code}
{quote}
((NoSuchPropertyException) e).getName()
{quote}
always returns null, instead we should use expr parameter which give the right information.
was:
As a developer, I write long JSPs and sometimes I make mistakes. For example, i can write the line underneath:
<s:if test="ghamRestitution.moraHalfFoodFree" >
if the the field "moraHalfFoodFree" doesn't exists on bean "ghamRestitution", XWork raise a warn such as:
2014/11/25 11:45:08 WARN (CommonsLogger.java:56) warn Could not find property [null]
The problem is that the message always say "Count not find property [null]" and it's very hard for the developer to know where the bug is in a long JSP.
The problem come from com.opensymphony.xwork2.ognl.OgnlValueStack#handleOgnlException
private Object handleOgnlException(String expr, boolean throwExceptionOnFailure, OgnlException e) {
Object ret = findInContext(expr);
if (ret == null) {
if (shouldLogMissingPropertyWarning(e)) {
LOG.warn("Could not find property [" + ((NoSuchPropertyException) e).getName() + "]");
}
if (throwExceptionOnFailure) {
throw new XWorkException(e);
}
}
return ret;
}
((NoSuchPropertyException) e).getName() always returns null, instead we should use expr parameter which give the right information.
> When a property doesn't exists, the log warn message always misses information
> ------------------------------------------------------------------------------
>
> Key: WW-4424
> URL: https://issues.apache.org/jira/browse/WW-4424
> Project: Struts 2
> Issue Type: Bug
> Components: Value Stack
> Affects Versions: 2.3.16.3
> Reporter: Brendan Le Ny
> Priority: Trivial
> Labels: easyfix
>
> As a developer, I write long JSPs and sometimes I make mistakes. For example, i can write the line underneath:
> {code:xml}
> <s:if test="ghamRestitution.moraHalfFoodFree">blah</s:if>
> {code}
> if the the field "moraHalfFoodFree" doesn't exists on bean "ghamRestitution", XWork raise a warn such as:
> {quote}
> 2014/11/25 11:45:08 WARN (CommonsLogger.java:56) warn Could not find property [null]
> {quote}
> The problem is that the message always say "Count not find property [null]" and it's very hard for the developer to know where the bug is in a long JSP.
> {code:title=com.opensymphony.xwork2.ognl.OgnlValueStack}
> private Object handleOgnlException(String expr, boolean throwExceptionOnFailure, OgnlException e) {
> Object ret = findInContext(expr);
> if (ret == null) {
> if (shouldLogMissingPropertyWarning(e)) {
> LOG.warn("Could not find property [" + ((NoSuchPropertyException) e).getName() + "]");
> }
> if (throwExceptionOnFailure) {
> throw new XWorkException(e);
> }
> }
> return ret;
> }
> {code}
> {quote}
> ((NoSuchPropertyException) e).getName()
> {quote}
> always returns null, instead we should use expr parameter which give the right information.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)