EcsJsonSerializer { public static void serializeFormattedMessage(StringBuilder builder, String message) { builder.append("\"message\":\""); JsonUtils.quoteAsString(message, builder); builder.append("\", "); }  static CharSequence toNullSafeString(final CharSequence s); static void serializeObjectStart(StringBuilder builder, long timeMillis); static void serializeObjectEnd(StringBuilder builder); static void serializeLoggerName(StringBuilder builder, String loggerName); static void serializeThreadName(StringBuilder builder, String threadName); static void serializeThreadId(StringBuilder builder, long threadId); static void serializeFormattedMessage(StringBuilder builder, String message); static void serializeServiceName(StringBuilder builder, String serviceName); static void serializeEventDataset(StringBuilder builder, String eventDataset); static void serializeLogLevel(StringBuilder builder, String level); static void serializeTag(StringBuilder builder, String tag); static void serializeTagStart(StringBuilder builder); static void serializeSingleTag(StringBuilder builder, String tag); static void serializeTagEnd(StringBuilder builder); static void serializeOrigin(StringBuilder builder, StackTraceElement stackTraceElement); static void serializeOrigin(StringBuilder builder, String fileName, String methodName, int lineNumber); static void serializeMDC(StringBuilder builder, Map<String, ?> properties); static void serializeException(StringBuilder builder, Throwable thrown, boolean stackTraceAsArray); static void serializeException(StringBuilder builder, String exceptionClassName, String exceptionMessage, String stackTrace, boolean stackTraceAsArray); static void removeIfEndsWith(StringBuilder sb, String ending); static boolean endsWith(StringBuilder sb, String ending); static StringBuilder getMessageStringBuilder(); static String computeEventDataset(String eventDataset, String serviceName);  }
@Test void serializeNullDoesNotThrowAnException() throws JsonProcessingException { StringBuilder stringBuilder = new StringBuilder(); EcsJsonSerializer.serializeFormattedMessage(stringBuilder, null); assertThat(stringBuilder.toString()).isEqualTo("\"message\":\"null\", "); }