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

fails method name resolution for boolean JavaBean properties

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 2.7, 2.7.1
    • 2.7.1
    • Core Runtime
    • None
    • JDK 1.4.2/1.5

    Description

      We have a simple class with two JavaBean boolean properties notAvailable and available with the assessor methods isNotAvailable and isAvailable.

      OGNL runtime fails to method name resolution, for example:

      import ognl.Node;

      import ognl.Ognl;

      import ognl.OgnlContext;

      public class BooleanMethodOGNL {

      public class BooleanTest {

      public boolean isNotAvailable()

      { return false; }

      public boolean isAvailable()

      { return true; }

      }

      public BooleanTest test = new BooleanTest();

      public static void main(String[] args) {

      OgnlContext context = new OgnlContext();

      try

      { System.out.println(((Node)Ognl.parseExpression("test.available")).toGetSourceString(context, new BooleanMethodOGNL())); System.out.println(((Node)Ognl.parseExpression("test.notAvailable")).toGetSourceString(context, new BooleanMethodOGNL())); }

      catch (Exception e)

      { e.printStackTrace(); }

      }

      }

      For both test the toGetSourceString method returns the same result: ".test.isNotAvailable()"

      Failure occurs in the method ognl.OgnlRuntime.getReadMethod(Class, String, int) when tries to resolve the boolean properties access methods.

      Probably the wrong if condition is:

      methods[i].getName().toLowerCase().endsWith(name.toLowerCase())

      Attachments

        Activity

          People

            jkuhnert Jesse Kuhnert
            frdavid David Frontini
            Votes:
            1 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: