Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Copy link

Copilot AI Aug 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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().

Suggested change
String msg = String.format("property %s has non string value %s", entry.getKey(), entry.getValue());
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());

Copilot uses AI. Check for mistakes.
throw new IllegalArgumentException(msg);
}
}
return properties;
}

public int getServerId() {
return serverId;
}
Expand Down