You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Cyril de Catheu (Jira)" <ji...@apache.org> on 2023/01/14 20:59:00 UTC
[jira] [Closed] (TEXT-223) StringSubstitutor checks for cycles even if recursive substitution is disabled
[ https://issues.apache.org/jira/browse/TEXT-223?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Cyril de Catheu closed TEXT-223.
--------------------------------
Resolution: Not A Bug
> StringSubstitutor checks for cycles even if recursive substitution is disabled
> ------------------------------------------------------------------------------
>
> Key: TEXT-223
> URL: https://issues.apache.org/jira/browse/TEXT-223
> Project: Commons Text
> Issue Type: Bug
> Affects Versions: 1.10.0
> Reporter: Cyril de Catheu
> Priority: Minor
>
> *Issue*
> StringSubstitutor can perform [recursive variable replacements|https://commons.apache.org/proper/commons-text/apidocs/org/apache/commons/text/StringSubstitutor.html#:~:text=recursive].
> If there is a cycle, an IllegalStateException is thrown.
> When using StringSubstitutor with recursive substitution disabled, an exception is still thrown in case of cycles.
> *Expected behavior*
> No exception should be thrown. There is no cycle because the replacement is not recursive.
> *How to reproduce*
> {code:java}
> import java.util.Map;
> import org.apache.commons.text.StringSubstitutor;
> public class TestCycles {
> public static void main(String[] args) {
> Map<String, Object> cycleMap = Map.of("cycle", "${cycle}");
> StringSubstitutor sub = new StringSubstitutor(cycleMap).setEnableSubstitutionInVariables(false);
> String res = sub.replace("my template ${cycle}");
> }
> }
> {code}
> Will throw
> {code:java}
> java.lang.IllegalStateException: Infinite loop in property interpolation of my template ${cycle}: cycle.{code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)