You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Dale Newfield <Da...@Newfield.org> on 2008/03/06 06:56:19 UTC

Re: [struts] More Struts Insanity

Chris Pratt wrote:
> <!-- Equals(): <s:property
> value='%{originalMember.name.equals(currentMember.name)}'/> -->

Just to be pedantic, can you also verify that:

<!-- Equals(): <s:property 
value='%{currentMember.name.equals(originalMember.name)}'/> -->

yields:

<!-- Equals(): true -->

?
All correctly implemented equals methods are symmetric, so in the event 
OGNL decides that neither of these are null and that it should call the 
equals() method, it could theoretically do so in either order.  If the 
reversed order (above) throws an exception then that would explain the 
observed output.

Assuming that's not it, I'd suggest instrumenting your model to log when 
the equals and getName methods are called so you can verify it's making 
the calls you expect.

I agree it does seem strange.
Also:  Which version of ognl are you using?

-Dale

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: [struts] More Struts Insanity

Posted by Chris Pratt <th...@gmail.com>.
On Wed, Mar 5, 2008 at 10:53 PM, Dale Newfield <Da...@newfield.org> wrote:
> Chris Pratt wrote:
>  > <!-- Equals(): <s:property
>  > value='%{originalMember.name.equals(currentMember.name)}'/> -->
>
> > <!-- Equals(): <s:property
>  > value='%{CurrentMember.name.equals(originalMember.name)}'/> -->
>
>  Was that case typo (CurrentMember instead of currentMember) introduced
>  in transcription?  I would assume it would not have produced "true" if
>  it were in your code...
>

Yup, it was a typo in the test source, but surprisingly OGNL accepted
it and appeared to do the right thing.  I corrected it and ran the
test again with the same results.
  (*Chris*)

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: [struts] More Struts Insanity

Posted by Dale Newfield <Da...@Newfield.org>.
Chris Pratt wrote:
> <!-- Equals(): <s:property
> value='%{originalMember.name.equals(currentMember.name)}'/> -->
> <!-- Equals(): <s:property
> value='%{CurrentMember.name.equals(originalMember.name)}'/> -->

Was that case typo (CurrentMember instead of currentMember) introduced 
in transcription?  I would assume it would not have produced "true" if 
it were in your code...

-Dale

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: [struts] More Struts Insanity

Posted by Dave Newton <ne...@yahoo.com>.
--- Dale Newfield <Da...@Newfield.org> wrote:
> There's a chance those bugs were introduced between 2.6.11 and 2.7, but 
> I'm betting not.

Nope; it's in 2.6.9 at least. The behavior happens because of the
isAssignableFrom sequence I mentioned in my previous post.

Dave


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: [struts] More Struts Insanity

Posted by Dale Newfield <Da...@Newfield.org>.
Chris Pratt wrote:
> I added some instrumentation and it appears that OGNL is not calling
> the equals method when I use the == operator, only when I explicitly
> call .equals().

Look!  A clue!

> I believe the jar file is ognl-2.6.11.jar

Yep:

http://jira.opensymphony.com/browse/OGNL-96
http://jira.opensymphony.com/browse/OGNL-104

There's a chance those bugs were introduced between 2.6.11 and 2.7, but 
I'm betting not.

http://blog.opencomponentry.com/2008/02/01/ognl-272-released/

If you replace the .jar (you might also have/want to add javassist: 
http://www.csg.is.titech.ac.jp/~chiba/javassist ), does the problem go away?

-Dale

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: [struts] More Struts Insanity

Posted by Chris Pratt <th...@gmail.com>.
On Wed, Mar 5, 2008 at 9:56 PM, Dale Newfield <Da...@newfield.org> wrote:
> Chris Pratt wrote:
>  > <!-- Equals(): <s:property
>  > value='%{originalMember.name.equals(currentMember.name)}'/> -->
>
>  Just to be pedantic, can you also verify that:
>
>  <!-- Equals(): <s:property
>  value='%{currentMember.name.equals(originalMember.name)}'/> -->
>
>  yields:
>
>  <!-- Equals(): true -->
>
>  ?
>  All correctly implemented equals methods are symmetric, so in the event
>  OGNL decides that neither of these are null and that it should call the
>  equals() method, it could theoretically do so in either order.  If the
>  reversed order (above) throws an exception then that would explain the
>  observed output.

Yup, running:

<!-- Original: "<s:property value='%{originalMember.name}'/>" -->
<!-- Current:  "<s:property value='%{currentMember.name}'/>" -->
<!-- Equals(): <s:property
value='%{originalMember.name.equals(currentMember.name)}'/> -->
<!-- Equals(): <s:property
value='%{CurrentMember.name.equals(originalMember.name)}'/> -->
<!-- Equals:   <s:property value='%{originalMember.name ==
currentMember.name}'/> -->


Yields:

<!-- Original: "CHRIS PRATT" -->
<!-- Current:  "CHRIS PRATT" -->
<!-- Equals(): true -->
<!-- Equals(): true -->
<!-- Equals:    -->


>
>  Assuming that's not it, I'd suggest instrumenting your model to log when
>  the equals and getName methods are called so you can verify it's making
>  the calls you expect.

I added some instrumentation and it appears that OGNL is not calling
the equals method when I use the == operator, only when I explicitly
call .equals().

>
>  I agree it does seem strange.
>  Also:  Which version of ognl are you using?
>

I'm using the one that comes with 2.0.11.1 (and I've seen this on
2.0.11 also), I believe the jar file is ognl-2.6.11.jar
  (*Chris*)

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org