You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@zookeeper.apache.org by 十一飘 <86...@qq.com> on 2020/07/05 08:44:54 UTC
may be a bug
Hi, I may be find a bug in the file org.apache.zookeeper.server.quorum.FastLeaderElection.java when I read the source code of Zookeeper. These codes as follow are copied from the file between 255th and 282th line. ——————————————————————————————————————————————————————————————————————————boolean backCompatibility40 = (capacity == 40);
response.buffer.clear();
// Instantiate Notification and set its attributes
Notification n = new Notification();
int rstate = response.buffer.getInt(); //4
long rleader = response.buffer.getLong(); //8
long rzxid = response.buffer.getLong(); //8
long relectionEpoch = response.buffer.getLong(); //8
long rpeerepoch;
int version = 0x0;
QuorumVerifier rqv = null;
try {
if (!backCompatibility28) {
rpeerepoch = response.buffer.getLong(); //8
if (!backCompatibility40) { // here may be a bug
/*
* Version added in 3.4.6
*/
version = response.buffer.getInt(); //4
} else {
LOG.info("Backward compatibility mode (36 bits), server id: {}", response.sid);
}
} else {
LOG.info("Backward compatibility mode (28 bits), server id: {}", response.sid);
rpeerepoch = ZxidUtils.getEpochFromZxid(rzxid);
} ——————————————————————————————————————————————————————————————————————————————————————————————The variable "backCompatibility40 = (capacity == 40)", but "if (!backCompatibility40) {version = response.buffer.getInt();}" The variable response.buffer has been read 36 bytes before this line "if (!backCompatibility40)". It should be "if (backCompatibility40)", then "version = response.buffer.getInt()". It can be seen the log of "Backward compatibility mode (36 bits)".Thank you for your reply and explain me if I am wrong.