szetszwo commented on a change in pull request #243:
URL: https://github.com/apache/incubator-ratis/pull/243#discussion_r514967283
##########
File path:
ratis-test/src/test/java/org/apache/ratis/datastream/TestDataStreamBase.java
##########
@@ -65,8 +84,7 @@ public int write(ByteBuffer src) {
}
final int remaining = src.remaining();
for(; src.remaining() > 0; ) {
- Assert.assertEquals(pos2byte(byteWritten), src.get());
- byteWritten += 1;
+ Assert.assertEquals(pos2byte(byteWritten.getAndIncrement()),
src.get());
Review comment:
Using int may work but it is hard to understand why it works. Since
this is a test, we want to make sure that it won't has bugs. When the test
fails, we don't want to ask questions like "do we need to synchronize
byteWritten?" :)
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]