You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Given we have a following config, where we want to merge two maps (objects) and for formatting purposes we add a whitespace between them. When we render an unresolved ConfigObject, we get a wrong unparseable result:
var rendered = ConfigFactory.parseString(
"""
objectA {
a = "A"
}
objectB {
b = "B"
}
objectC = ${?objectA} ${objectB}
""",
ConfigParseOptions.defaults().setClassLoader(Thread.currentThread().getContextClassLoader()))
.root()
.render(ConfigRenderOptions.defaults());
The whitespace between objects is turned to a string containing a whitespace.
However, when we do resolve:
var rendered = ConfigFactory.parseString(
"""
objectA {
a = "A"
}
objectB {
b = "B"
}
objectC = ${?objectA} ${objectB}
""",
ConfigParseOptions.defaults().setClassLoader(Thread.currentThread().getContextClassLoader()))
.resolve()
.root()
.render(ConfigRenderOptions.defaults());
we get the correct result: {"objectA":{"a":"A"},"objectB":{"b":"B"},"objectC":{"a":"A","b":"B"}}
A workaround for this problem can be to not have a whitespace in the concatenation: objectC = ${?objectA}${objectB}
However, the actual fix of the bug should be done in the ConfigConcatenation#render. This class already contains a method isIgnoredWhitespace and it is used in join method to skip those formatting whitespaces. The solution can be easily applied by using the same isIgnoredWhitespace method to filter pieces in render method.
The text was updated successfully, but these errors were encountered:
Given we have a following config, where we want to merge two maps (objects) and for formatting purposes we add a whitespace between them. When we render an unresolved ConfigObject, we get a wrong unparseable result:
Result:
{"objectA":{"a":"A"},"objectB":{"b":"B"},"objectC":${?objectA}" "${objectB}}
The whitespace between objects is turned to a string containing a whitespace.
However, when we do resolve:
we get the correct result:
{"objectA":{"a":"A"},"objectB":{"b":"B"},"objectC":{"a":"A","b":"B"}}
A workaround for this problem can be to not have a whitespace in the concatenation:
objectC = ${?objectA}${objectB}
However, the actual fix of the bug should be done in the
ConfigConcatenation#render
. This class already contains a methodisIgnoredWhitespace
and it is used injoin
method to skip those formatting whitespaces. The solution can be easily applied by using the sameisIgnoredWhitespace
method to filter pieces inrender
method.The text was updated successfully, but these errors were encountered: