coheigea commented on code in PR #397:
URL: https://github.com/apache/cxf-xjc-utils/pull/397#discussion_r4256859230
##########
runtime/src/main/java/org/apache/cxf/xjc/runtime/JAXBToStringStyle.java:
##########
@@ -77,8 +82,96 @@ class JAXBToStringStyleImpl extends ToStringStyle {
protected void appendDetail(StringBuffer buffer, String fieldName, Object
value) {
if (value instanceof JAXBElement) {
buffer.append(ToStringBuilder.reflectionToString(value, this));
+ } else {
+ appendValue(buffer, value);
+ }
+ }
+
+ @Override
+ protected void appendDetail(StringBuffer buffer, String fieldName, char
value) {
+ appendEscaped(buffer, String.valueOf(value));
+ }
+
+ /*
+ * Older commons-lang3 releases append collections and maps via their own
+ * toString(), which bypasses both the escaping below and cycle detection.
+ * Route each element through appendInternal instead (as commons-lang3
+ * 3.21+ does), keeping the AbstractCollection/AbstractMap layout.
+ */
+ @Override
+ protected void appendDetail(StringBuffer buffer, String fieldName,
Collection<?> coll) {
+ buffer.append('[');
Review Comment:
Thanks @reta, yes it’s intentional. commons-lang3 3.21+ already does this
itself: ToStringStyle.appendDetail(Collection/Map) routes each element through
appendInternal, so elements get escaped and cycle-checked. Older releases just
append coll.toString()/map.toString(), which bypasses both. Since commons-lang3
is an optional dependency of the runtime, the overrides copy the 3.21 behaviour
so that it applies on any version. I’ve pushed a small update that makes the
overrides match 3.21 exactly (separators and null map entries, with an explicit
null check because appendInternal(null) throws an NPE on older releases). With
3.21, the output is now unchanged from before this PR for anything without
control characters.
--
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]