diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/LogUtils.java b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/LogUtils.java index b1337f1c8a52..23c34e6877b5 100644 --- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/LogUtils.java +++ b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/LogUtils.java @@ -26,7 +26,6 @@ import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; -import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Paths; import java.util.List; @@ -142,22 +141,22 @@ public static String readWholeFileContent(String filePath) { public static String rollViewLogLines(List lines) { StringBuilder builder = new StringBuilder(); - final int MaxResponseLogSize = 65535; - int totalLogByteSize = 0; + final int MaxResponseLogCharSize = 65535; + int totalLogCharSize = 0; for (String line : lines) { // If a single line of log is exceed max response size, cut off the line - final int lineByteSize = line.getBytes(StandardCharsets.UTF_8).length; - if (lineByteSize >= MaxResponseLogSize) { - builder.append(line, 0, MaxResponseLogSize) - .append(" [this line's size ").append(lineByteSize).append(" bytes is exceed ") - .append(MaxResponseLogSize).append(" bytes, so only ") - .append(MaxResponseLogSize).append(" characters are reserved for performance reasons.]") + final int lineCharSize = line.length(); + if (lineCharSize >= MaxResponseLogCharSize) { + builder.append(line, 0, MaxResponseLogCharSize) + .append(" [this line's size ").append(lineCharSize).append(" characters exceeds ") + .append(MaxResponseLogCharSize).append(" characters, so only ") + .append(MaxResponseLogCharSize).append(" characters are reserved for performance reasons.]") .append("\r\n"); } else { builder.append(line).append("\r\n"); } - totalLogByteSize += lineByteSize; - if (totalLogByteSize >= MaxResponseLogSize) { + totalLogCharSize += lineCharSize; + if (totalLogCharSize >= MaxResponseLogCharSize) { break; } }