struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Miguel Almeida <mig...@almeida.at>
Subject Private setter method breaking application in Tomcat7
Date Wed, 20 Feb 2013 13:59:59 GMT
Following a chat with Lukasz on IRC, I post a weird behaviour I got this
morning.

Example:
- QueryAction class with a int selectedParent property
- url on a webpage pointing to:
QueryqueryConversation.action?selectedParent=2
- an action mapping <action name="Query*" method="{1}"
class="queryAction">
- Application packaged in .war and deployed in two containers: tomcat6
and tomcat7

Problem:
1) In tomcat7 the selectedParent int was 0 when entering the
queryConversation method. in tomcat6 the variable was correctly set to
2.
2) Get request had the correct string:
"GET /edc-test/QueryqueryConversation.action?selectedParent=2 HTTP/1.1"
3) Params interceptor was picking up the parameter: DEBUG
ParametersInterceptor:68 - Setting params selectedParent => [ 2 ]

Resolution:
I found out the issue was related to the fact that we had two
setSelectedParent methods in the Action class:
- public void setSelectedParent(int selectedParent)
- private void setSelectedParent(ObjectX anotherObjectType)

Renaming the second method (I've always said naming methods with get/set
prefix should be reserved to..well, getters/setters) solved the problem.

Questions:
Two questions remain a mystery to me thought:
1) Why is Tomcat7 the only container complaining? Neither tomcat6 nor
our embedded jetty containers complain about this
2) Even though the method's name should be changed, I also find it
strange that this is a problem when the 2nd method is private.


Any thoughts appreciated,

Miguel Almeida


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message