提交 d119204f 编写于 作者: R rongtongjin

fix(test):fix the issue that MessageClientIDSetter#getIPFromID return wrong...

fix(test):fix the issue that MessageClientIDSetter#getIPFromID return wrong pid when pid greater than short type max value
上级 997164b1
...@@ -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.
先完成此消息的编辑!
想要评论请 注册