duongkame commented on code in PR #6859:
URL: https://github.com/apache/ozone/pull/6859#discussion_r1676588626


##########
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:
   Agree. I added synchronized because findbugs made me do that.



-- 
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: issues-unsubscr...@ozone.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@ozone.apache.org
For additional commands, e-mail: issues-h...@ozone.apache.org

Reply via email to