GitHub user afine opened a pull request:
https://github.com/apache/zookeeper/pull/280
ZOOKEEPER-2806: Flaky test:
org.apache.zookeeper.server.quorum.FLEBackwardElectionRoundTest.testBackwardElectionRound
Here is an example of a test failure:
https://builds.apache.org/job/ZooKeeper_branch34_jdk8/1016/testReport/org.apache.zookeeper.server.quorum/FLEBackwardElectionRoundTest/testBackwardElectionRound/
This flaky test is caused by the reuse of a `ByteBuffer` object between
`QuorumCnxManager`s.
When sending a `ByteBuffer` we reset its position first:
```
synchronized void send(ByteBuffer b) throws IOException {
byte[] msgBytes = new byte[b.capacity()];
try {
b.position(0);
b.get(msgBytes);
} catch (BufferUnderflowException be) {
LOG.error("BufferUnderflowException ", be);
return;
}
dout.writeInt(b.capacity());
dout.write(b.array());
dout.flush();
}
```
`b.get(msgBytes);` changes the position of the `ByteBuffer`. So we can have
a race here that results in a `BufferUnderflowException` causing a message
never to be sent and this test to fail.
The fix is to create a new `ByteBuffer` for each message we send in the
test.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/afine/zookeeper ZOOKEEPER-2806
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/zookeeper/pull/280.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #280
----
commit 384bf271a79333a7d646a74e1e6c326955d7001c
Author: Abraham Fine <[email protected]>
Date: 2017-06-13T18:46:48Z
ZOOKEEPER-2806: Flaky test:
org.apache.zookeeper.server.quorum.FLEBackwardElectionRoundTest.testBackwardElectionRound
----
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---