Uploaded image for project: 'Commons OGNL (Dormant)'
  1. Commons OGNL (Dormant)
  2. OGNL-169

When setting parameters OGNL only tries to match arguments with the first accessor method

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 3.0
    • None
    • PropertyAccessors
    • None
    • Struts2.2.1

      Java 1.5_08

      Windows/Unix
    • Important

    Description

      I have an object with two methods:

      class Something

      {

      public void setStartDate(Calendar date)

      { <some code> }

      public void setStartDate(String date) { <some other code> }

      }



      OGNL sometimes fails to call the second method when given a String parameter.



      I've stepped through the code in debug and what appears to be happening is that when I try to set Something.StartDate with a string (submitting a form via struts) OGNL tries only one method for compatibility. I can see it finding both accessor methods (it gets both) but then it goes through looking for compatible parameters and doesn't try both.



      This has an unfortunate side effect (I think because of slight variations in java compiler). If I build and test the application with irrelevant changes and it works some of the time. My best guess is that every so often Java creates the .class file with one method first and other time with the other first.



      The work around is to rename my methods and change the jsp files so I have:



      class Something

      {

      public void setStartDate(Calendar date) { <some code> }

      public void setStartDateWithString(String date)

      { <some other code> }

      }

      Major because it sometimes causes a system that passes all testing to then fail when rolled out to live.

      Attachments

        Activity

          People

            jkuhnert Jesse Kuhnert
            andychapman Andy Chapman
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: