This is an automated email from the ASF dual-hosted git repository.

weichiu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ozone.git


The following commit(s) were added to refs/heads/master by this push:
     new 0a377c685a HDDS-7838. gRPC channel created block input/output stream 
not shutdown properly (#4215)
0a377c685a is described below

commit 0a377c685ad8ee6ebb35ef40d5ad1f709fb590e1
Author: Doroszlai, Attila <[email protected]>
AuthorDate: Fri Feb 3 20:27:32 2023 +0100

    HDDS-7838. gRPC channel created block input/output stream not shutdown 
properly (#4215)
---
 .../hadoop/hdds/scm/storage/BlockInputStream.java  |  14 +-
 .../hadoop/hdds/scm/storage/BlockOutputStream.java |  20 +--
 .../hadoop/hdds/scm/storage/ChunkInputStream.java  |   9 +-
 .../hdds/scm/storage/ECBlockOutputStream.java      |   6 -
 .../hdds/scm/storage/DummyChunkInputStream.java    |   2 +-
 .../hdds/scm/storage/TestBlockInputStream.java     |   2 +-
 .../hadoop/ozone/client/io/KeyOutputStream.java    |   2 +-
 .../client/rpc/TestOzoneRpcClientAbstract.java     | 171 ++++++++++-----------
 8 files changed, 111 insertions(+), 115 deletions(-)

diff --git 
a/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/storage/BlockInputStream.java
 
b/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/storage/BlockInputStream.java
index e89c7f9ee8..a0d848e251 100644
--- 
a/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/storage/BlockInputStream.java
+++ 
b/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/storage/BlockInputStream.java
@@ -320,7 +320,7 @@ public class BlockInputStream extends 
BlockExtendedInputStream {
           if (isConnectivityIssue(ex)) {
             handleReadError(ex);
           } else {
-            current.releaseClient();
+            current.releaseClient(false);
           }
           continue;
         } else {
@@ -435,7 +435,7 @@ public class BlockInputStream extends 
BlockExtendedInputStream {
 
   @Override
   public synchronized void close() {
-    releaseClient();
+    releaseClient(true);
     xceiverClientFactory = null;
 
     final List<ChunkInputStream> inputStreams = this.chunkStreams;
@@ -446,9 +446,9 @@ public class BlockInputStream extends 
BlockExtendedInputStream {
     }
   }
 
-  private void releaseClient() {
+  private void releaseClient(boolean invalidateClient) {
     if (xceiverClientFactory != null && xceiverClient != null) {
-      xceiverClientFactory.releaseClient(xceiverClient, false);
+      xceiverClientFactory.releaseClient(xceiverClient, invalidateClient);
       xceiverClient = null;
     }
   }
@@ -487,7 +487,7 @@ public class BlockInputStream extends 
BlockExtendedInputStream {
   @Override
   public synchronized void unbuffer() {
     storePosition();
-    releaseClient();
+    releaseClient(true);
 
     final List<ChunkInputStream> inputStreams = this.chunkStreams;
     if (inputStreams != null) {
@@ -514,11 +514,11 @@ public class BlockInputStream extends 
BlockExtendedInputStream {
   }
 
   private void handleReadError(IOException cause) throws IOException {
-    releaseClient();
+    releaseClient(false);
     final List<ChunkInputStream> inputStreams = this.chunkStreams;
     if (inputStreams != null) {
       for (ChunkInputStream is : inputStreams) {
-        is.releaseClient();
+        is.releaseClient(false);
       }
     }
 
diff --git 
a/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/storage/BlockOutputStream.java
 
b/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/storage/BlockOutputStream.java
index 679f8a5d52..f72d537ba9 100644
--- 
a/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/storage/BlockOutputStream.java
+++ 
b/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/storage/BlockOutputStream.java
@@ -554,7 +554,7 @@ public class BlockOutputStream extends OutputStream {
       throw e;
     } finally {
       if (close) {
-        cleanup(false);
+        cleanup(true);
       }
     }
   }
@@ -591,14 +591,16 @@ public class BlockOutputStream extends OutputStream {
 
   @Override
   public void close() throws IOException {
-    if (xceiverClientFactory != null && xceiverClient != null
-        && bufferPool != null && bufferPool.getSize() > 0) {
-      handleFlush(true);
-      // TODO: Turn the below buffer empty check on when Standalone pipeline
-      // is removed in the write path in tests
-      // Preconditions.checkArgument(buffer.position() == 0);
-      // bufferPool.checkBufferPoolEmpty();
-
+    if (xceiverClientFactory != null && xceiverClient != null) {
+      if (bufferPool != null && bufferPool.getSize() > 0) {
+        handleFlush(true);
+        // TODO: Turn the below buffer empty check on when Standalone pipeline
+        // is removed in the write path in tests
+        // Preconditions.checkArgument(buffer.position() == 0);
+        // bufferPool.checkBufferPoolEmpty();
+      } else {
+        cleanup(true);
+      }
     }
   }
 
diff --git 
a/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/storage/ChunkInputStream.java
 
b/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/storage/ChunkInputStream.java
index e30df34b85..554d605b3f 100644
--- 
a/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/storage/ChunkInputStream.java
+++ 
b/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/storage/ChunkInputStream.java
@@ -282,12 +282,13 @@ public class ChunkInputStream extends InputStream
   @Override
   public synchronized void close() {
     releaseBuffers();
-    releaseClient();
+    releaseClient(true);
   }
 
-  protected synchronized void releaseClient() {
+  protected synchronized void releaseClient(boolean invalidateClient) {
     if (xceiverClientFactory != null && xceiverClient != null) {
-      xceiverClientFactory.releaseClientForReadData(xceiverClient, false);
+      xceiverClientFactory.releaseClientForReadData(
+          xceiverClient, invalidateClient);
       xceiverClient = null;
     }
   }
@@ -738,7 +739,7 @@ public class ChunkInputStream extends InputStream
   public synchronized void unbuffer() {
     storePosition();
     releaseBuffers();
-    releaseClient();
+    releaseClient(true);
   }
 
   @VisibleForTesting
diff --git 
a/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/storage/ECBlockOutputStream.java
 
b/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/storage/ECBlockOutputStream.java
index cc97ae8f16..c8ea45b194 100644
--- 
a/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/storage/ECBlockOutputStream.java
+++ 
b/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/storage/ECBlockOutputStream.java
@@ -257,12 +257,6 @@ public class ECBlockOutputStream extends BlockOutputStream 
{
     return flushFuture;
   }
 
-  @Override
-  public void close() throws IOException {
-    super.close();
-    cleanup(false);
-  }
-
   /**
    * @return The current chunk writer response future.
    */
diff --git 
a/hadoop-hdds/client/src/test/java/org/apache/hadoop/hdds/scm/storage/DummyChunkInputStream.java
 
b/hadoop-hdds/client/src/test/java/org/apache/hadoop/hdds/scm/storage/DummyChunkInputStream.java
index 78d0c05bfe..cfbba0df24 100644
--- 
a/hadoop-hdds/client/src/test/java/org/apache/hadoop/hdds/scm/storage/DummyChunkInputStream.java
+++ 
b/hadoop-hdds/client/src/test/java/org/apache/hadoop/hdds/scm/storage/DummyChunkInputStream.java
@@ -82,7 +82,7 @@ public class DummyChunkInputStream extends ChunkInputStream {
   }
 
   @Override
-  protected void releaseClient() {
+  protected void releaseClient(boolean invalidateClient) {
     // no-op
   }
 
diff --git 
a/hadoop-hdds/client/src/test/java/org/apache/hadoop/hdds/scm/storage/TestBlockInputStream.java
 
b/hadoop-hdds/client/src/test/java/org/apache/hadoop/hdds/scm/storage/TestBlockInputStream.java
index 0bba24d819..ef270731d5 100644
--- 
a/hadoop-hdds/client/src/test/java/org/apache/hadoop/hdds/scm/storage/TestBlockInputStream.java
+++ 
b/hadoop-hdds/client/src/test/java/org/apache/hadoop/hdds/scm/storage/TestBlockInputStream.java
@@ -423,7 +423,7 @@ public class TestBlockInputStream {
       Assert.assertEquals(len, bytesRead);
       verify(refreshPipeline).apply(blockID);
       verify(clientFactory).acquireClientForReadData(pipeline);
-      verify(clientFactory).releaseClient(client, false);
+      verify(clientFactory).releaseClient(client, true);
     } finally {
       subject.close();
     }
diff --git 
a/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/io/KeyOutputStream.java
 
b/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/io/KeyOutputStream.java
index 00970788ea..0a64b9392d 100644
--- 
a/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/io/KeyOutputStream.java
+++ 
b/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/io/KeyOutputStream.java
@@ -335,7 +335,7 @@ public class KeyOutputStream extends OutputStream 
implements Syncable {
       excludeList.addPipeline(pipelineId);
     }
     // just clean up the current stream.
-    streamEntry.cleanup(retryFailure);
+    streamEntry.cleanup(!retryFailure);
 
     // discard all subsequent blocks the containers and pipelines which
     // are in the exclude list so that, the very next retry should never
diff --git 
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/client/rpc/TestOzoneRpcClientAbstract.java
 
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/client/rpc/TestOzoneRpcClientAbstract.java
index 029768bfda..e9f3a9130f 100644
--- 
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/client/rpc/TestOzoneRpcClientAbstract.java
+++ 
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/client/rpc/TestOzoneRpcClientAbstract.java
@@ -892,10 +892,11 @@ public abstract class TestOzoneRpcClientAbstract {
       out.close();
       OzoneKey key = bucket.getKey(keyName);
       Assert.assertEquals(keyName, key.getName());
-      OzoneInputStream is = bucket.readKey(keyName);
-      byte[] fileContent = new byte[value.getBytes(UTF_8).length];
-      is.read(fileContent);
-      Assert.assertEquals(value, new String(fileContent, UTF_8));
+      try (OzoneInputStream is = bucket.readKey(keyName)) {
+        byte[] fileContent = new byte[value.getBytes(UTF_8).length];
+        is.read(fileContent);
+        Assert.assertEquals(value, new String(fileContent, UTF_8));
+      }
     } else {
       Assertions.assertThrows(IllegalArgumentException.class,
               () -> bucket.createKey(keyName, "dummy".getBytes(UTF_8).length,
@@ -925,15 +926,16 @@ public abstract class TestOzoneRpcClientAbstract {
       out.close();
       OzoneKey key = bucket.getKey(keyName);
       Assert.assertEquals(keyName, key.getName());
-      OzoneInputStream is = bucket.readKey(keyName);
-      byte[] fileContent = new byte[value.getBytes(UTF_8).length];
-      is.read(fileContent);
-      verifyReplication(volumeName, bucketName, keyName,
-          RatisReplicationConfig.getInstance(
-              HddsProtos.ReplicationFactor.ONE));
-      Assert.assertEquals(value, new String(fileContent, UTF_8));
-      Assert.assertFalse(key.getCreationTime().isBefore(testStartTime));
-      Assert.assertFalse(key.getModificationTime().isBefore(testStartTime));
+      try (OzoneInputStream is = bucket.readKey(keyName)) {
+        byte[] fileContent = new byte[value.getBytes(UTF_8).length];
+        is.read(fileContent);
+        verifyReplication(volumeName, bucketName, keyName,
+            RatisReplicationConfig.getInstance(
+                HddsProtos.ReplicationFactor.ONE));
+        Assert.assertEquals(value, new String(fileContent, UTF_8));
+        Assert.assertFalse(key.getCreationTime().isBefore(testStartTime));
+        Assert.assertFalse(key.getModificationTime().isBefore(testStartTime));
+      }
     }
   }
 
@@ -1484,16 +1486,16 @@ public abstract class TestOzoneRpcClientAbstract {
       out.close();
       OzoneKey key = bucket.getKey(keyName);
       Assert.assertEquals(keyName, key.getName());
-      OzoneInputStream is = bucket.readKey(keyName);
-      byte[] fileContent = new byte[value.getBytes(UTF_8).length];
-      is.read(fileContent);
-      is.close();
-      verifyReplication(volumeName, bucketName, keyName,
-          RatisReplicationConfig.getInstance(
-              HddsProtos.ReplicationFactor.ONE));
-      Assert.assertEquals(value, new String(fileContent, UTF_8));
-      Assert.assertFalse(key.getCreationTime().isBefore(testStartTime));
-      Assert.assertFalse(key.getModificationTime().isBefore(testStartTime));
+      try (OzoneInputStream is = bucket.readKey(keyName)) {
+        byte[] fileContent = new byte[value.getBytes(UTF_8).length];
+        is.read(fileContent);
+        verifyReplication(volumeName, bucketName, keyName,
+            RatisReplicationConfig.getInstance(
+                HddsProtos.ReplicationFactor.ONE));
+        Assert.assertEquals(value, new String(fileContent, UTF_8));
+        Assert.assertFalse(key.getCreationTime().isBefore(testStartTime));
+        Assert.assertFalse(key.getModificationTime().isBefore(testStartTime));
+      }
     }
   }
 
@@ -1519,16 +1521,16 @@ public abstract class TestOzoneRpcClientAbstract {
       out.close();
       OzoneKey key = bucket.getKey(keyName);
       Assert.assertEquals(keyName, key.getName());
-      OzoneInputStream is = bucket.readKey(keyName);
-      byte[] fileContent = new byte[value.getBytes(UTF_8).length];
-      is.read(fileContent);
-      is.close();
-      verifyReplication(volumeName, bucketName, keyName,
-          RatisReplicationConfig.getInstance(
-              HddsProtos.ReplicationFactor.THREE));
-      Assert.assertEquals(value, new String(fileContent, UTF_8));
-      Assert.assertFalse(key.getCreationTime().isBefore(testStartTime));
-      Assert.assertFalse(key.getModificationTime().isBefore(testStartTime));
+      try (OzoneInputStream is = bucket.readKey(keyName)) {
+        byte[] fileContent = new byte[value.getBytes(UTF_8).length];
+        is.read(fileContent);
+        verifyReplication(volumeName, bucketName, keyName,
+            RatisReplicationConfig.getInstance(
+                HddsProtos.ReplicationFactor.THREE));
+        Assert.assertEquals(value, new String(fileContent, UTF_8));
+        Assert.assertFalse(key.getCreationTime().isBefore(testStartTime));
+        Assert.assertFalse(key.getModificationTime().isBefore(testStartTime));
+      }
     }
   }
 
@@ -1560,14 +1562,14 @@ public abstract class TestOzoneRpcClientAbstract {
           out.close();
           OzoneKey key = bucket.getKey(keyName);
           Assert.assertEquals(keyName, key.getName());
-          OzoneInputStream is = bucket.readKey(keyName);
-          byte[] fileContent = new byte[data.getBytes(UTF_8).length];
-          is.read(fileContent);
-          is.close();
-          verifyReplication(volumeName, bucketName, keyName,
-              RatisReplicationConfig.getInstance(
-                  HddsProtos.ReplicationFactor.THREE));
-          Assert.assertEquals(data, new String(fileContent, UTF_8));
+          try (OzoneInputStream is = bucket.readKey(keyName)) {
+            byte[] fileContent = new byte[data.getBytes(UTF_8).length];
+            is.read(fileContent);
+            verifyReplication(volumeName, bucketName, keyName,
+                RatisReplicationConfig.getInstance(
+                    HddsProtos.ReplicationFactor.THREE));
+            Assert.assertEquals(data, new String(fileContent, UTF_8));
+          }
           Assert.assertFalse(key.getCreationTime().isBefore(testStartTime));
           
Assert.assertFalse(key.getModificationTime().isBefore(testStartTime));
         }
@@ -1670,9 +1672,9 @@ public abstract class TestOzoneRpcClientAbstract {
       configuration.setFromObject(clientConfig);
 
       RpcClient client = new RpcClient(configuration, null);
-      OzoneInputStream is = client.getKey(volumeName, bucketName, keyName);
-      is.read(new byte[100]);
-      is.close();
+      try (InputStream is = client.getKey(volumeName, bucketName, keyName)) {
+        is.read(new byte[100]);
+      }
       if (verifyChecksum) {
         fail("Reading corrupted data should fail, as verify checksum is " +
             "enabled");
@@ -1685,17 +1687,6 @@ public abstract class TestOzoneRpcClientAbstract {
     }
   }
 
-
-  private void readKey(OzoneBucket bucket, String keyName, String data)
-      throws IOException {
-    OzoneKey key = bucket.getKey(keyName);
-    Assert.assertEquals(keyName, key.getName());
-    OzoneInputStream is = bucket.readKey(keyName);
-    byte[] fileContent = new byte[data.getBytes(UTF_8).length];
-    is.read(fileContent);
-    is.close();
-  }
-
   @Test
   public void testGetKeyDetails() throws IOException {
     String volumeName = UUID.randomUUID().toString();
@@ -1774,7 +1765,12 @@ public abstract class TestOzoneRpcClientAbstract {
       }
     }
 
-    assertInputStreamContent(keyValue, keyDetails.getContent());
+    OzoneInputStream inputStream = keyDetails.getContent();
+    try {
+      assertInputStreamContent(keyValue, inputStream);
+    } finally {
+      inputStream.close();
+    }
   }
 
   private void assertInputStreamContent(String expected, InputStream is)
@@ -1829,8 +1825,9 @@ public abstract class TestOzoneRpcClientAbstract {
     // Try reading the key. Since the chunk file is corrupted, it should
     // throw a checksum mismatch exception.
     try {
-      OzoneInputStream is = bucket.readKey(keyName);
-      is.read(new byte[100]);
+      try (OzoneInputStream is = bucket.readKey(keyName)) {
+        is.read(new byte[100]);
+      }
       fail("Reading corrupted data should fail.");
     } catch (IOException e) {
       GenericTestUtils.assertExceptionContains("Checksum mismatch", e);
@@ -1925,11 +1922,12 @@ public abstract class TestOzoneRpcClientAbstract {
     // Try reading keyName2
     try {
       GenericTestUtils.setLogLevel(XceiverClientGrpc.getLogger(), DEBUG);
-      OzoneInputStream is = bucket.readKey(keyName2);
-      byte[] content = new byte[100];
-      is.read(content);
-      String retValue = new String(content, UTF_8);
-      Assert.assertTrue(value.equals(retValue.trim()));
+      try (OzoneInputStream is = bucket.readKey(keyName2)) {
+        byte[] content = new byte[100];
+        is.read(content);
+        String retValue = new String(content, UTF_8);
+        Assert.assertTrue(value.equals(retValue.trim()));
+      }
     } catch (IOException e) {
       fail("Reading unhealthy replica should succeed.");
     }
@@ -1985,8 +1983,7 @@ public abstract class TestOzoneRpcClientAbstract {
     corruptData(containerList.get(0), key);
     // Try reading the key. Read will fail on the first node and will 
eventually
     // failover to next replica
-    try {
-      OzoneInputStream is = bucket.readKey(keyName);
+    try (OzoneInputStream is = bucket.readKey(keyName)) {
       byte[] b = new byte[data.length];
       is.read(b);
       Assert.assertTrue(Arrays.equals(b, data));
@@ -1996,8 +1993,7 @@ public abstract class TestOzoneRpcClientAbstract {
     corruptData(containerList.get(1), key);
     // Try reading the key. Read will fail on the first node and will 
eventually
     // failover to next replica
-    try {
-      OzoneInputStream is = bucket.readKey(keyName);
+    try (OzoneInputStream is = bucket.readKey(keyName)) {
       byte[] b = new byte[data.length];
       is.read(b);
       Assert.assertTrue(Arrays.equals(b, data));
@@ -2006,8 +2002,7 @@ public abstract class TestOzoneRpcClientAbstract {
     }
     corruptData(containerList.get(2), key);
     // Try reading the key. Read will fail here as all the replica are corrupt
-    try {
-      OzoneInputStream is = bucket.readKey(keyName);
+    try (OzoneInputStream is = bucket.readKey(keyName)) {
       byte[] b = new byte[data.length];
       is.read(b);
       fail("Reading corrupted data should fail.");
@@ -2808,8 +2803,7 @@ public abstract class TestOzoneRpcClientAbstract {
     completeMultipartUpload(bucket2, keyName2, uploadId, partsMap);
 
     // User without permission cannot read multi-uploaded object
-    try {
-      OzoneInputStream inputStream = bucket2.readKey(keyName);
+    try (OzoneInputStream ignored = bucket2.readKey(keyName)) {
       fail("User without permission should fail");
     } catch (Exception e) {
       assertTrue(e instanceof OMException);
@@ -3043,8 +3037,9 @@ public abstract class TestOzoneRpcClientAbstract {
     Assert.assertNotNull(omMultipartCommitUploadPartInfo);
 
     byte[] fileContent = new byte[data.length];
-    OzoneInputStream inputStream = bucket.readKey(keyName);
-    inputStream.read(fileContent);
+    try (OzoneInputStream inputStream = bucket.readKey(keyName)) {
+      inputStream.read(fileContent);
+    }
     StringBuilder sb = new StringBuilder(data.length);
 
     // Combine all parts data, and check is it matching with get key data.
@@ -3668,8 +3663,9 @@ public abstract class TestOzoneRpcClientAbstract {
     //Now Read the key which has been completed multipart upload.
     byte[] fileContent = new byte[data.length + data.length + part3.getBytes(
         UTF_8).length];
-    OzoneInputStream inputStream = bucket.readKey(keyName);
-    inputStream.read(fileContent);
+    try (OzoneInputStream inputStream = bucket.readKey(keyName)) {
+      inputStream.read(fileContent);
+    }
 
     verifyReplication(bucket.getVolumeName(), bucket.getName(), keyName,
         replication);
@@ -3821,10 +3817,11 @@ public abstract class TestOzoneRpcClientAbstract {
         key.getMetadata().get(OzoneConsts.GDPR_ALGORITHM));
     Assert.assertNotNull(key.getMetadata().get(OzoneConsts.GDPR_SECRET));
 
-    OzoneInputStream is = bucket.readKey(keyName);
-    assertInputStreamContent(text, is);
-    verifyReplication(volumeName, bucketName, keyName,
-        RatisReplicationConfig.getInstance(HddsProtos.ReplicationFactor.ONE));
+    try (OzoneInputStream is = bucket.readKey(keyName)) {
+      assertInputStreamContent(text, is);
+      verifyReplication(volumeName, bucketName, keyName,
+          
RatisReplicationConfig.getInstance(HddsProtos.ReplicationFactor.ONE));
+    }
 
     //Step 4
     OMMetadataManager omMetadataManager = ozoneManager.getMetadataManager();
@@ -3841,13 +3838,14 @@ public abstract class TestOzoneRpcClientAbstract {
     key = bucket.getKey(keyName);
     Assert.assertEquals(keyName, key.getName());
     Assert.assertNull(key.getMetadata().get(OzoneConsts.GDPR_FLAG));
-    is = bucket.readKey(keyName);
-    byte[] fileContent = new byte[text.getBytes(UTF_8).length];
-    is.read(fileContent);
 
-    //Step 6
-    Assert.assertNotEquals(text, new String(fileContent, UTF_8));
+    try (OzoneInputStream is = bucket.readKey(keyName)) {
+      byte[] fileContent = new byte[text.getBytes(UTF_8).length];
+      is.read(fileContent);
 
+      //Step 6
+      Assert.assertNotEquals(text, new String(fileContent, UTF_8));
+    }
   }
 
   /**
@@ -3898,8 +3896,9 @@ public abstract class TestOzoneRpcClientAbstract {
         key.getMetadata().get(OzoneConsts.GDPR_ALGORITHM));
     Assert.assertTrue(key.getMetadata().get(OzoneConsts.GDPR_SECRET) != null);
 
-    OzoneInputStream is = bucket.readKey(keyName);
-    assertInputStreamContent(text, is);
+    try (OzoneInputStream is = bucket.readKey(keyName)) {
+      assertInputStreamContent(text, is);
+    }
     verifyReplication(volumeName, bucketName, keyName,
         RatisReplicationConfig.getInstance(HddsProtos.ReplicationFactor.ONE));
 


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to