xushiyan commented on code in PR #7251:
URL: https://github.com/apache/hudi/pull/7251#discussion_r1027284997


##########
hudi-client/hudi-spark-client/src/test/java/org/apache/hudi/table/action/clean/TestCleanerInsertAndCleanByCommits.java:
##########
@@ -127,23 +126,21 @@ private void testInsertAndCleanByCommits(
         
.withConsistencyGuardConfig(ConsistencyGuardConfig.newBuilder().withConsistencyCheckEnabled(true).build())
         
.withLockConfig(HoodieLockConfig.newBuilder().withLockProvider(InProcessLockProvider.class).build())
         .build();
-    final SparkRDDWriteClient client = getHoodieWriteClient(cfg);
-
-    final HoodieTestDataGenerator dataGen = new 
HoodieTestDataGenerator(System.nanoTime());
-    final Function2<List<HoodieRecord>, String, Integer> 
recordInsertGenWrappedFunction = isPreppedAPI
-        ? wrapRecordsGenFunctionForPreppedCalls(basePath(), hadoopConf(), 
context(), cfg, dataGen::generateInserts)
-        : dataGen::generateInserts;
-    final Function2<List<HoodieRecord>, String, Integer> 
recordUpsertGenWrappedFunction = isPreppedAPI
-        ? wrapRecordsGenFunctionForPreppedCalls(basePath(), hadoopConf(), 
context(), cfg, dataGen::generateUniqueUpdates)
-        : dataGen::generateUniqueUpdates;
-
-    HoodieTableMetaClient metaClient = 
getHoodieMetaClient(HoodieTableType.COPY_ON_WRITE);
-    insertFirstBigBatchForClientCleanerTest(context(), metaClient, client, 
recordInsertGenWrappedFunction, insertFn);
-
-    // Keep doing some writes and clean inline. Make sure we have expected 
number of files remaining.
-    for (int i = 0; i < 8; i++) {
-      String newCommitTime = makeNewCommitTime();
-      try {
+    try (final SparkRDDWriteClient client = getHoodieWriteClient(cfg)) {
+      final HoodieTestDataGenerator dataGen = new 
HoodieTestDataGenerator(System.nanoTime());
+      final Function2<List<HoodieRecord>, String, Integer> 
recordInsertGenWrappedFunction = isPreppedAPI
+          ? wrapRecordsGenFunctionForPreppedCalls(basePath(), hadoopConf(), 
context(), cfg, dataGen::generateInserts)
+          : dataGen::generateInserts;
+      final Function2<List<HoodieRecord>, String, Integer> 
recordUpsertGenWrappedFunction = isPreppedAPI
+          ? wrapRecordsGenFunctionForPreppedCalls(basePath(), hadoopConf(), 
context(), cfg, dataGen::generateUniqueUpdates)
+          : dataGen::generateUniqueUpdates;
+
+      HoodieTableMetaClient metaClient = 
getHoodieMetaClient(HoodieTableType.COPY_ON_WRITE);
+      insertFirstBigBatchForClientCleanerTest(context(), metaClient, client, 
recordInsertGenWrappedFunction, insertFn);
+
+      // Keep doing some writes and clean inline. Make sure we have expected 
number of files remaining.
+      for (int i = 0; i < 8; i++) {
+        String newCommitTime = makeNewCommitTime();

Review Comment:
   added try with close for `client` - the diff above is mostly indentation 
change



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

Reply via email to