Copilot commented on code in PR #489:
URL:
https://github.com/apache/maven-build-cache-extension/pull/489#discussion_r3241107529
##########
src/main/java/org/apache/maven/buildcache/xml/CacheConfigImpl.java:
##########
@@ -661,6 +662,11 @@ private String getProperty(String key, String
defaultValue) {
return value;
}
+ private int getProperty(String key, int defaultValue) {
+ String property = getProperty(key, String.valueOf(defaultValue));
+ return Integer.parseInt(property);
Review Comment:
Parsing the property value with `Integer.parseInt` will throw a
`NumberFormatException` with a generic message (e.g. `For input string: "abc"`)
if a user passes a non-numeric value via
`-Dmaven.build.cache.maxLocalBuildsCached=...`. Consider catching the exception
and producing a clearer error that names the offending property, or at minimum
logging a warning and falling back to the XML default. Additionally, there is
no validation that the parsed value is non-negative; a negative or zero value
silently flows through to the cache retention logic.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]