orpiske commented on code in PR #10388:
URL: https://github.com/apache/camel/pull/10388#discussion_r1230535929
##########
core/camel-core-languages/src/main/java/org/apache/camel/language/csimple/CSimpleHelper.java:
##########
@@ -163,6 +178,40 @@ public static String bodyOneLine(Exchange exchange) {
return body;
}
+ public static String prettyBody(Exchange exchange) {
+ String body = exchange.getIn().getBody(String.class);
+
+ if (body == null) {
+ return null;
+ } else if (body.startsWith("{") && body.endsWith("}") ||
body.startsWith("[") && body.endsWith("]")) {
+ body = Jsoner.prettyPrint(body); //json
+ } else if (body.startsWith("<") && body.endsWith(">")) {
+ return CSimpleHelper.prettyXml(body); //xml
+ }
+
+ return body;
+ }
+
+ private static String prettyXml(String rawXml) {
+ try {
+ InputSource src = new InputSource(new StringReader(rawXml));
Review Comment:
Please, can you confirm this won't leak? I am under the impression
`InputSource` won't close it (same thing if you use a `InputStream`).
--
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]