diff --git a/micrometer-core/src/main/java/io/micrometer/core/instrument/util/JsonUtils.java b/micrometer-core/src/main/java/io/micrometer/core/instrument/util/JsonUtils.java index 4cffe69676..3da197ad12 100644 --- a/micrometer-core/src/main/java/io/micrometer/core/instrument/util/JsonUtils.java +++ b/micrometer-core/src/main/java/io/micrometer/core/instrument/util/JsonUtils.java @@ -15,73 +15,22 @@ */ package io.micrometer.core.instrument.util; +/** + * @deprecated this will be removed and should not be used + */ +@Deprecated public final class JsonUtils { private JsonUtils() { } /** - * Based on https://stackoverflow.com/a/49564514/510017 - * * @param unformattedJsonString JSON string that has not been formatted at all. - * @return A best-effort at pretty printed JSON, even for malformed JSON. + * @return the input string unchanged + * @deprecated this will be removed and no longer does anything meaningful */ + @Deprecated public static String prettyPrint(String unformattedJsonString) { - StringBuilder sb = new StringBuilder(); - int indentLevel = 0; - boolean inQuote = false; - for (char charFromUnformattedJson : unformattedJsonString.toCharArray()) { - switch (charFromUnformattedJson) { - case '"': - // switch the quoting status - inQuote = !inQuote; - sb.append(charFromUnformattedJson); - break; - case ' ': - // For space: ignore the space if it is not being quoted. - if (inQuote) { - sb.append(charFromUnformattedJson); - } - break; - case '{': - case '[': - // Starting a new block: increase the indent level - sb.append(charFromUnformattedJson); - indentLevel++; - appendIndentedNewLine(indentLevel, sb); - break; - case '}': - case ']': - // Ending a new block; decrese the indent level - indentLevel--; - appendIndentedNewLine(indentLevel, sb); - sb.append(charFromUnformattedJson); - break; - case ',': - // Ending a json item; create a new line after - sb.append(charFromUnformattedJson); - if (!inQuote) { - appendIndentedNewLine(indentLevel, sb); - } - break; - default: - sb.append(charFromUnformattedJson); - } - } - return sb.toString(); - } - - /** - * Print a new line with indention at the beginning of the new line. - * - * @param indentLevel - * @param stringBuilder - */ - private static void appendIndentedNewLine(int indentLevel, StringBuilder stringBuilder) { - stringBuilder.append("\n"); - for (int i = 0; i < indentLevel; i++) { - // Assuming indention using 2 spaces - stringBuilder.append(" "); - } + return unformattedJsonString; } } diff --git a/micrometer-core/src/main/java/io/micrometer/core/ipc/http/HttpSender.java b/micrometer-core/src/main/java/io/micrometer/core/ipc/http/HttpSender.java index 73256df9d3..8069a16de2 100644 --- a/micrometer-core/src/main/java/io/micrometer/core/ipc/http/HttpSender.java +++ b/micrometer-core/src/main/java/io/micrometer/core/ipc/http/HttpSender.java @@ -15,7 +15,6 @@ */ package io.micrometer.core.ipc.http; -import io.micrometer.core.instrument.util.JsonUtils; import io.micrometer.core.instrument.util.StringUtils; import io.micrometer.core.lang.Nullable; @@ -111,8 +110,6 @@ public String toString() { .append(url.toString()).append("\n"); if (entity.length == 0) { printed.append(""); - } else if ("application/json".equals(requestHeaders.get("Content-Type"))) { - printed.append(JsonUtils.prettyPrint(new String(entity))); } else { printed.append(new String(entity)); }