[ https://issues.apache.org/jira/browse/BEANUTILS-533?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17051629#comment-17051629 ]
Melloware edited comment on BEANUTILS-533 at 3/4/20, 9:09 PM: -------------------------------------------------------------- I just updated the DefaultResolverTestCase unit test with your new property values and verified your issue. {code:java} // Mapped Properties Test Data private final String[] validMapProperties = new String[] {"a(b)", "c(de)", "fg(h)", "ij(kl)", "mno(pqr.s)", "tuv(wx).yz[1]", "test(myvalue(ineedthisparenthis))"}; private final String[] validMapNames = new String[] {"a", "c", "fg", "ij", "mno", "tuv", "test"}; private final String[] validMapKeys = new String[] {"b", "de", "h", "kl", "pqr.s", "wx", "myvalue(ineedthisparenthis)"}; {code} was (Author: melloware): I just updated the DefaultResolverTestCase unit test with you new property values against the code in MASTER and its working fine. {code:java} // Mapped Properties Test Data private final String[] validMapProperties = new String[] {"a(b)", "c(de)", "fg(h)", "ij(kl)", "mno(pqr.s)", "tuv(wx).yz[1], test(myvalue(ineedthisparenthis))"}; private final String[] validMapNames = new String[] {"a", "c", "fg", "ij", "mno", "tuv", "test"}; private final String[] validMapKeys = new String[] {"b", "de", "h", "kl", "pqr.s", "wx", "myvalue(ineedthisparenthis)"}; {code} > If expression contains ")", DefaultResolver #getKey return wrong value > ---------------------------------------------------------------------- > > Key: BEANUTILS-533 > URL: https://issues.apache.org/jira/browse/BEANUTILS-533 > Project: Commons BeanUtils > Issue Type: Bug > Components: Bean / Property Utils > Affects Versions: 1.7.0, 1.8.0, 1.9.0, 1.9.3 > Reporter: Maxime Garenne > Priority: Blocker > > h2. 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)) > h2. 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 : > {code:java} > final int end = expression.indexOf(MAPPED_END, i);{code} > 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 > -- This message was sent by Atlassian Jira (v8.3.4#803005)