ruanwenjun commented on code in PR #10612:
URL: https://github.com/apache/dolphinscheduler/pull/10612#discussion_r906662332


##########
dolphinscheduler-log-server/src/main/java/org/apache/dolphinscheduler/server/log/LoggerRequestProcessor.java:
##########
@@ -113,8 +114,22 @@ public void process(Channel channel, Command command) {
                 List<String> lines = readPartFileContent(rollViewLogPath,
                         rollViewLogRequest.getSkipLineNum(), 
rollViewLogRequest.getLimit());
                 StringBuilder builder = new StringBuilder();
+                final int MaxResponseLogSize = 65535;
                 for (String line : lines) {
-                    builder.append(line).append("\r\n");
+                    //If a single line of log is exceed max response size, cut 
off the line
+                    if (line.getBytes(StandardCharsets.UTF_8).length >= 
MaxResponseLogSize) {
+                        builder.append(line, 0, MaxResponseLogSize)
+                                .append(" [this line' size is exceed ")
+                                .append(MaxResponseLogSize).append(" bytes, so 
only ")
+                                .append(MaxResponseLogSize).append(" 
characters are reserved for performance reasons.]")
+                                .append("\r\n");
+                    }else {
+                        builder.append(line).append("\r\n");
+                    }
+
+                    if 
(builder.toString().getBytes(StandardCharsets.UTF_8).length >= 
MaxResponseLogSize) {
+                        break;

Review Comment:
   I worry this method will be very slow, you already calculate the size of 
each line, you don't need to calculate the size again.



-- 
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]

Reply via email to