[ https://issues.apache.org/struts/browse/WW-3306?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=47030#action_47030 ]
Andreas Krüger commented on WW-3306:
------------------------------------
Thank you. This is already better.
But, unfortunately our real world application still wasn't happy.
To reproduce the problem the real world application exposes,
I enhanced the model class and the jsp as follows.
When this bug is solved, the enhanced JSP as below should not throw an error,
even if struts.el.throwExceptionOnFailure=true .
========================================
public class StrutsBugModel {
final private StrutsBugModel deep;
public StrutsBugModel() {
this(true);
}
private StrutsBugModel(boolean needDeep) {
if(needDeep)
deep = new StrutsBugModel(false);
else
deep = null;
}
public String getModelprop() {return null;}
public void setModelprop(String foo) {throw new UnsupportedOperationException();}
public StrutsBugModel getDeep() {return deep;}
public void setDeep(StrutsBugModel deep) {throw new UnsupportedOperationException();}
@Override
public String toString() {
if(deep == null)
return "shallow model";
else
return "deep model";
}
}
========================================
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
Weird struts behaviour
Weird struts behaviour
See https://issues.apache.org/struts/browse/WW-3306 .
All of these work
Property modelprop
from the model is null, as <s:if>
is happy to tell us.
Property modelprop
from the model is not null. (Well, it is, so this text never shows.)
Property actionprop
from the action is null, as <s:if>
is happy to tell us.
Property actionprop
from the action is not null. (Well, it is, so this text never shows.)
Applying a null into the text, from an action property, here it comes: “” -
this works and causes no problems, even though we have set
struts.el.throwExceptionOnFailure=true
in struts.properties
.
This now works - it did not before
Applying a null into the text from a model property, here it comes: “”.
This does not work: Nested property with null value
Accessing a nested property (via toString()
) isn't in itself a problem: “”
Accessing a nested null property: “”
Click here to expose the bug.
========================================
For the record:
We want our test environment to deviate from the production environment
as little as possible, and we will not (be allowed to) use a non-released
version in our production environment. So this is what I did for the test:
svn co -r2059 http://svn.opensymphony.com/svn/xwork/trunk xwork
svn merge -r2063:2064 http://svn.opensymphony.com/svn/xwork/trunk xwork
find xwork -name pom.xml | xargs grep -l 2.1.6 /dev/null |
xargs perl -i.oripom -wpe 's/2\.1\.6/2.1.6.1/'
cd xwork
Then, DefaultValidatorFileParserTest#testParserWithBadXML2() gave line number -1,
not the expected line number 8. I worked around this problem (without fixing).
Secondly, org.apache.maven.shared:maven-repository-builder:jar:1.0-alpha-1
could not be found. I went to xwork/assembly/pom.xml and changed the version
of maven-assembly-plugin to 2.2-beta-4 (twice).
After that,
mvn -U clean install
mvn -U source:jar
> Null value accepted from action property, but not model property when throwExceptionOnFailure=true
> --------------------------------------------------------------------------------------------------
>
> Key: WW-3306
> URL: https://issues.apache.org/struts/browse/WW-3306
> Project: Struts 2
> Issue Type: Bug
> Components: Value Stack
> Affects Versions: 2.2.0
> Reporter: Andreas Krüger
> Fix For: 2.2.0
>
>
> In this project, we experiment with setting struts.el.throwExceptionOnFailure=true to catch errors.
> We use in our JSP.
> Occasionally, the property thus referenced is null. We want struts to insert an empty string in that case.
> This it duely does, when either struts.el.throwExceptionOnFailure=false or when the property is from an action object.
> However, if the property is from a model object and struts.el.throwExceptionOnFailure=true, this bombs out.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.