private String extractValue(Object value) {
if (value == null) return "null";
if (value instanceof BeanReference) {
return "@" + ((BeanReference) value).getBeanName();
}
if (value instanceof BeanDefinition) {
String className = ((BeanDefinition) value).getBeanClassName();
if (className != null) {
return className.substring(className.lastIndexOf('.') + 1);
}
return "InnerBean";
}
if (value instanceof TypedStringValue) {
return xmlEscape(((TypedStringValue) value).getValue());
}
if (value instanceof List) {
List<String> cleaned = new ArrayList<>();
int count = 0;
for (Object item : (List<?>) value) {
if (count++ >= 10) { cleaned.add("..."); break; }
// Use a placeholder for the break so we don't escape it yet
cleaned.add(extractValue(item));
}
// Join with a literal tag that Graphviz understands
return String.join("<BR ALIGN=\"LEFT\"/>", cleaned);
}
// For maps and other objects
String s = value.toString();
return xmlEscape(s.length() > 60 ? s.substring(0, 57) + "..." : s);
}
private String xmlEscape(String input) {
if (input == null) return "";
// Basic escaping but KEEPING it safe for the final label string
return input.replace("&", "&")
.replace("<", "<")
.replace(">", ">")
.replace("\"", """)
.replace("'", "'");
}
// This is the CRITICAL change in the main loop:
// When building the label, do NOT escape the final string again.
// dot.append(String.format("<TD ALIGN=\"LEFT\">%s</TD>", cleanVal));
For further actions, you may consider blocking this person and/or reporting abuse
Top comments (0)