Skip to content

Commit

Permalink
Merge pull request alibaba#1822 from RongtongJin/fix_1821
Browse files Browse the repository at this point in the history
[ISSUE alibaba#1821]Fix the issue that MessageClientIDSetter#getIPFromID return wrong pid
  • Loading branch information
duhenglucky authored Mar 5, 2020
2 parents c233f65 + d119204 commit d7102c0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,11 @@ public static byte[] getIPFromID(String msgID) {
return result;
}

public static short getPidFromID(String msgID) {
public static int getPidFromID(String msgID) {
byte[] bytes = UtilAll.string2bytes(msgID);
ByteBuffer wrap = ByteBuffer.wrap(bytes);
wrap.position(bytes.length - 2 - 4 - 4 - 2);
return wrap.getShort();
int value = wrap.getShort(bytes.length - 2 - 4 - 4 - 2);
return value & 0x0000FFFF;
}

public static String createUniqID() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public void testGetPidFromID() {
int pid = UtilAll.getPid();

String uniqID = MessageClientIDSetter.createUniqID();
short pidFromID = MessageClientIDSetter.getPidFromID(uniqID);
int pidFromID = MessageClientIDSetter.getPidFromID(uniqID);

assertThat(pid).isEqualTo(pidFromID);
}
Expand Down

0 comments on commit d7102c0

Please sign in to comment.