Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HDDS-10502. Improve generic type of IOUtils.close #6361

Merged
merged 1 commit into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public static void close(Logger logger, AutoCloseable... closeables) {
* Close each argument, catching exceptions and logging them as error.
*/
public static void close(Logger logger,
Collection<AutoCloseable> closeables) {
Collection<? extends AutoCloseable> closeables) {
if (closeables == null) {
return;
}
Expand All @@ -94,7 +94,7 @@ public static void closeQuietly(AutoCloseable... closeables) {
/**
* Close each argument, swallowing exceptions.
*/
public static void closeQuietly(Collection<AutoCloseable> closeables) {
public static void closeQuietly(Collection<? extends AutoCloseable> closeables) {
close(null, closeables);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ public HeapEntry next() {
}

public void close() throws IOException {
iterators.forEach(IOUtils::closeQuietly);
IOUtils.closeQuietly(iterators);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -391,13 +391,8 @@ public OmSnapshot load(@Nonnull UUID key) {
@AfterEach
public void tearDown() {
IOUtils.closeQuietly(snapshotDiffManager);
if (columnFamilyHandles != null) {
columnFamilyHandles.forEach(IOUtils::closeQuietly);
}

IOUtils.closeQuietly(db);
IOUtils.closeQuietly(dbOptions);
IOUtils.closeQuietly(columnFamilyOptions);
IOUtils.closeQuietly(columnFamilyHandles);
IOUtils.closeQuietly(db, dbOptions, columnFamilyOptions);
}

private OmSnapshot getMockedOmSnapshot(UUID snapshotId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,7 @@ private void downloadReplicasAndCreateManifest(
blockJson.add(JSON_PROPERTY_BLOCK_REPLICAS, replicasJson);
blocks.add(blockJson);

blockReplicasWithoutChecksum.values()
.forEach(each -> IOUtils.close(LOG, each));
IOUtils.close(LOG, blockReplicasWithoutChecksum.values());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package org.apache.hadoop.ozone.freon;


import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.RandomUtils;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hdds.DatanodeVersion;
Expand All @@ -43,6 +42,7 @@
import org.apache.hadoop.hdds.upgrade.HDDSLayoutVersionManager;
import org.apache.hadoop.hdds.utils.HAUtils;
import org.apache.hadoop.hdds.utils.HddsServerUtil;
import org.apache.hadoop.hdds.utils.IOUtils;
import org.apache.hadoop.hdds.utils.LegacyHadoopConfigurationSource;
import org.apache.hadoop.io.retry.RetryPolicies;
import org.apache.hadoop.io.retry.RetryPolicy;
Expand Down Expand Up @@ -186,7 +186,7 @@ public Void call() throws Exception {
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
scmClients.values().forEach(IOUtils::closeQuietly);
IOUtils.closeQuietly(scmClients.values());
IOUtils.closeQuietly(reconClient);
LOGGER.info("Successfully closed all the used resources");
saveDatanodesToFile();
Expand Down