Hello,
I'm trying to use StringSubstitutor. Substitution in variables (recursive
substitution) is disabled.
When I run with a variable cycle, I don't expect an infinite loop because
recursive substitution is disabled. But I still get the exception:
java.lang.IllegalStateException: Infinite loop in property interpolation of
my template ${cycle}: cycle.
See example code below.
import java.util.Map;
import org.apache.commons.text.StringSubstitutor;
public class TestCycles {
public static void main(String[] args) {
final Map<String, Object> cycleMap = Map.of("cycle", "${cycle}");
final StringSubstitutor sub = new StringSubstitutor(cycleMap)
.setEnableSubstitutionInVariables(false);
String res = sub.replace("my template ${cycle}");
}
}
Is this the expected behavior, or do you think this should be fixed?
Thanks.
--
[image: StarTree] <https://startree.ai>
Cyril de Catheu
Software Engineer
+33 (684) 829-908 <+33+(684)+829-908>
Follow us: [image: RSS] <https://www.startree.ai/blogs>[image: LinkedIn]
<https://www.linkedin.com/company/startreedata/>[image: Twitter]
<https://twitter.com/startreedata>[image: Slack]
<https://stree.ai/slack>[image:
YouTube] <https://youtube.com/StarTreeData>
[image: Try StarTree Cloud Today]
<https://get.startree.ai/startree-cloud?utm_campaign=byoc-edition-of-startree-cloud&utm_source=email&utm_content=startree-employee-email-signatures>