Status: Resolved (View Workflow)
Affects Version/s: None
Fix Version/s: 24.0.0
Security Level: Default (Default Security Scheme)
Sprint:Horizon - December 5th 2018, Horizon - December 12th 2018, Horizon - December 19th 2018, Horizon - January 9th 2019, Horizon - January 23rd 2019, Horizon - January 30th 2019
In order to get a System Property we use throughout opennms Integer.getInteger() instead of System.getProperty(). This saves us the conversion from a String to an int and thus makes the code more readable and simpler.
However we loose the ability to detect wrong / unusable values (a String that can't be converted to a number).
Integer.getInteger() just returns the default value. It would be desirable to log a wrong value and thus allow to find configuration problems easier.
- write a helper function to provide the same functionality as Integer.getInteger() but log invalid values
- replace all Integer.getInteger calls
- add a checkstyle check to prevent further usage of Integer.getInteger
The concept can of course not only be applied to Integer.getInteger but also to other value types such as primitives like Long.getLong() or Enums.
Also System.getProperty itself could be a candidate if we want to apply a restriction to the String value, like: String getString(String propertyName, String defaultValue, String regex)