diff --git a/config/src/main/java/com/typesafe/config/impl/SimpleConfigObject.java b/config/src/main/java/com/typesafe/config/impl/SimpleConfigObject.java index ef69c688..4c05008d 100644 --- a/config/src/main/java/com/typesafe/config/impl/SimpleConfigObject.java +++ b/config/src/main/java/com/typesafe/config/impl/SimpleConfigObject.java @@ -606,7 +606,7 @@ public boolean containsKey(Object key) { @Override public Set keySet() { - return value.keySet(); + return Collections.unmodifiableSet(value.keySet()); } @Override diff --git a/config/src/test/scala/com/typesafe/config/impl/ConfigValueTest.scala b/config/src/test/scala/com/typesafe/config/impl/ConfigValueTest.scala index cf30273a..5857f454 100644 --- a/config/src/test/scala/com/typesafe/config/impl/ConfigValueTest.scala +++ b/config/src/test/scala/com/typesafe/config/impl/ConfigValueTest.scala @@ -491,6 +491,8 @@ class ConfigValueTest extends TestUtils { unsupported { m.put("hello", intValue(42)) } unsupported { m.putAll(Collections.emptyMap[String, AbstractConfigValue]()) } unsupported { m.remove("a") } + unsupported { m.keySet().remove("a") } + unsupported { m.keySet().clear() } } @Test