Open guerrillalg opened 4 months ago
So, the fix is there and everyone is ignoring it.. :(
See https://github.com/lightbend/config/issues/789 I have a Scala port mentioned there that is also Cross platform to Scala.js and Scala Native if you are interested.
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.