IMO, the ExtendedProperties class has rather odd behaviour.

It is documented as an extension of normal Java properties, yet it
allows Objects to be used as values:

addProperty(String, Object)
setProperty(String, Object)

The save() method ignores anything but String and List<String>, so it
won't save such values.

The following sequence fails:

eprop.addProperty("xxx", "true");
eprop.getString("xxx");
eprop.getBoolean("xxx");
eprop.getString("xxx"); // ClassCastException: 'xxx' doesn't map to a
String object

This is because the call to getBoolean() replaces the String value
with a Boolean value.
Presumably this is intended to make it faster to retrieve next time,
but it's rather unexpected for a get() method to change the value.

Is this behaviour really intended?

If there really is a use case for including non-String values, then it
seems to me that load() and save() ought to handle these.

In any case, it seems to me that the get() behaviour ought to be changed.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
For additional commands, e-mail: dev-h...@commons.apache.org

Reply via email to