Copilot commented on code in PR #17140:
URL:
https://github.com/apache/dolphinscheduler/pull/17140#discussion_r2049823076
##########
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/LogUtils.java:
##########
@@ -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 ")
.append(MaxResponseLogSize).append(" bytes, so only ")
.append(MaxResponseLogSize).append(" characters are
reserved for performance reasons.]")
Review Comment:
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.
##########
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/LogUtils.java:
##########
@@ -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 ")
Review Comment:
Change 'is exceed' to 'exceeds' for correct grammar in the log message.
```suggestion
.append(" [this line's size
").append(lineSize).append(" bytes exceeds ")
```
--
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]