smengcl commented on code in PR #6859:
URL: https://github.com/apache/ozone/pull/6859#discussion_r1676434801
##########
hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/storage/BlockOutputStream.java:
##########
@@ -320,46 +330,58 @@ public void write(byte[] b, int off, int len) throws
IOException {
if (len == 0) {
return;
}
-
- while (len > 0) {
- allocateNewBufferIfNeeded();
- final int writeLen = Math.min(currentBufferRemaining, len);
- currentBuffer.put(b, off, writeLen);
- currentBufferRemaining -= writeLen;
- writeChunkIfNeeded();
- off += writeLen;
- len -= writeLen;
- updateWrittenDataLength(writeLen);
- doFlushOrWatchIfNeeded();
+ synchronized (this) {
+ while (len > 0) {
+ allocateNewBufferIfNeeded();
+ final int writeLen = Math.min(currentBufferRemaining, len);
+ currentBuffer.put(b, off, writeLen);
+ currentBufferRemaining -= writeLen;
+ updateWrittenDataLength(writeLen);
+ writeChunkIfNeeded();
+ off += writeLen;
+ len -= writeLen;
+ doFlushOrWatchIfNeeded();
+ }
}
}
- public void updateWrittenDataLength(int writeLen) {
+ public synchronized void updateWrittenDataLength(int writeLen) {
Review Comment:
1. This can be `protected`
2. Looks like all 3 callers of this method are already calling this in
`synchronized` block. But I guess it doesn't hurt.
```suggestion
protected synchronized void updateWrittenDataLength(int writeLen) {
```
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]