Fix the issue of incorrectly calculating the number of dump lines when using PrettyDump in ByteBufUtil (#9304)

Motivation:

Fix the issue of incorrectly calculating the number of dump rows when using prettyHexDumpmethod in ByteBufUtil. The way to find the remainder is either length % 16 or length & 15

Modification:

Fixed the way to calculate the remainder

Result:

Fixed #9301
This commit is contained in:
秦世成 2019-07-01 14:35:18 +08:00 committed by Norman Maurer
parent 262ced7ce4
commit 4596f9e139
1 changed files with 1 additions and 1 deletions

View File

@ -1095,7 +1095,7 @@ public final class ByteBufUtil {
if (length == 0) {
return StringUtil.EMPTY_STRING;
} else {
int rows = length / 16 + (length % 15 == 0? 0 : 1) + 4;
int rows = length / 16 + ((length & 15) == 0? 0 : 1) + 4;
StringBuilder buf = new StringBuilder(rows * 80);
appendPrettyHexDump(buf, buffer, offset, length);
return buf.toString();