mirror of
https://github.com/tiennm99/zfoo.git
synced 2026-10-15 00:18:04 +00:00
fix[protocol]: 修复long第5位写入多一位的问题
This commit is contained in:
1 parent
aae5582f9f
commit
dbdcd944d4
1 file changed
+14
-12
@@ -203,16 +203,9 @@ public abstract class ByteBufUtils {
|
|||||||
bytes[index++] = (byte) (mask >>> 7 | 0x80);
|
bytes[index++] = (byte) (mask >>> 7 | 0x80);
|
||||||
bytes[index++] = (byte) (mask >>> 14 | 0x80);
|
bytes[index++] = (byte) (mask >>> 14 | 0x80);
|
||||||
bytes[index++] = (byte) (mask >>> 21 | 0x80);
|
bytes[index++] = (byte) (mask >>> 21 | 0x80);
|
||||||
bytes[index++] = (byte) (mask >>> 28 | 0x80);
|
|
||||||
|
|
||||||
|
int a = (int) (mask >>> 28);
|
||||||
int a = (int) (mask >>> 35);
|
int b = (int) (mask >>> 35);
|
||||||
if (a == 0) {
|
|
||||||
byteBuf.writeBytes(bytes, 0, index);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
int b = (int) (mask >>> 42);
|
|
||||||
if (b == 0) {
|
if (b == 0) {
|
||||||
bytes[index++] = (byte) a;
|
bytes[index++] = (byte) a;
|
||||||
byteBuf.writeBytes(bytes, 0, index);
|
byteBuf.writeBytes(bytes, 0, index);
|
||||||
@@ -220,7 +213,7 @@ public abstract class ByteBufUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bytes[index++] = (byte) (a | 0x80);
|
bytes[index++] = (byte) (a | 0x80);
|
||||||
a = (int) (mask >>> 49);
|
a = (int) (mask >>> 42);
|
||||||
if (a == 0) {
|
if (a == 0) {
|
||||||
bytes[index++] = (byte) b;
|
bytes[index++] = (byte) b;
|
||||||
byteBuf.writeBytes(bytes, 0, index);
|
byteBuf.writeBytes(bytes, 0, index);
|
||||||
@@ -228,7 +221,7 @@ public abstract class ByteBufUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bytes[index++] = (byte) (b | 0x80);
|
bytes[index++] = (byte) (b | 0x80);
|
||||||
b = (int) (mask >>> 56);
|
b = (int) (mask >>> 49);
|
||||||
if (b == 0) {
|
if (b == 0) {
|
||||||
bytes[index++] = (byte) a;
|
bytes[index++] = (byte) a;
|
||||||
byteBuf.writeBytes(bytes, 0, index);
|
byteBuf.writeBytes(bytes, 0, index);
|
||||||
@@ -236,10 +229,19 @@ public abstract class ByteBufUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bytes[index++] = (byte) (a | 0x80);
|
bytes[index++] = (byte) (a | 0x80);
|
||||||
bytes[index++] = (byte) b;
|
a = (int) (mask >>> 56);
|
||||||
|
if (a == 0) {
|
||||||
|
bytes[index++] = (byte) b;
|
||||||
|
byteBuf.writeBytes(bytes, 0, index);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
bytes[index++] = (byte) (b | 0x80);
|
||||||
|
bytes[index++] = (byte) a;
|
||||||
byteBuf.writeBytes(bytes, 0, index);
|
byteBuf.writeBytes(bytes, 0, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static long readLong(ByteBuf byteBuf) {
|
public static long readLong(ByteBuf byteBuf) {
|
||||||
int readIndex = byteBuf.readerIndex();
|
int readIndex = byteBuf.readerIndex();
|
||||||
long b = byteBuf.getByte(readIndex++);
|
long b = byteBuf.getByte(readIndex++);
|
||||||
|
|||||||
Reference in new issue
Block a user