-
Notifications
You must be signed in to change notification settings - Fork 4.9k
[Fix-17139][Common] Fix rollViewLogLines IndexOutOfBoundsExceptionindex #17140
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Changes from 8 commits
650eaa6
5fb55dc
73c262b
54a7c5b
06ede9c
05c948a
92b8c4a
ef8dfc4
250d447
16b3b72
3bcc5f1
cbe55e8
951427a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
|
@@ -143,21 +142,21 @@ public static String readWholeFileContent(String filePath) { | |
public static String rollViewLogLines(List<String> lines) { | ||
StringBuilder builder = new StringBuilder(); | ||
final int MaxResponseLogSize = 65535; | ||
int totalLogByteSize = 0; | ||
int totalLogSize = 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) { | ||
final int lineSize = line.length(); | ||
if (lineSize >= MaxResponseLogSize) { | ||
builder.append(line, 0, MaxResponseLogSize) | ||
.append(" [this line's size ").append(lineByteSize).append(" bytes is exceed ") | ||
.append(" [this line's size ").append(lineSize).append(" bytes is exceed ") | ||
deng-jeffer marked this conversation as resolved.
Show resolved
Hide resolved
|
||
.append(MaxResponseLogSize).append(" bytes, so only ") | ||
.append(MaxResponseLogSize).append(" characters are reserved for performance reasons.]") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changing the size measurement from bytes to characters may lead to inaccurate log size calculations when non-ASCII characters are present. Consider retaining byte-based calculation or ensuring that the character-based approach meets the intended requirements. Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||
.append("\r\n"); | ||
} else { | ||
builder.append(line).append("\r\n"); | ||
} | ||
totalLogByteSize += lineByteSize; | ||
if (totalLogByteSize >= MaxResponseLogSize) { | ||
totalLogSize += lineSize; | ||
if (totalLogSize >= MaxResponseLogSize) { | ||
break; | ||
} | ||
} | ||
|
Uh oh!
There was an error while loading. Please reload this page.