diff --git a/config/src/main/java/com/typesafe/config/impl/SimpleConfigDocument.java b/config/src/main/java/com/typesafe/config/impl/SimpleConfigDocument.java index 88cac073..f9786a01 100644 --- a/config/src/main/java/com/typesafe/config/impl/SimpleConfigDocument.java +++ b/config/src/main/java/com/typesafe/config/impl/SimpleConfigDocument.java @@ -1,9 +1,7 @@ package com.typesafe.config.impl; +import com.typesafe.config.*; import com.typesafe.config.parser.ConfigDocument; -import com.typesafe.config.ConfigParseOptions; -import com.typesafe.config.ConfigValue; -import com.typesafe.config.ConfigException; import java.io.StringReader; import java.util.Iterator; @@ -34,7 +32,9 @@ final class SimpleConfigDocument implements ConfigDocument { public ConfigDocument withValue(String path, ConfigValue newValue) { if (newValue == null) throw new ConfigException.BugOrBroken("null value for " + path + " passed to withValue"); - return withValueText(path, newValue.render().trim()); + ConfigRenderOptions options = ConfigRenderOptions.defaults(); + options = options.setOriginComments(false); + return withValueText(path, newValue.render(options).trim()); } @Override diff --git a/config/src/test/scala/com/typesafe/config/impl/ConfigDocumentTest.scala b/config/src/test/scala/com/typesafe/config/impl/ConfigDocumentTest.scala index ae0a783e..d8e34cce 100644 --- a/config/src/test/scala/com/typesafe/config/impl/ConfigDocumentTest.scala +++ b/config/src/test/scala/com/typesafe/config/impl/ConfigDocumentTest.scala @@ -438,11 +438,11 @@ class ConfigDocumentTest extends TestUtils { assertEquals("a : 1", configDocument.withValueText("a", "1").render) val mapVal = ConfigValueFactory.fromAnyRef(Map("a" -> 1, "b" -> 2).asJava) - assertEquals("a : {\n # hardcoded value\n \"a\" : 1,\n # hardcoded value\n \"b\" : 2\n}", + assertEquals("a : {\n \"a\" : 1,\n \"b\" : 2\n}", configDocument.withValue("a", mapVal).render) val arrayVal = ConfigValueFactory.fromAnyRef(List(1, 2).asJava) - assertEquals("a : [\n # hardcoded value\n 1,\n # hardcoded value\n 2\n]", configDocument.withValue("a", arrayVal).render) + assertEquals("a : [\n 1,\n 2\n]", configDocument.withValue("a", arrayVal).render) } @Test @@ -452,7 +452,7 @@ class ConfigDocumentTest extends TestUtils { val configVal = ConfigValueFactory.fromAnyRef(Map("a" -> 1, "b" -> 2).asJava) - assertEquals("{ a : {\n # hardcoded value\n \"a\" : 1,\n # hardcoded value\n \"b\" : 2\n } }", + assertEquals("{ a : {\n \"a\" : 1,\n \"b\" : 2\n } }", configDocument.withValue("a", configVal).render) } }