Copilot commented on code in PR #1274:
URL: https://github.com/apache/curator/pull/1274#discussion_r2284098321
##########
curator-test/src/main/java/org/apache/curator/test/InstanceSpec.java:
##########
@@ -209,11 +209,21 @@ public InstanceSpec(
this.tickTime = (tickTime > 0 ? tickTime : -1); // -1 to set default
value
this.maxClientCnxns = (maxClientCnxns >= 0 ? maxClientCnxns : -1); //
-1 to set default value
this.customProperties = customProperties != null
- ? Collections.<String, Object>unmodifiableMap(customProperties)
- : Collections.<String, Object>emptyMap();
+ ?
Collections.unmodifiableMap(enforceStringMap(customProperties))
+ : Collections.emptyMap();
this.hostname = hostname == null ? localhost : hostname;
}
+ private static Map<String, Object> enforceStringMap(Map<String, Object>
properties) {
+ for (Map.Entry<String, Object> entry : properties.entrySet()) {
+ if (!(entry.getValue() instanceof String)) {
+ String msg = String.format("property %s has non string value
%s", entry.getKey(), entry.getValue());
Review Comment:
The error message should include the expected type for clarity. Consider
changing to: "Property '%s' must have a string value, but found %s of type %s"
and include entry.getValue().getClass().getSimpleName().
```suggestion
String msg = String.format("Property '%s' must have a string
value, but found %s of type %s", entry.getKey(), entry.getValue(),
entry.getValue() == null ? "null" :
entry.getValue().getClass().getSimpleName());
```
--
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]