config icon indicating copy to clipboard operation
config copied to clipboard

Fix the Map spec implementation for ConfigObject.

Open radist-nt opened this issue 5 years ago • 3 comments

According to the Map specification, methods keySet, values and entrySet are backed by the map, so changes to the map are reflected in the collection, and vice-versa. ConfigObject interface extends Map, so it must conform the specification. Also, ConfigObject declared as immutable, so keySet, values and entrySet must return immutable collections.

radist-nt avatar May 24 '20 00:05 radist-nt

would it be simpler to wrap the value field in the constructor? though I suppose that uses memory more permanently so I don’t know.

havocp avatar May 24 '20 01:05 havocp

I had no idea about this! surprising Java fact. Thanks!

havocp avatar May 24 '20 01:05 havocp

would it be simpler to wrap the value field in the constructor? though I suppose that uses memory more permanently so I don’t know.

value is passing to the SimpleConfigObject constructor from one of the inner methods. There no way to check value instanceof Collections.UnmodifiableMap (because UnmodifiableMap is private), so we could obtain a Map wrapped several times. Another solution is to reconstruct Map in constructor, but it too expensive. Also, I think, keySet, entrySet and values are not often used method for ConfigObject.

radist-nt avatar May 24 '20 03:05 radist-nt

We do not intend to extend the functionality of "Typesafe Config" further. See https://github.com/lightbend/config#maintained-by

ennru avatar Jul 06 '23 08:07 ennru