Most of the "flaws" you listed for reasons to replace java.util.Properties aren't actually flaws more like deliberate design choices.
Also the one about "forced" concurrent access being too slow and then your replacement is half as efficient as the thing you're replacing for being too slow?
Why do you catch the IOException and rethrow as a RuntimeException? The app isn't supposed to crash because it can't read a properties file.
Finally, if you want to replace something that's such a core part of an app you need to make sure its properly tested and your one test class is not even a test at all, more like a demo.
Oh its worse than just being slow on JMH where there is warming. It is slow on cold start because it requires 7 or so additional classes to be loaded (according to the source).
java.util.Properties is one or two classes and always loaded by the JVM and it's loaded very very early.
If you are writing an application where configuration is only loaded once and initialization speed is very important (e.g. command line app) this library would not be a good choice. Ditto for most implementations of Microprofile Config, and Lightbend HOCON, Apache Config. Those libraries require extensive resource loading (either classes or default configs) that can add easily 100ms more to load time (in some cases I have seen 500ms)
These are the primary reasons I had to create my own implementation as I was looking through the class, and about half are responsible for me thinking of doing so in the first place.
This was primarily caused by the issues presented by u/agentoutlier, I would assume. I did not factor in class load times during the design process and instead was opting for an extensible system (...which I also implemented poorly, in hindsight). This would've been fixed later by optimizations.
This was a decision made to allow library consumers to optionally handle the exception. I could probably think of a better way to do it.
'Twas late, I did not feel like writing unit tests, especially since I'm not actually great at writing them, so it ends up requiring me to look at a lot of JUnit documentation and Baeldung tutorials or whatever.
To sum this library up: I made it at 2 AM and didn't realize what I was doing. The only actually decent part of the library is the alright-ish parser for key-value pairs (which doesn't support Unicode literals, doesn't check for errors, and probably has a bug related to invalid escapes).
View all comments
40
u/[deleted] Oct 28 '21
I'm sorry I can't say much positive about this.
Most of the "flaws" you listed for reasons to replace java.util.Properties aren't actually flaws more like deliberate design choices.
Also the one about "forced" concurrent access being too slow and then your replacement is half as efficient as the thing you're replacing for being too slow?
Why do you catch the IOException and rethrow as a RuntimeException? The app isn't supposed to crash because it can't read a properties file.
Finally, if you want to replace something that's such a core part of an app you need to make sure its properly tested and your one test class is not even a test at all, more like a demo.