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 dfa69f0980
commit 1454c3a777

View File

@ -1095,7 +1095,7 @@ public final class ByteBufUtil {
if (length == 0) { if (length == 0) {
return StringUtil.EMPTY_STRING; return StringUtil.EMPTY_STRING;
} else { } 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); StringBuilder buf = new StringBuilder(rows * 80);
appendPrettyHexDump(buf, buffer, offset, length); appendPrettyHexDump(buf, buffer, offset, length);
return buf.toString(); return buf.toString();