diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/component/Dumpable.java b/jetty-util/src/main/java/org/eclipse/jetty/util/component/Dumpable.java index 748c678167f..37efb48a2e9 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/component/Dumpable.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/component/Dumpable.java @@ -70,6 +70,15 @@ public interface Dumpable return b.toString(); } + /** + * The description of this/self found in the dump. + * Allows for alternative representation of Object other then .toString() + * where the long form output of toString() is represented in a cleaner way + * within the dump infrastructure. + * + * @return the representation of self + */ + default String dumpSelf() { return toString(); } /** * Dump just an Object (but not it's contained items) to an Appendable. @@ -90,6 +99,8 @@ public interface Dumpable s = String.format("%s@%x[size=%d]",o.getClass().getComponentType(),o.hashCode(), Array.getLength(o)); else if (o instanceof Map) s = String.format("%s@%x{size=%d}",o.getClass().getName(),o.hashCode(),((Map)o).size()); + else if (o instanceof Dumpable) + s = ((Dumpable)o).dumpSelf().replace("\r\n","|").replace("\n","|"); else s = String.valueOf(o).replace("\r\n","|").replace("\n","|");