Uploaded image for project: 'Commons BeanUtils'
  1. Commons BeanUtils
  2. BEANUTILS-533

If expression contains ")", DefaultResolver #getKey return wrong value

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Blocker
    • Resolution: Unresolved
    • 1.7.0, 1.8.0, 1.9.0, 1.9.3
    • None
    • Bean / Property Utils
    • None

    Description

      Context

      I use BeanUtils to return a map that contain properties.

      I had a failure in my code because this property causes a fail in the BeanUtils "getMappedProperty" method :

      test(myvalue(ineedthisparenthis))

      Explanation

      In DefaultResolver #getKey(String expression), if the expression contains a ")", the returned value is incorrect because the algorithm stops at the first ")" character (#indefOf is used).

      In my example, the method now returns : "myvalue(ineedthisparenthis". It should be "myvalue(ineedthisparenthis) with proprerty name = "test".

      Instead of using :

      final int end = expression.indexOf(MAPPED_END, i);

      It would be better to just check if the last character of "expression" is a ")" and then substring between "i+1" and last character index.

      Then my example would not fail. 

       

      This occurs in version 1.7.

      I checked in upper versions, the method is different but still wrong because the method indexOf is still used (taking again the first ")" found). 

       # escape # parenthesis # bracket # DefaultResolver # getKey # expression

       

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              Rekho Maxime Garenne
              Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated: