HBASE-25451 Upgrade commons-io to 2.8.0 (#2825)

Signed-off-by: Guanghao Zhang <zghao@apache.org>
Signed-off-by: stack <stack@apache.org>
This commit is contained in:
Duo Zhang 2020-12-31 16:57:27 +08:00
parent 3166109b91
commit 15d27450c2
31 changed files with 112 additions and 93 deletions

View File

@ -201,9 +201,10 @@ class AsyncConnectionImpl implements AsyncConnection {
if(LOG.isDebugEnabled()){
logCallStack(Thread.currentThread().getStackTrace());
}
IOUtils.closeQuietly(clusterStatusListener);
IOUtils.closeQuietly(rpcClient);
IOUtils.closeQuietly(registry);
IOUtils.closeQuietly(clusterStatusListener,
e -> LOG.warn("failed to close clusterStatusListener", e));
IOUtils.closeQuietly(rpcClient, e -> LOG.warn("failed to close rpcClient", e));
IOUtils.closeQuietly(registry, e -> LOG.warn("failed to close registry", e));
if (choreService != null) {
choreService.shutdown();
}

View File

@ -111,7 +111,7 @@ public class AsyncClientExample extends Configured implements Tool {
CompletableFuture<Void> closeFuture = new CompletableFuture<>();
addListener(f, (conn, error) -> {
if (error == null) {
IOUtils.closeQuietly(conn);
IOUtils.closeQuietly(conn, e -> LOG.warn("failed to close conn", e));
}
closeFuture.complete(null);
});

View File

@ -21,8 +21,6 @@ import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.util.concurrent.atomic.AtomicInteger;
import org.apache.commons.io.IOUtils;
import org.apache.hadoop.fs.CanUnbuffer;
import org.apache.hadoop.fs.FSDataInputStream;
import org.apache.hadoop.fs.FileSystem;
@ -34,6 +32,8 @@ import org.apache.yetus.audience.InterfaceAudience;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.hbase.thirdparty.com.google.common.io.Closeables;
/**
* Wrapper for input stream(s) that takes care of the interaction of FS and HBase checksums,
* as well as closing streams. Initialization is not thread-safe, but normal operation is;
@ -290,11 +290,11 @@ public class FSDataInputStreamWrapper implements Closeable {
}
updateInputStreamStatistics(this.streamNoFsChecksum);
// we do not care about the close exception as it is for reading, no data loss issue.
IOUtils.closeQuietly(streamNoFsChecksum);
Closeables.closeQuietly(streamNoFsChecksum);
updateInputStreamStatistics(stream);
IOUtils.closeQuietly(stream);
Closeables.closeQuietly(stream);
}
public HFileSystem getHfs() {

View File

@ -505,7 +505,8 @@ public final class HFile {
throw new IllegalArgumentException("Invalid HFile version " + trailer.getMajorVersion());
}
} catch (Throwable t) {
IOUtils.closeQuietly(context.getInputStreamWrapper());
IOUtils.closeQuietly(context.getInputStreamWrapper(),
e -> LOG.warn("failed to close input stream wrapper", e));
throw new CorruptHFileException("Problem reading HFile Trailer from file "
+ context.getFilePath(), t);
} finally {

View File

@ -43,7 +43,11 @@ import org.apache.hadoop.hbase.protobuf.ProtobufMagic;
import org.apache.hadoop.hbase.security.EncryptionUtil;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.yetus.audience.InterfaceAudience;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.hbase.thirdparty.com.google.protobuf.UnsafeByteOperations;
import org.apache.hadoop.hbase.shaded.protobuf.ProtobufUtil;
import org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos;
import org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.BytesBytesPair;
@ -61,6 +65,9 @@ import org.apache.hadoop.hbase.shaded.protobuf.generated.HFileProtos;
*/
@InterfaceAudience.Private
public class HFileInfo implements SortedMap<byte[], byte[]> {
private static final Logger LOG = LoggerFactory.getLogger(HFileInfo.class);
static final String RESERVED_PREFIX = "hfile.";
static final byte[] RESERVED_PREFIX_BYTES = Bytes.toBytes(RESERVED_PREFIX);
static final byte [] LASTKEY = Bytes.toBytes(RESERVED_PREFIX + "LASTKEY");
@ -342,7 +349,8 @@ public class HFileInfo implements SortedMap<byte[], byte[]> {
this.hfileContext = createHFileContext(path, trailer, conf);
context.getInputStreamWrapper().unbuffer();
} catch (Throwable t) {
IOUtils.closeQuietly(context.getInputStreamWrapper());
IOUtils.closeQuietly(context.getInputStreamWrapper(),
e -> LOG.warn("failed to close input stream wrapper", e));
throw new CorruptHFileException("Problem reading HFile Trailer from file "
+ context.getFilePath(), t);
}
@ -380,9 +388,10 @@ public class HFileInfo implements SortedMap<byte[], byte[]> {
// close the block reader
context.getInputStreamWrapper().unbuffer();
} catch (Throwable t) {
IOUtils.closeQuietly(context.getInputStreamWrapper());
throw new CorruptHFileException("Problem reading data index and meta index from file "
+ context.getFilePath(), t);
IOUtils.closeQuietly(context.getInputStreamWrapper(),
e -> LOG.warn("failed to close input stream wrapper", e));
throw new CorruptHFileException(
"Problem reading data index and meta index from file " + context.getFilePath(), t);
}
}

View File

@ -53,7 +53,6 @@ import java.util.concurrent.atomic.AtomicInteger;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import javax.servlet.http.HttpServlet;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FSDataOutputStream;
@ -216,12 +215,12 @@ import org.slf4j.LoggerFactory;
import org.apache.hbase.thirdparty.com.google.common.collect.Lists;
import org.apache.hbase.thirdparty.com.google.common.collect.Maps;
import org.apache.hbase.thirdparty.com.google.common.collect.Sets;
import org.apache.hbase.thirdparty.com.google.common.io.Closeables;
import org.apache.hbase.thirdparty.org.eclipse.jetty.server.Server;
import org.apache.hbase.thirdparty.org.eclipse.jetty.server.ServerConnector;
import org.apache.hbase.thirdparty.org.eclipse.jetty.servlet.ServletHolder;
import org.apache.hbase.thirdparty.org.eclipse.jetty.webapp.WebAppContext;
import org.apache.hadoop.hbase.shaded.protobuf.RequestConverter;
import org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.GetRegionInfoResponse;
import org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotDescription;
@ -811,7 +810,7 @@ public class HMaster extends HRegionServer implements MasterServices {
HBaseFsck.createLockRetryCounterFactory(this.conf).create());
} finally {
if (result != null) {
IOUtils.closeQuietly(result.getSecond());
Closeables.close(result.getSecond(), true);
}
}
}

View File

@ -139,6 +139,7 @@ import org.apache.hbase.thirdparty.com.google.common.base.Joiner;
import org.apache.hbase.thirdparty.com.google.common.base.Preconditions;
import org.apache.hbase.thirdparty.com.google.common.collect.Lists;
import org.apache.hbase.thirdparty.com.google.common.collect.Sets;
import org.apache.hbase.thirdparty.com.google.common.io.Closeables;
import org.apache.hbase.thirdparty.com.google.common.util.concurrent.ThreadFactoryBuilder;
import org.apache.yetus.audience.InterfaceAudience;
import org.apache.yetus.audience.InterfaceStability;
@ -513,7 +514,7 @@ public class HBaseFsck extends Configured implements Closeable {
RetryCounter retryCounter = lockFileRetryCounterFactory.create();
do {
try {
IOUtils.closeQuietly(hbckOutFd);
Closeables.close(hbckOutFd, true);
CommonFSUtils.delete(CommonFSUtils.getCurrentFileSystem(getConf()), HBCK_LOCK_PATH, true);
LOG.info("Finishing hbck");
return;
@ -566,7 +567,7 @@ public class HBaseFsck extends Configured implements Closeable {
Runtime.getRuntime().addShutdownHook(new Thread() {
@Override
public void run() {
IOUtils.closeQuietly(HBaseFsck.this);
IOUtils.closeQuietly(HBaseFsck.this, e -> LOG.warn("", e));
cleanupHbckZnode();
unlockHbck();
}
@ -865,9 +866,9 @@ public class HBaseFsck extends Configured implements Closeable {
zkw.close();
zkw = null;
}
IOUtils.closeQuietly(admin);
IOUtils.closeQuietly(meta);
IOUtils.closeQuietly(connection);
IOUtils.closeQuietly(admin, e -> LOG.warn("", e));
IOUtils.closeQuietly(meta, e -> LOG.warn("", e));
IOUtils.closeQuietly(connection, e -> LOG.warn("", e));
}
}
@ -3851,7 +3852,7 @@ public class HBaseFsck extends Configured implements Closeable {
setRetCode(code);
}
} finally {
IOUtils.closeQuietly(this);
IOUtils.closeQuietly(this, e -> LOG.warn("", e));
}
return this;
}

View File

@ -118,8 +118,8 @@ public class RegionMover extends AbstractHBaseTool implements Closeable {
@Override
public void close() {
IOUtils.closeQuietly(this.admin);
IOUtils.closeQuietly(this.conn);
IOUtils.closeQuietly(this.admin, e -> LOG.warn("failed to close admin", e));
IOUtils.closeQuietly(this.conn, e -> LOG.warn("failed to close conn", e));
}
/**

View File

@ -28,7 +28,6 @@ import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Supplier;
import org.apache.commons.io.IOUtils;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.TableName;
@ -46,6 +45,8 @@ import org.junit.rules.TestName;
import org.junit.runners.Parameterized.Parameter;
import org.junit.runners.Parameterized.Parameters;
import org.apache.hbase.thirdparty.com.google.common.io.Closeables;
public abstract class AbstractTestAsyncTableRegionReplicasRead {
protected static final HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility();
@ -152,7 +153,7 @@ public abstract class AbstractTestAsyncTableRegionReplicasRead {
@AfterClass
public static void tearDownAfterClass() throws Exception {
IOUtils.closeQuietly(ASYNC_CONN);
Closeables.close(ASYNC_CONN, true);
TEST_UTIL.shutdownMiniCluster();
}

View File

@ -26,8 +26,6 @@ import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ForkJoinPool;
import java.util.function.Supplier;
import java.util.regex.Pattern;
import org.apache.commons.io.IOUtils;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.StartMiniClusterOption;
@ -44,6 +42,8 @@ import org.junit.runners.Parameterized.Parameters;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.hbase.thirdparty.com.google.common.io.Closeables;
/**
* Class to test AsyncAdmin.
*/
@ -93,7 +93,7 @@ public abstract class TestAsyncAdminBase extends AbstractTestUpdateConfiguration
@AfterClass
public static void tearDownAfterClass() throws Exception {
IOUtils.closeQuietly(ASYNC_CONN);
Closeables.close(ASYNC_CONN, true);
TEST_UTIL.shutdownMiniCluster();
}

View File

@ -29,7 +29,6 @@ import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;
import java.util.function.Supplier;
import org.apache.commons.io.IOUtils;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HConstants;
@ -53,6 +52,8 @@ import org.junit.runners.Parameterized.Parameters;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.hbase.thirdparty.com.google.common.io.Closeables;
@RunWith(Parameterized.class)
@Category({ LargeTests.class, ClientTests.class })
public class TestAsyncAdminBuilder {
@ -98,7 +99,7 @@ public class TestAsyncAdminBuilder {
@After
public void tearDown() throws Exception {
IOUtils.closeQuietly(ASYNC_CONN);
Closeables.close(ASYNC_CONN, true);
TEST_UTIL.shutdownMiniCluster();
}

View File

@ -22,7 +22,6 @@ import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.util.concurrent.TimeUnit;
import org.apache.commons.io.IOUtils;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.master.HMaster;
@ -37,6 +36,8 @@ import org.junit.ClassRule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.apache.hbase.thirdparty.com.google.common.io.Closeables;
/**
* Only used to test stopMaster/stopRegionServer/shutdown methods.
*/
@ -71,7 +72,7 @@ public class TestAsyncClusterAdminApi2 extends TestAsyncAdminBase {
@After
@Override
public void tearDown() throws Exception {
IOUtils.closeQuietly(ASYNC_CONN);
Closeables.close(ASYNC_CONN, true);
TEST_UTIL.shutdownMiniCluster();
}

View File

@ -19,7 +19,6 @@ package org.apache.hadoop.hbase.client;
import static org.apache.hadoop.hbase.client.RegionReplicaTestHelper.testLocator;
import org.apache.commons.io.IOUtils;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HRegionLocation;
@ -34,6 +33,8 @@ import org.junit.ClassRule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.apache.hbase.thirdparty.com.google.common.io.Closeables;
@Category({ MediumTests.class, ClientTests.class })
public class TestAsyncMetaRegionLocator {
@ -60,7 +61,7 @@ public class TestAsyncMetaRegionLocator {
@AfterClass
public static void tearDown() throws Exception {
IOUtils.closeQuietly(REGISTRY);
Closeables.close(REGISTRY, true);
TEST_UTIL.shutdownMiniCluster();
}

View File

@ -36,7 +36,6 @@ import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ThreadLocalRandom;
import java.util.stream.IntStream;
import org.apache.commons.io.IOUtils;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtility;
@ -64,6 +63,8 @@ import org.junit.runners.Parameterized;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.hbase.thirdparty.com.google.common.io.Closeables;
@Category({ MediumTests.class, ClientTests.class })
@RunWith(Parameterized.class)
public class TestAsyncNonMetaRegionLocator {
@ -115,7 +116,7 @@ public class TestAsyncNonMetaRegionLocator {
@AfterClass
public static void tearDown() throws Exception {
IOUtils.closeQuietly(CONN);
Closeables.close(CONN, true);
TEST_UTIL.shutdownMiniCluster();
}

View File

@ -32,7 +32,6 @@ import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.IntStream;
import org.apache.commons.io.IOUtils;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtility;
@ -55,6 +54,8 @@ import org.junit.ClassRule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.apache.hbase.thirdparty.com.google.common.io.Closeables;
@Category({ MediumTests.class, ClientTests.class })
public class TestAsyncNonMetaRegionLocatorConcurrenyLimit {
@ -136,7 +137,7 @@ public class TestAsyncNonMetaRegionLocatorConcurrenyLimit {
@AfterClass
public static void tearDown() throws Exception {
IOUtils.closeQuietly(CONN);
Closeables.close(CONN, true);
TEST_UTIL.shutdownMiniCluster();
}

View File

@ -32,7 +32,6 @@ import java.util.concurrent.CompletionException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
import org.apache.commons.io.IOUtils;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtility;
@ -56,6 +55,8 @@ import org.junit.ClassRule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.apache.hbase.thirdparty.com.google.common.io.Closeables;
@Category({ MediumTests.class, ClientTests.class })
public class TestAsyncRegionLocator {
@ -107,7 +108,7 @@ public class TestAsyncRegionLocator {
@AfterClass
public static void tearDown() throws Exception {
IOUtils.closeQuietly(CONN);
Closeables.close(CONN, true);
TEST_UTIL.shutdownMiniCluster();
}

View File

@ -29,7 +29,6 @@ import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import org.apache.commons.io.IOUtils;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HRegionLocation;
@ -44,6 +43,8 @@ import org.junit.ClassRule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.apache.hbase.thirdparty.com.google.common.io.Closeables;
@Category({ MediumTests.class, ClientTests.class })
public class TestAsyncSingleRequestRpcRetryingCaller {
@ -79,7 +80,7 @@ public class TestAsyncSingleRequestRpcRetryingCaller {
@AfterClass
public static void tearDownAfterClass() throws Exception {
IOUtils.closeQuietly(CONN);
Closeables.close(CONN, true);
TEST_UTIL.shutdownMiniCluster();
}

View File

@ -41,7 +41,6 @@ import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
import java.util.function.Supplier;
import java.util.stream.IntStream;
import org.apache.commons.io.IOUtils;
import org.apache.hadoop.hbase.CompareOperator;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtility;
@ -71,6 +70,8 @@ import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameter;
import org.junit.runners.Parameterized.Parameters;
import org.apache.hbase.thirdparty.com.google.common.io.Closeables;
@RunWith(Parameterized.class)
@Category({ MediumTests.class, ClientTests.class })
public class TestAsyncTable {
@ -128,7 +129,7 @@ public class TestAsyncTable {
@AfterClass
public static void tearDownAfterClass() throws Exception {
IOUtils.closeQuietly(ASYNC_CONN);
Closeables.close(ASYNC_CONN, true);
assertTrue(ASYNC_CONN.isClosed());
TEST_UTIL.shutdownMiniCluster();
}

View File

@ -21,7 +21,6 @@ import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.io.IOException;
import org.apache.commons.io.IOUtils;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.TableName;
@ -34,6 +33,8 @@ import org.junit.ClassRule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.apache.hbase.thirdparty.com.google.common.io.Closeables;
/**
* Fix an infinite loop in {@link AsyncNonMetaRegionLocator}, see the comments on HBASE-21943 for
* more details.
@ -69,7 +70,7 @@ public class TestAsyncTableLocateRegionForDeletedTable {
@AfterClass
public static void tearDownAfterClass() throws Exception {
IOUtils.closeQuietly(ASYNC_CONN);
Closeables.close(ASYNC_CONN, true);
assertTrue(ASYNC_CONN.isClosed());
TEST_UTIL.shutdownMiniCluster();
}

View File

@ -26,7 +26,6 @@ import java.util.Optional;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import org.apache.commons.io.IOUtils;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.TableName;
@ -47,6 +46,8 @@ import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.rules.TestName;
import org.apache.hbase.thirdparty.com.google.common.io.Closeables;
@Category({ MediumTests.class, ClientTests.class })
public class TestAsyncTableNoncedRetry {
@ -114,7 +115,7 @@ public class TestAsyncTableNoncedRetry {
@AfterClass
public static void tearDownAfterClass() throws Exception {
IOUtils.closeQuietly(ASYNC_CONN);
Closeables.close(ASYNC_CONN, true);
TEST_UTIL.shutdownMiniCluster();
}

View File

@ -25,7 +25,6 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.ForkJoinPool;
import org.apache.commons.io.IOUtils;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.PrivateCellUtil;
@ -45,6 +44,8 @@ import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameter;
import org.junit.runners.Parameterized.Parameters;
import org.apache.hbase.thirdparty.com.google.common.io.Closeables;
@RunWith(Parameterized.class)
@Category({ MediumTests.class, ClientTests.class })
public class TestAsyncTableScanMetrics {
@ -105,7 +106,7 @@ public class TestAsyncTableScanMetrics {
@AfterClass
public static void tearDown() throws Exception {
IOUtils.closeQuietly(CONN);
Closeables.close(CONN, true);
UTIL.shutdownMiniCluster();
}

View File

@ -21,9 +21,9 @@ import static org.apache.hadoop.hbase.HConstants.EMPTY_START_ROW;
import static org.apache.hadoop.hbase.TableName.META_TABLE_NAME;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
import org.apache.commons.io.IOUtils;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtility;
@ -40,6 +40,8 @@ import org.junit.experimental.categories.Category;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.hbase.thirdparty.com.google.common.io.Closeables;
@Category({ MediumTests.class, ClientTests.class })
public class TestCatalogReplicaLoadBalanceSimpleSelector {
@ -80,7 +82,7 @@ public class TestCatalogReplicaLoadBalanceSimpleSelector {
@AfterClass
public static void tearDown() throws Exception {
IOUtils.closeQuietly(CONN);
Closeables.close(CONN, true);
TEST_UTIL.shutdownMiniCluster();
}

View File

@ -23,7 +23,6 @@ import static org.junit.Assert.assertFalse;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.apache.commons.io.IOUtils;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtility;
@ -48,6 +47,8 @@ import org.junit.ClassRule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.apache.hbase.thirdparty.com.google.common.io.Closeables;
@Category({SmallTests.class, MasterTests.class })
public class TestMetaRegionLocationCache {
@ClassRule
@ -68,7 +69,7 @@ public class TestMetaRegionLocationCache {
@AfterClass
public static void cleanUp() throws Exception {
IOUtils.closeQuietly(REGISTRY);
Closeables.close(REGISTRY, true);
TEST_UTIL.shutdownMiniCluster();
}

View File

@ -31,7 +31,6 @@ import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.stream.IntStream;
import org.apache.commons.io.IOUtils;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.Abortable;
import org.apache.hadoop.hbase.HBaseClassTestRule;
@ -61,6 +60,8 @@ import org.junit.rules.TestName;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.hbase.thirdparty.com.google.common.io.Closeables;
@Category({ MediumTests.class, ClientTests.class })
public class TestZKConnectionRegistry {
@ -85,7 +86,7 @@ public class TestZKConnectionRegistry {
@AfterClass
public static void tearDown() throws Exception {
IOUtils.closeQuietly(REGISTRY);
Closeables.close(REGISTRY, true);
TEST_UTIL.shutdownMiniCluster();
}

View File

@ -33,8 +33,6 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;
import org.apache.commons.io.IOUtils;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.ClusterMetrics.Option;
import org.apache.hadoop.hbase.HBaseClassTestRule;
@ -107,7 +105,8 @@ public class TestMasterOperationsForRegionReplicas {
}
private static void resetConnections() throws IOException {
IOUtils.closeQuietly(ADMIN, CONNECTION);
Closeables.close(ADMIN, true);
Closeables.close(CONNECTION, true);
CONNECTION = ConnectionFactory.createConnection(TEST_UTIL.getConfiguration());
ADMIN = CONNECTION.getAdmin();
}

View File

@ -30,7 +30,6 @@ import java.util.Random;
import java.util.Set;
import java.util.TreeSet;
import java.util.stream.Collectors;
import org.apache.commons.io.IOUtils;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.ChoreService;
import org.apache.hadoop.hbase.HBaseClassTestRule;
@ -306,24 +305,15 @@ public class TestEndToEndSplitTransaction {
/** verify region boundaries obtained from HTable.getStartEndKeys() */
void verifyRegionsUsingHTable() throws IOException {
Table table = null;
try {
// HTable.getStartEndKeys()
table = connection.getTable(tableName);
try (RegionLocator rl = connection.getRegionLocator(tableName)) {
Pair<byte[][], byte[][]> keys = rl.getStartEndKeys();
verifyStartEndKeys(keys);
try (RegionLocator rl = connection.getRegionLocator(tableName)) {
Pair<byte[][], byte[][]> keys = rl.getStartEndKeys();
verifyStartEndKeys(keys);
Set<RegionInfo> regions = new TreeSet<>(RegionInfo.COMPARATOR);
for (HRegionLocation loc : rl.getAllRegionLocations()) {
regions.add(loc.getRegion());
}
verifyTableRegions(regions);
Set<RegionInfo> regions = new TreeSet<>(RegionInfo.COMPARATOR);
for (HRegionLocation loc : rl.getAllRegionLocations()) {
regions.add(loc.getRegion());
}
} finally {
IOUtils.closeQuietly(table);
verifyTableRegions(regions);
}
}

View File

@ -38,7 +38,6 @@ import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicBoolean;
import org.apache.commons.io.IOUtils;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
@ -116,6 +115,7 @@ import org.mockito.Mockito;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.hbase.thirdparty.com.google.common.io.Closeables;
import org.apache.hbase.thirdparty.com.google.protobuf.RpcController;
import org.apache.hbase.thirdparty.com.google.protobuf.ServiceException;
@ -898,7 +898,7 @@ public class TestSplitTransactionOnCluster {
HMaster master = cluster.startMaster().getMaster();
cluster.waitForActiveAndReadyMaster();
// reset the connections
IOUtils.closeQuietly(admin);
Closeables.close(admin, true);
TESTING_UTIL.invalidateConnection();
admin = TESTING_UTIL.getAdmin();
return master;

View File

@ -24,7 +24,6 @@ import static org.junit.Assert.fail;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.io.IOUtils;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.HBaseTestingUtility;
@ -54,6 +53,8 @@ import org.junit.BeforeClass;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.hbase.thirdparty.com.google.common.io.Closeables;
/**
* This class is only a base for other integration-level replication tests.
* Do not add tests here.
@ -203,9 +204,9 @@ public class TestReplicationBase {
conf2.setBoolean("hbase.tests.use.shortcircuit.reads", false);
}
static void restartSourceCluster(int numSlaves)
throws Exception {
IOUtils.closeQuietly(hbaseAdmin, htable1);
static void restartSourceCluster(int numSlaves) throws Exception {
Closeables.close(hbaseAdmin, true);
Closeables.close(htable1, true);
UTIL1.shutdownMiniHBaseCluster();
UTIL1.restartHBaseCluster(numSlaves);
// Invalidate the cached connection state.
@ -216,7 +217,7 @@ public class TestReplicationBase {
}
static void restartTargetHBaseCluster(int numSlaves) throws Exception {
IOUtils.closeQuietly(htable2);
Closeables.close(htable2, true);
UTIL2.restartHBaseCluster(numSlaves);
// Invalidate the cached connection state
CONF2 = UTIL2.getConfiguration();

View File

@ -19,7 +19,6 @@ package org.apache.hadoop.hbase.replication;
import static org.apache.hadoop.hbase.HConstants.REPLICATION_SCOPE_GLOBAL;
import org.apache.commons.io.IOUtils;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.TableName;
@ -143,24 +142,28 @@ public abstract class TestReplicationSyncUpToolBase {
// Utilities that manager shutdown / restart of source / sink clusters. They take care of
// invalidating stale connections after shutdown / restarts.
final void shutDownSourceHBaseCluster() throws Exception {
IOUtils.closeQuietly(ht1Source, ht2Source);
Closeables.close(ht1Source, true);
Closeables.close(ht2Source, true);
UTIL1.shutdownMiniHBaseCluster();
}
final void shutDownTargetHBaseCluster() throws Exception {
IOUtils.closeQuietly(ht1TargetAtPeer1, ht2TargetAtPeer1);
Closeables.close(ht1TargetAtPeer1, true);
Closeables.close(ht2TargetAtPeer1, true);
UTIL2.shutdownMiniHBaseCluster();
}
final void restartSourceHBaseCluster(int numServers) throws Exception {
IOUtils.closeQuietly(ht1Source, ht2Source);
Closeables.close(ht1Source, true);
Closeables.close(ht2Source, true);
UTIL1.restartHBaseCluster(numServers);
ht1Source = UTIL1.getConnection().getTable(TN1);
ht2Source = UTIL1.getConnection().getTable(TN2);
}
final void restartTargetHBaseCluster(int numServers) throws Exception {
IOUtils.closeQuietly(ht1TargetAtPeer1, ht2TargetAtPeer1);
Closeables.close(ht1TargetAtPeer1, true);
Closeables.close(ht2TargetAtPeer1, true);
UTIL2.restartHBaseCluster(numServers);
ht1TargetAtPeer1 = UTIL2.getConnection().getTable(TN1);
ht2TargetAtPeer1 = UTIL2.getConnection().getTable(TN2);

View File

@ -25,8 +25,6 @@ import java.util.List;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.Callable;
import java.util.concurrent.LinkedBlockingQueue;
import org.apache.commons.io.IOUtils;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.HBaseClassTestRule;
@ -57,6 +55,7 @@ import org.junit.experimental.categories.Category;
import org.apache.hbase.thirdparty.com.google.common.collect.ImmutableList;
import org.apache.hbase.thirdparty.com.google.common.collect.ImmutableMap;
import org.apache.hbase.thirdparty.com.google.common.io.Closeables;
@Category({ ReplicationTests.class, MediumTests.class })
public class TestSerialReplicationEndpoint {
@ -79,7 +78,7 @@ public class TestSerialReplicationEndpoint {
@AfterClass
public static void tearDown() throws Exception {
IOUtils.closeQuietly(CONN);
Closeables.close(CONN, true);
UTIL.shutdownMiniCluster();
}

View File

@ -1418,7 +1418,7 @@
<caffeine.version>2.8.1</caffeine.version>
<commons-codec.version>1.13</commons-codec.version>
<!-- pretty outdated -->
<commons-io.version>2.6</commons-io.version>
<commons-io.version>2.8.0</commons-io.version>
<commons-lang3.version>3.9</commons-lang3.version>
<commons-math.version>3.6.1</commons-math.version>
<disruptor.version>3.4.2</disruptor.version>