Fixed
Details
Assignee
Patrick SchweizerPatrick SchweizerReporter
Patrick SchweizerPatrick SchweizerSprint
NoneFix versions
Priority
Minor
Details
Details
Assignee
Patrick Schweizer
Patrick SchweizerReporter
Patrick Schweizer
Patrick SchweizerSprint
None
Fix versions
Priority
PagerDuty
PagerDuty
PagerDuty
Created November 27, 2018 at 11:28 PM
Updated January 25, 2019 at 1:57 PM
Resolved January 25, 2019 at 1:57 PM
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.
Idea:
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)