taklwu commented on code in PR #11245:
URL: https://github.com/apache/ozone/pull/11245#discussion_r4020836646


##########
hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/io/OzoneCryptoInputStream.java:
##########
@@ -73,8 +79,18 @@ public int getBufferSize() {
     return bufferSize;
   }
 
+  /**
+   * {@link CryptoInputStream} does not synchronize its own methods, so every 
method moving the cursor of
+   * this stream is serialized here on the monitor of this stream. Otherwise a 
read or a seek could land in
+   * the middle of a positioned read and see (or undo) the cursor move that 
read does.
+   * This covers both the sequential-read API ({@link #read(byte[], int, 
int)}, {@link #read(ByteBuffer)},
+   * {@link #seek(long)}, {@link #getPos()}) and all positioned-read overloads
+   * ({@link #read(long, ByteBuffer)}, {@link #readFully(long, ByteBuffer)},
+   * {@link #read(long, byte[], int, int)}, {@link #readFully(long, byte[], 
int, int)},
+   * {@link #readFully(long, byte[])}).
+   */
   @Override
-  public int read(byte[] b, int off, int len) throws IOException {
+  public synchronized int read(byte[] b, int off, int len) throws IOException {

Review Comment:
   HDDS-16400



##########
hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/OzoneFSInputStream.java:
##########
@@ -211,4 +222,19 @@ public void readFully(long position, ByteBuffer buf) 
throws IOException {
       }
     }
   }
+
+  @Override
+  public int read(long position, byte[] buffer, int offset, int length) throws 
IOException {
+    return read(position, ByteBuffer.wrap(buffer, offset, length));
+  }
+
+  @Override
+  public void readFully(long position, byte[] buffer, int offset, int length) 
throws IOException {
+    readFully(position, ByteBuffer.wrap(buffer, offset, length));
+  }
+
+  @Override
+  public void readFully(long position, byte[] buffer) throws IOException {
+    readFully(position, buffer, 0, buffer.length);
+  }

Review Comment:
   fixed



-- 
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]

Reply via email to