sadanand48 commented on code in PR #7285:
URL: https://github.com/apache/ozone/pull/7285#discussion_r1792516525


##########
hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/client/rpc/OzoneRpcClientTests.java:
##########
@@ -3140,6 +3149,34 @@ void testMultipartUploadOverride(ReplicationConfig 
replication)
     doMultipartUpload(bucket, keyName, (byte)97, replication);
 
   }
+
+  @Test
+  public void testClientLeakDetector() throws Exception {
+    HddsUtils.setIgnoreReportingLeak(true);
+    OzoneClient client = OzoneClientFactory.getRpcClient(cluster.getConf());
+    String volumeName = UUID.randomUUID().toString();
+    String bucketName = UUID.randomUUID().toString();
+    String keyName = UUID.randomUUID().toString();
+    GenericTestUtils.LogCapturer ozoneClientFactoryLogCapturer =
+        GenericTestUtils.LogCapturer.captureLogs(
+            OzoneClientFactory.getLogger());
+
+    client.getObjectStore().createVolume(volumeName);
+    OzoneVolume volume = client.getObjectStore().getVolume(volumeName);
+    volume.createBucket(bucketName);
+    OzoneBucket bucket = volume.getBucket(bucketName);
+    byte[] data = new byte[10];
+    Arrays.fill(data, (byte) 1);
+    try (OzoneOutputStream out = bucket.createKey(keyName, 10,
+        ReplicationConfig.fromTypeAndFactor(RATIS, ONE), new HashMap<>())) {
+      out.write(data);
+    }
+    client = null;
+    System.gc();
+    GenericTestUtils.waitFor(() -> ozoneClientFactoryLogCapturer.getOutput()
+        .contains("is not closed correctly"), 100, 2000);
+    HddsUtils.setIgnoreReportingLeak(false);

Review Comment:
   This won't work as the root logger still appends to the console. 
ozoneClientFactoryLogCapturer.clearOutput() only clears the string writer which 
is a new instance of Appender. I will need to set specific log4j properties for 
this test file or somehow programatically remove the console appender from root 
logger. Will check if this is possible



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