未验证 提交 d7102c06 编写于 作者: H Heng Du 提交者: GitHub

Merge pull request #1822 from RongtongJin/fix_1821

[ISSUE #1821]Fix the issue that MessageClientIDSetter#getIPFromID return wrong pid
...@@ -104,11 +104,11 @@ public class MessageClientIDSetter { ...@@ -104,11 +104,11 @@ public class MessageClientIDSetter {
return result; return result;
} }
public static short getPidFromID(String msgID) { public static int getPidFromID(String msgID) {
byte[] bytes = UtilAll.string2bytes(msgID); byte[] bytes = UtilAll.string2bytes(msgID);
ByteBuffer wrap = ByteBuffer.wrap(bytes); ByteBuffer wrap = ByteBuffer.wrap(bytes);
wrap.position(bytes.length - 2 - 4 - 4 - 2); int value = wrap.getShort(bytes.length - 2 - 4 - 4 - 2);
return wrap.getShort(); return value & 0x0000FFFF;
} }
public static String createUniqID() { public static String createUniqID() {
......
...@@ -40,7 +40,7 @@ public class MessageClientIDSetterTest { ...@@ -40,7 +40,7 @@ public class MessageClientIDSetterTest {
int pid = UtilAll.getPid(); int pid = UtilAll.getPid();
String uniqID = MessageClientIDSetter.createUniqID(); String uniqID = MessageClientIDSetter.createUniqID();
short pidFromID = MessageClientIDSetter.getPidFromID(uniqID); int pidFromID = MessageClientIDSetter.getPidFromID(uniqID);
assertThat(pid).isEqualTo(pidFromID); assertThat(pid).isEqualTo(pidFromID);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册