From 2910969cf41fd275c4adb0062f2cd57a52932b05 Mon Sep 17 00:00:00 2001 From: leon chen Date: Fri, 23 Sep 2016 08:36:35 +0800 Subject: [PATCH] fix readInt bug --- .../moilioncircle/redis/replicator/io/RedisInputStream.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/moilioncircle/redis/replicator/io/RedisInputStream.java b/src/main/java/com/moilioncircle/redis/replicator/io/RedisInputStream.java index 6c97abe0..ad3cc7fb 100644 --- a/src/main/java/com/moilioncircle/redis/replicator/io/RedisInputStream.java +++ b/src/main/java/com/moilioncircle/redis/replicator/io/RedisInputStream.java @@ -113,7 +113,8 @@ public int readInt(int length, boolean littleEndian) throws IOException { r = (r << 8) | v; } } - return r; + int c; + return r << (c = (4 - length << 3)) >> c; } public long readUInt(int length) throws IOException { @@ -138,7 +139,8 @@ public int readInt(byte[] bytes, boolean littleEndian) { r = (r << 8) | v; } } - return r; + int c; + return r << (c = (4 - length << 3)) >> c; } public long readLong(int length, boolean littleEndian) throws IOException {