nickbabcock opened a new pull request #115:  Fix length change omission for 
StringSubstitutor cyclic detection 
URL: https://github.com/apache/commons-text/pull/115
 
 
   `StringSubstitutor#substitute` would throw `StringIndexOutOfBoundsException` 
when removing a variable start marker if `StringSubstitutor` wasn't using the 
internal representation of  `TextStringBuilder#buffer`. The local variable, 
`priorVariables`, contains unbalanced squirrely parentheses (replacing 
`$${${TEST}}` would cause `priorVariables` to add `${${TEST}}}` -- amusingly 
didn't result in unexpected behavior). I discovered this when swapping all 
instances of `buf.buffer` to `buf.toCharArray()`. This PR ensures that both now 
have equivalent behavior. I was unable to tease out a test for this, as the 
length is only decremented to that point (but this change in length goes 
unused, hence the exception for `toCharArray`), so no overflows. I did port a 
test from `StrSubstitutorTest.java`, but the test passes before and after this 
change.
   
   I believe this to be a trivial change (hence no JIRA ticket). Let me know if 
otherwise

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to