On 09/01/2020 09:35, Patrick Reinhart wrote:
He everyone,
When loading a properties file using java.util.Properties.load() the
behaviour for duplicate key values is not yet specified.
The actual implementation overwrites existing key/value defined within
the current file by the further down without any warning or exception.
This has lead to various hard to detect errors as in big property
files, where multiple existences of the same property key.
I would like to extend the existing specification in that regard that
only the first key/value pair will be taken into account and be added
to the properties.
Alternatively new methods using this behaviour could also introduced...
Changing long standing behavior when properties files have duplicate
keys could be problematic, esp. if there are properties files are
bundled with a library that is deployed with different JDK releases.
There was another discussion here recently about storing properties in
canonical form, JDK-8231640 [1] was created to look into that. I only
mention because there is other "projects" in this area if you want to
look into that too.
-Alan
[1] https://bugs.openjdk.java.net/browse/JDK-8231640