From 43ae73ff60ba180c058979b38834d8dd5ab0f4ee Mon Sep 17 00:00:00 2001 From: Christopher Tubbs Date: Thu, 12 Mar 2020 19:53:25 -0400 Subject: [PATCH 1/4] Update dependency and plugin versions Fix warnings due to updated dependencies * Use new vfs2 method instead of deprecated one * Use assertThrows instead of ExpectedException * Remove hamcrest dependency, because it's not needed any more --- .../clientImpl/lexicoder/ByteUtilsTest.java | 9 +- .../core/conf/AccumuloConfigurationTest.java | 9 +- .../core/conf/ClientPropertyTest.java | 10 +- .../accumulo/core/crypto/CryptoTest.java | 30 ++---- .../core/util/PreAllocatedArrayTest.java | 21 ++--- .../core/util/UnsynchronizedBufferTest.java | 11 +-- .../apache/accumulo/fate/util/RetryTest.java | 36 +++----- .../mapred/AccumuloInputFormatTest.java | 8 +- .../mapreduce/AccumuloInputFormatTest.java | 9 +- pom.xml | 92 +++++++++---------- .../server/fs/PerTableVolumeChooserTest.java | 23 +---- .../server/fs/PreferredVolumeChooserTest.java | 31 ++----- .../server/fs/VolumeManagerImplTest.java | 21 +---- .../accumulo/tserver/InMemoryMapTest.java | 11 +-- .../compaction/CompactionPlanTest.java | 16 +--- .../tserver/log/SortedLogRecoveryTest.java | 15 +-- .../vfs/AccumuloReloadingVFSClassLoader.java | 6 +- test/pom.xml | 4 - .../test/functional/ClassLoaderIT.java | 3 +- .../test/functional/ScannerContextIT.java | 3 +- .../accumulo/test/functional/TableIT.java | 3 +- .../accumulo/test/rpc/ThriftBehaviorIT.java | 23 ++--- 22 files changed, 131 insertions(+), 263 deletions(-) diff --git a/core/src/test/java/org/apache/accumulo/core/clientImpl/lexicoder/ByteUtilsTest.java b/core/src/test/java/org/apache/accumulo/core/clientImpl/lexicoder/ByteUtilsTest.java index 6a89f754697..629434e8879 100644 --- a/core/src/test/java/org/apache/accumulo/core/clientImpl/lexicoder/ByteUtilsTest.java +++ b/core/src/test/java/org/apache/accumulo/core/clientImpl/lexicoder/ByteUtilsTest.java @@ -20,16 +20,12 @@ import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThrows; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; public class ByteUtilsTest { - @Rule - public ExpectedException exception = ExpectedException.none(); - private final byte[] empty = new byte[0]; private final byte[] noSplits = "nosplits".getBytes(); private final byte[] splitAt5 = ("1234" + (char) 0x00 + "56789").getBytes(); @@ -93,8 +89,7 @@ public void testEscape() { @Test public void testIllegalArgument() { // incomplete bytes would cause an ArrayIndexOutOfBounds in the past - exception.expect(IllegalArgumentException.class); byte[] errorBytes = {0x01}; - ByteUtils.unescape(errorBytes); + assertThrows(IllegalArgumentException.class, () -> ByteUtils.unescape(errorBytes)); } } diff --git a/core/src/test/java/org/apache/accumulo/core/conf/AccumuloConfigurationTest.java b/core/src/test/java/org/apache/accumulo/core/conf/AccumuloConfigurationTest.java index a530470a269..55f0af703c8 100644 --- a/core/src/test/java/org/apache/accumulo/core/conf/AccumuloConfigurationTest.java +++ b/core/src/test/java/org/apache/accumulo/core/conf/AccumuloConfigurationTest.java @@ -22,6 +22,7 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotSame; import static org.junit.Assert.assertSame; +import static org.junit.Assert.assertThrows; import static org.junit.Assert.assertTrue; import java.util.Collection; @@ -32,15 +33,10 @@ import org.apache.accumulo.core.conf.AccumuloConfiguration.ScanExecutorConfig; import org.apache.accumulo.core.spi.scan.SimpleScanDispatcher; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; public class AccumuloConfigurationTest { - @Rule - public ExpectedException thrown = ExpectedException.none(); - @Test public void testGetPropertyByString() { AccumuloConfiguration c = DefaultConfiguration.getInstance(); @@ -196,8 +192,7 @@ public void testMutatePrefixMap() { expected1.put(Property.TABLE_ARBITRARY_PROP_PREFIX.getKey() + "a2", "asg34"); assertEquals(expected1, pm1); - thrown.expect(UnsupportedOperationException.class); - pm1.put("k9", "v3"); + assertThrows(UnsupportedOperationException.class, () -> pm1.put("k9", "v3")); } @Test diff --git a/core/src/test/java/org/apache/accumulo/core/conf/ClientPropertyTest.java b/core/src/test/java/org/apache/accumulo/core/conf/ClientPropertyTest.java index f5efe5c306b..6f861f594d8 100644 --- a/core/src/test/java/org/apache/accumulo/core/conf/ClientPropertyTest.java +++ b/core/src/test/java/org/apache/accumulo/core/conf/ClientPropertyTest.java @@ -19,15 +19,14 @@ package org.apache.accumulo.core.conf; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThrows; import static org.junit.Assert.assertTrue; import java.util.Properties; import org.apache.accumulo.core.client.security.tokens.AuthenticationToken; import org.apache.accumulo.core.client.security.tokens.PasswordToken; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; public class ClientPropertyTest { @@ -59,9 +58,6 @@ public void testAuthentication() { assertEquals("/path/to/keytab", ClientProperty.AUTH_TOKEN.getValue(props)); } - @Rule - public ExpectedException exception = ExpectedException.none(); - @Test public void testTypes() { Properties props = new Properties(); @@ -81,7 +77,7 @@ public void testTypes() { value = ClientProperty.BATCH_WRITER_LATENCY_MAX.getTimeInMillis(props); assertEquals(1234L, value.longValue()); - exception.expect(IllegalStateException.class); - ClientProperty.BATCH_WRITER_LATENCY_MAX.getBytes(props); + assertThrows(IllegalStateException.class, + () -> ClientProperty.BATCH_WRITER_LATENCY_MAX.getBytes(props)); } } diff --git a/core/src/test/java/org/apache/accumulo/core/crypto/CryptoTest.java b/core/src/test/java/org/apache/accumulo/core/crypto/CryptoTest.java index 9b73c836c5f..4cca2d74ad9 100644 --- a/core/src/test/java/org/apache/accumulo/core/crypto/CryptoTest.java +++ b/core/src/test/java/org/apache/accumulo/core/crypto/CryptoTest.java @@ -23,7 +23,7 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.fail; +import static org.junit.Assert.assertThrows; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -73,9 +73,7 @@ import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; import org.junit.BeforeClass; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; import com.google.common.collect.Iterables; @@ -93,9 +91,6 @@ public class CryptoTest { System.getProperty("user.dir") + "/target/CryptoTest-emptykeyfile"; private static Configuration hadoopConf = new Configuration(); - @Rule - public ExpectedException exception = ExpectedException.none(); - @BeforeClass public static void setupKeyFiles() throws Exception { FileSystem fs = FileSystem.getLocal(hadoopConf); @@ -279,9 +274,9 @@ public void testMissingConfigProperties() throws ReflectiveOperationException { AccumuloVFSClassLoader.loadClass(configuredClass, CryptoService.class); CryptoService cs = clazz.getDeclaredConstructor().newInstance(); - exception.expect(NullPointerException.class); - cs.init(aconf.getAllPropertiesWithPrefix(Property.TABLE_PREFIX)); assertEquals(AESCryptoService.class, cs.getClass()); + assertThrows(NullPointerException.class, + () -> cs.init(aconf.getAllPropertiesWithPrefix(Property.TABLE_PREFIX))); } @SuppressFBWarnings(value = "CIPHER_INTEGRITY", justification = "CBC is being tested") @@ -297,8 +292,9 @@ public void testAESKeyUtilsGeneratesKey() throws NoSuchAlgorithmException, key = AESKeyUtils.generateKey(sr, 32); key = AESKeyUtils.generateKey(sr, 11); - exception.expect(InvalidKeyException.class); - Cipher.getInstance("AES/CBC/NoPadding").init(Cipher.ENCRYPT_MODE, key); + final java.security.Key key2 = key; + assertThrows(InvalidKeyException.class, + () -> Cipher.getInstance("AES/CBC/NoPadding").init(Cipher.ENCRYPT_MODE, key2)); } @Test @@ -324,9 +320,7 @@ public void testAESKeyUtilsFailUnwrapWithWrongKEK() java.security.Key wrongKek = new SecretKeySpec(wrongBytes, "AES"); byte[] wrapped = AESKeyUtils.wrapKey(fek, kek); - exception.expect(CryptoException.class); - java.security.Key unwrapped = AESKeyUtils.unwrapKey(wrapped, wrongKek); - fail("creation of " + unwrapped + " should fail"); + assertThrows(CryptoException.class, () -> AESKeyUtils.unwrapKey(wrapped, wrongKek)); } @Test @@ -341,17 +335,13 @@ public void testAESKeyUtilsLoadKekFromUri() throws IOException { @Test public void testAESKeyUtilsLoadKekFromUriInvalidUri() { - exception.expect(CryptoException.class); - SecretKeySpec fileKey = AESKeyUtils.loadKekFromUri( - System.getProperty("user.dir") + "/target/CryptoTest-testkeyfile-doesnt-exist"); - fail("creation of " + fileKey + " should fail"); + assertThrows(CryptoException.class, () -> AESKeyUtils.loadKekFromUri( + System.getProperty("user.dir") + "/target/CryptoTest-testkeyfile-doesnt-exist")); } @Test public void testAESKeyUtilsLoadKekFromEmptyFile() { - exception.expect(CryptoException.class); - SecretKeySpec fileKey = AESKeyUtils.loadKekFromUri(emptyKeyPath); - fail("creation of " + fileKey + " should fail"); + assertThrows(CryptoException.class, () -> AESKeyUtils.loadKekFromUri(emptyKeyPath)); } private ArrayList testData() { diff --git a/core/src/test/java/org/apache/accumulo/core/util/PreAllocatedArrayTest.java b/core/src/test/java/org/apache/accumulo/core/util/PreAllocatedArrayTest.java index 037a88e9fbb..7c48fbde8ba 100644 --- a/core/src/test/java/org/apache/accumulo/core/util/PreAllocatedArrayTest.java +++ b/core/src/test/java/org/apache/accumulo/core/util/PreAllocatedArrayTest.java @@ -21,18 +21,14 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertThrows; import java.util.Iterator; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; public class PreAllocatedArrayTest { - @Rule - public ExpectedException exception = ExpectedException.none(); - /** * Test method for {@link org.apache.accumulo.core.util.PreAllocatedArray#PreAllocatedArray(int)}. */ @@ -50,8 +46,7 @@ public void testPreAllocatedArray() { @Test public void testPreAllocatedArray_Fail() { - exception.expect(IllegalArgumentException.class); - new PreAllocatedArray(-5); + assertThrows(IllegalArgumentException.class, () -> new PreAllocatedArray(-5)); } /** @@ -89,31 +84,27 @@ public void testSet() { public void testSetIndexHigh() { PreAllocatedArray strings = new PreAllocatedArray<>(3); strings.set(2, "in bounds"); - exception.expect(IndexOutOfBoundsException.class); - strings.set(3, "out of bounds"); + assertThrows(IndexOutOfBoundsException.class, () -> strings.set(3, "out of bounds")); } @Test public void testSetIndexNegative() { PreAllocatedArray strings = new PreAllocatedArray<>(3); strings.set(0, "in bounds"); - exception.expect(IndexOutOfBoundsException.class); - strings.set(-3, "out of bounds"); + assertThrows(IndexOutOfBoundsException.class, () -> strings.set(-3, "out of bounds")); } @Test public void testGetIndexHigh() { PreAllocatedArray strings = new PreAllocatedArray<>(3); strings.get(2); - exception.expect(IndexOutOfBoundsException.class); - strings.get(3); + assertThrows(IndexOutOfBoundsException.class, () -> strings.get(3)); } @Test public void testGetIndexNegative() { PreAllocatedArray strings = new PreAllocatedArray<>(3); strings.get(0); - exception.expect(IndexOutOfBoundsException.class); - strings.get(-3); + assertThrows(IndexOutOfBoundsException.class, () -> strings.get(-3)); } } diff --git a/core/src/test/java/org/apache/accumulo/core/util/UnsynchronizedBufferTest.java b/core/src/test/java/org/apache/accumulo/core/util/UnsynchronizedBufferTest.java index c9886ae9b9a..93c2b89bddf 100644 --- a/core/src/test/java/org/apache/accumulo/core/util/UnsynchronizedBufferTest.java +++ b/core/src/test/java/org/apache/accumulo/core/util/UnsynchronizedBufferTest.java @@ -20,6 +20,7 @@ import static java.nio.charset.StandardCharsets.UTF_8; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThrows; import static org.junit.Assert.assertTrue; import java.io.ByteArrayOutputStream; @@ -28,15 +29,10 @@ import java.util.Arrays; import org.apache.hadoop.io.WritableUtils; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; public class UnsynchronizedBufferTest { - @Rule - public ExpectedException thrown = ExpectedException.none(); - @Test public void testByteBufferConstructor() { byte[] test = "0123456789".getBytes(UTF_8); @@ -57,8 +53,9 @@ public void testByteBufferConstructor() { buf = new byte[6]; // the byte buffer has the extra byte, but should not be able to read it... - thrown.expect(ArrayIndexOutOfBoundsException.class); - ub.readBytes(buf); + final UnsynchronizedBuffer.Reader ub2 = ub; + final byte[] buf2 = buf; + assertThrows(ArrayIndexOutOfBoundsException.class, () -> ub2.readBytes(buf2)); } @Test diff --git a/core/src/test/java/org/apache/accumulo/fate/util/RetryTest.java b/core/src/test/java/org/apache/accumulo/fate/util/RetryTest.java index a15f06d5b5c..745d268bcd8 100644 --- a/core/src/test/java/org/apache/accumulo/fate/util/RetryTest.java +++ b/core/src/test/java/org/apache/accumulo/fate/util/RetryTest.java @@ -25,8 +25,8 @@ import static java.util.concurrent.TimeUnit.NANOSECONDS; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertThrows; import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; import java.util.concurrent.TimeUnit; @@ -38,9 +38,7 @@ import org.apache.accumulo.fate.util.Retry.RetryFactory; import org.easymock.EasyMock; import org.junit.Before; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; import org.slf4j.Logger; public class RetryTest { @@ -54,9 +52,6 @@ public class RetryTest { private Retry unlimitedRetry; private static final TimeUnit MS = MILLISECONDS; - @Rule - public ExpectedException exception = ExpectedException.none(); - @Before public void setup() { retry = Retry.builder().maxRetries(MAX_RETRIES).retryAfter(INITIAL_WAIT, MS) @@ -103,9 +98,7 @@ public void usingNonExistentRetryFails() { assertFalse(retry.canRetry()); // Calling useRetry when canRetry returns false throws an exception - exception.expect(IllegalStateException.class); - retry.useRetry(); - fail("previous command should have thrown IllegalStateException"); + assertThrows(IllegalStateException.class, () -> retry.useRetry()); } @Test @@ -245,9 +238,8 @@ public void testMaxRetries() { NeedsRetries builder = Retry.builder(); builder.maxRetries(10); builder.maxRetries(0); - exception.expect(IllegalArgumentException.class); - builder.maxRetries(-1); - fail("Should not allow negative retries"); + assertThrows("Should not allow negative retries", IllegalArgumentException.class, + () -> builder.maxRetries(-1)); } @Test @@ -260,9 +252,8 @@ public void testInitialWait() { builder.retryAfter(0, MILLISECONDS); builder.retryAfter(0, DAYS); - exception.expect(IllegalArgumentException.class); - builder.retryAfter(-1, NANOSECONDS); - fail("Should not allow negative wait times"); + assertThrows("Should not allow negative wait times", IllegalArgumentException.class, + () -> builder.retryAfter(-1, NANOSECONDS)); } @Test @@ -275,9 +266,8 @@ public void testIncrementBy() { builder.incrementBy(0, HOURS); builder.incrementBy(0, NANOSECONDS); - exception.expect(IllegalArgumentException.class); - builder.incrementBy(-1, NANOSECONDS); - fail("Should not allow negative increments"); + assertThrows("Should not allow negative increments", IllegalArgumentException.class, + () -> builder.incrementBy(-1, NANOSECONDS)); } @Test @@ -287,9 +277,8 @@ public void testMaxWait() { builder.maxWait(15, MILLISECONDS); builder.maxWait(16, MILLISECONDS); - exception.expect(IllegalArgumentException.class); - builder.maxWait(14, MILLISECONDS); - fail("Max wait time should be greater than or equal to initial wait time"); + assertThrows("Max wait time should be greater than or equal to initial wait time", + IllegalArgumentException.class, () -> builder.maxWait(14, MILLISECONDS)); } @Test @@ -303,9 +292,8 @@ public void testLogInterval() { builder.logInterval(0, HOURS); builder.logInterval(0, NANOSECONDS); - exception.expect(IllegalArgumentException.class); - builder.logInterval(-1, NANOSECONDS); - fail("Log interval must not be negative"); + assertThrows("Log interval must not be negative", IllegalArgumentException.class, + () -> builder.logInterval(-1, NANOSECONDS)); } @Test diff --git a/hadoop-mapreduce/src/test/java/org/apache/accumulo/hadoop/mapred/AccumuloInputFormatTest.java b/hadoop-mapreduce/src/test/java/org/apache/accumulo/hadoop/mapred/AccumuloInputFormatTest.java index 4ae0cde855b..54e8d5b98be 100644 --- a/hadoop-mapreduce/src/test/java/org/apache/accumulo/hadoop/mapred/AccumuloInputFormatTest.java +++ b/hadoop-mapreduce/src/test/java/org/apache/accumulo/hadoop/mapred/AccumuloInputFormatTest.java @@ -19,6 +19,7 @@ package org.apache.accumulo.hadoop.mapred; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThrows; import static org.junit.Assert.fail; import java.io.ByteArrayOutputStream; @@ -43,7 +44,6 @@ import org.junit.BeforeClass; import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; import org.junit.rules.TestName; public class AccumuloInputFormatTest { @@ -53,8 +53,6 @@ public class AccumuloInputFormatTest { @Rule public TestName test = new TestName(); - @Rule - public ExpectedException exception = ExpectedException.none(); @Before public void createJob() { @@ -71,8 +69,8 @@ public static void setupClientInfo() { public void testMissingTable() throws Exception { Properties clientProps = org.apache.accumulo.hadoop.mapreduce.AccumuloInputFormatTest.setupClientProperties(); - exception.expect(IllegalArgumentException.class); - AccumuloInputFormat.configure().clientProperties(clientProps).store(new JobConf()); + assertThrows(IllegalArgumentException.class, + () -> AccumuloInputFormat.configure().clientProperties(clientProps).store(new JobConf())); } /** diff --git a/hadoop-mapreduce/src/test/java/org/apache/accumulo/hadoop/mapreduce/AccumuloInputFormatTest.java b/hadoop-mapreduce/src/test/java/org/apache/accumulo/hadoop/mapreduce/AccumuloInputFormatTest.java index cf1ea1480c3..ff63f60d873 100644 --- a/hadoop-mapreduce/src/test/java/org/apache/accumulo/hadoop/mapreduce/AccumuloInputFormatTest.java +++ b/hadoop-mapreduce/src/test/java/org/apache/accumulo/hadoop/mapreduce/AccumuloInputFormatTest.java @@ -19,6 +19,7 @@ package org.apache.accumulo.hadoop.mapreduce; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThrows; import static org.junit.Assert.fail; import java.io.ByteArrayOutputStream; @@ -42,13 +43,9 @@ import org.apache.hadoop.io.Text; import org.apache.hadoop.mapreduce.Job; import org.junit.BeforeClass; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; public class AccumuloInputFormatTest { - @Rule - public ExpectedException exception = ExpectedException.none(); static Properties clientProperties; @@ -71,8 +68,8 @@ public static Properties setupClientProperties() { public void testMissingTable() throws Exception { Properties clientProps = org.apache.accumulo.hadoop.mapreduce.AccumuloInputFormatTest.setupClientProperties(); - exception.expect(IllegalArgumentException.class); - AccumuloInputFormat.configure().clientProperties(clientProps).store(Job.getInstance()); + assertThrows(IllegalArgumentException.class, () -> AccumuloInputFormat.configure() + .clientProperties(clientProps).store(Job.getInstance())); } /** diff --git a/pom.xml b/pom.xml index e4b1d4ea862..4e94155fdac 100644 --- a/pom.xml +++ b/pom.xml @@ -115,9 +115,9 @@ ${project.version} - 1.62 + 1.64 - 4.2.0 + 4.3.0 ${project.parent.basedir}/contrib/Eclipse-Accumulo-Codestyle.xml @@ -126,27 +126,26 @@ 1 - 3.1.2 - 2.5.0 + 3.2.1 + 2.6.1 4.1.0-incubating 3.2.0-incubating false - 2.10.0 + 2.10.3 3.0.1-b06 2.3.0.1 - 2.28 - 9.4.19.v20190610 + 2.30.1 + 9.4.27.v20200227 11 11 11 true - 2.0.2 + 2.0.5 false - 1.7.26 + 1.7.30 source-release-tar - 3.1.12 false @@ -162,12 +161,12 @@ com.beust jcommander - 1.72 + 1.78 com.fasterxml classmate - 1.5.0 + 1.5.1 com.fasterxml.jackson.core @@ -202,22 +201,22 @@ com.github.ben-manes.caffeine caffeine - 2.7.0 + 2.8.1 com.github.spotbugs spotbugs-annotations - ${spotbugs.version} + 4.0.0 com.google.auto.service auto-service - 1.0-rc5 + 1.0-rc6 com.google.code.gson gson - 2.8.5 + 2.8.6 @@ -228,7 +227,7 @@ com.google.guava guava - 28.0-jre + 28.2-jre com.google.protobuf @@ -248,7 +247,7 @@ commons-beanutils commons-beanutils - 1.9.3 + 1.9.4 commons-cli @@ -258,7 +257,7 @@ commons-codec commons-codec - 1.12 + 1.14 commons-io @@ -318,7 +317,7 @@ junit junit - 4.12 + 4.13 org.apache.accumulo @@ -394,12 +393,12 @@ org.apache.commons commons-collections4 - 4.3 + 4.4 org.apache.commons commons-configuration2 - 2.5 + 2.7 org.apache.commons @@ -424,12 +423,12 @@ org.apache.commons commons-text - 1.6 + 1.8 org.apache.commons commons-vfs2 - 2.3 + 2.6.0 org.apache.curator @@ -472,6 +471,11 @@ hadoop-distcp ${hadoop.version} + + org.apache.hadoop + hadoop-hdfs-client + ${hadoop.version} + org.apache.hadoop hadoop-minicluster @@ -554,7 +558,7 @@ org.easymock easymock - 4.0.2 + 4.2 org.eclipse.jetty @@ -594,7 +598,7 @@ org.freemarker freemarker - 2.3.28 + 2.3.30 org.glassfish.hk2 @@ -721,30 +725,20 @@ javax.el 2.2.6 - - org.hamcrest - hamcrest - 2.1 - - - org.hamcrest - hamcrest-core - 2.1 - org.hibernate.validator hibernate-validator - 6.1.0.Final + 6.1.2.Final org.javassist javassist - 3.25.0-GA + 3.26.0-GA org.jboss.logging jboss-logging - 3.4.0.Final + 3.4.1.Final org.powermock @@ -774,7 +768,7 @@ org.apache.logging.log4j log4j-bom - 2.13.0 + 2.13.1 pom import @@ -833,7 +827,7 @@ com.github.spotbugs spotbugs-maven-plugin - ${spotbugs.version}.1 + 3.1.12.1 true Max @@ -911,6 +905,11 @@ + + org.apache.maven.plugins + maven-dependency-plugin + 3.1.2 + org.apache.maven.plugins maven-jar-plugin @@ -1062,14 +1061,6 @@ org.apache.maven.plugins maven-dependency-plugin - - - - org.apache.maven.shared - maven-dependency-analyzer - 1.11.1 - - analyze @@ -1083,6 +1074,7 @@ org.apache.curator:curator-client:jar:* org.apache.hadoop:hadoop-common:jar:* org.apache.hadoop:hadoop-hdfs:*:* + org.apache.hadoop:hadoop-hdfs-client:*:* org.apache.hadoop:hadoop-mapreduce-client-core:jar:* org.apache.hadoop:hadoop-auth:jar:* org.apache.httpcomponents:httpcore:jar:* @@ -1266,7 +1258,7 @@ com.puppycrawl.tools checkstyle - 8.29 + 8.30 diff --git a/server/base/src/test/java/org/apache/accumulo/server/fs/PerTableVolumeChooserTest.java b/server/base/src/test/java/org/apache/accumulo/server/fs/PerTableVolumeChooserTest.java index eb1d9a6c0c3..518b5e0e930 100644 --- a/server/base/src/test/java/org/apache/accumulo/server/fs/PerTableVolumeChooserTest.java +++ b/server/base/src/test/java/org/apache/accumulo/server/fs/PerTableVolumeChooserTest.java @@ -24,7 +24,7 @@ import static org.easymock.EasyMock.replay; import static org.easymock.EasyMock.verify; import static org.junit.Assert.assertSame; -import static org.junit.Assert.fail; +import static org.junit.Assert.assertThrows; import org.apache.accumulo.core.data.TableId; import org.apache.accumulo.core.spi.common.ServiceEnvironment; @@ -33,9 +33,7 @@ import org.apache.accumulo.server.fs.VolumeChooserEnvironment.ChooserScope; import org.junit.After; import org.junit.Before; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; public class PerTableVolumeChooserTest { @@ -54,9 +52,6 @@ public static class MockChooser1 extends RandomVolumeChooser {} public static class MockChooser2 extends RandomVolumeChooser {} - @Rule - public ExpectedException thrown = ExpectedException.none(); - @Before public void before() { serviceEnv = createStrictMock(ServiceEnvironment.class); @@ -126,9 +121,7 @@ public void testTableScopeWithNoConfig() { .once(); replay(serviceEnv, tableConf, systemConf); - thrown.expect(VolumeChooserException.class); - getTableDelegate(); - fail("should not reach"); + assertThrows(VolumeChooserException.class, () -> getTableDelegate()); } @Test @@ -140,9 +133,7 @@ public void testTableScopeWithBadDelegate() throws Exception { VolumeChooser.class)).andThrow(new RuntimeException()); replay(serviceEnv, tableConf, systemConf); - thrown.expect(VolumeChooserException.class); - getTableDelegate(); - fail("should not reach"); + assertThrows(VolumeChooserException.class, () -> getTableDelegate()); } @Test @@ -179,9 +170,7 @@ public void testLoggerScopeWithNoConfig() { .once(); replay(serviceEnv, tableConf, systemConf); - thrown.expect(VolumeChooserException.class); - getDelegate(ChooserScope.LOGGER); - fail("should not reach"); + assertThrows(VolumeChooserException.class, () -> getDelegate(ChooserScope.LOGGER)); } @Test @@ -194,9 +183,7 @@ public void testLoggerScopeWithBadDelegate() throws Exception { .andThrow(new RuntimeException()); replay(serviceEnv, tableConf, systemConf); - thrown.expect(VolumeChooserException.class); - getDelegate(ChooserScope.LOGGER); - fail("should not reach"); + assertThrows(VolumeChooserException.class, () -> getDelegate(ChooserScope.LOGGER)); } @Test diff --git a/server/base/src/test/java/org/apache/accumulo/server/fs/PreferredVolumeChooserTest.java b/server/base/src/test/java/org/apache/accumulo/server/fs/PreferredVolumeChooserTest.java index 1167af910fe..c66c6bc6951 100644 --- a/server/base/src/test/java/org/apache/accumulo/server/fs/PreferredVolumeChooserTest.java +++ b/server/base/src/test/java/org/apache/accumulo/server/fs/PreferredVolumeChooserTest.java @@ -24,7 +24,7 @@ import static org.easymock.EasyMock.replay; import static org.easymock.EasyMock.verify; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; +import static org.junit.Assert.assertThrows; import java.util.Set; @@ -35,9 +35,7 @@ import org.apache.accumulo.server.fs.VolumeChooserEnvironment.ChooserScope; import org.junit.After; import org.junit.Before; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; public class PreferredVolumeChooserTest { @@ -54,9 +52,6 @@ private static final String getCustomPropertySuffix(ChooserScope scope) { private Configuration systemConf; private PreferredVolumeChooser chooser; - @Rule - public ExpectedException thrown = ExpectedException.none(); - @Before public void before() { serviceEnv = createStrictMock(ServiceEnvironment.class); @@ -118,9 +113,7 @@ public void testTableScopeWithNoConfig() { .once(); replay(serviceEnv, tableConf, systemConf); - thrown.expect(VolumeChooserException.class); - chooseForTable(); - fail("should not reach"); + assertThrows(VolumeChooserException.class, () -> chooseForTable()); } @Test @@ -128,9 +121,7 @@ public void testTableScopeWithEmptySet() { expect(tableConf.getTableCustom(TABLE_CUSTOM_SUFFIX)).andReturn(",").once(); replay(serviceEnv, tableConf, systemConf); - thrown.expect(VolumeChooserException.class); - chooseForTable(); - fail("should not reach"); + assertThrows(VolumeChooserException.class, () -> chooseForTable()); } @Test @@ -140,9 +131,7 @@ public void testTableScopeWithUnrecognizedVolumes() { .once(); replay(serviceEnv, tableConf, systemConf); - thrown.expect(VolumeChooserException.class); - chooseForTable(); - fail("should not reach"); + assertThrows(VolumeChooserException.class, () -> chooseForTable()); } @Test @@ -171,9 +160,7 @@ public void testLoggerScopeWithNoConfig() { .once(); replay(serviceEnv, tableConf, systemConf); - thrown.expect(VolumeChooserException.class); - choose(ChooserScope.LOGGER); - fail("should not reach"); + assertThrows(VolumeChooserException.class, () -> choose(ChooserScope.LOGGER)); } @Test @@ -182,9 +169,7 @@ public void testLoggerScopeWithEmptySet() { .once(); replay(serviceEnv, tableConf, systemConf); - thrown.expect(VolumeChooserException.class); - choose(ChooserScope.LOGGER); - fail("should not reach"); + assertThrows(VolumeChooserException.class, () -> choose(ChooserScope.LOGGER)); } @Test @@ -195,9 +180,7 @@ public void testLoggerScopeWithUnrecognizedVolumes() { .once(); replay(serviceEnv, tableConf, systemConf); - thrown.expect(VolumeChooserException.class); - choose(ChooserScope.LOGGER); - fail("should not reach"); + assertThrows(VolumeChooserException.class, () -> choose(ChooserScope.LOGGER)); } @Test diff --git a/server/base/src/test/java/org/apache/accumulo/server/fs/VolumeManagerImplTest.java b/server/base/src/test/java/org/apache/accumulo/server/fs/VolumeManagerImplTest.java index 1e1d084c674..c02714c3866 100644 --- a/server/base/src/test/java/org/apache/accumulo/server/fs/VolumeManagerImplTest.java +++ b/server/base/src/test/java/org/apache/accumulo/server/fs/VolumeManagerImplTest.java @@ -18,7 +18,7 @@ */ package org.apache.accumulo.server.fs; -import static org.junit.Assert.fail; +import static org.junit.Assert.assertThrows; import java.util.Arrays; import java.util.List; @@ -28,17 +28,12 @@ import org.apache.accumulo.core.conf.Property; import org.apache.accumulo.core.data.TableId; import org.apache.hadoop.conf.Configuration; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; public class VolumeManagerImplTest { private Configuration hadoopConf = new Configuration(); - @Rule - public ExpectedException thrown = ExpectedException.none(); - @Test public void invalidChooserConfigured() throws Exception { List volumes = Arrays.asList("file://one/", "file://two/", "file://three/"); @@ -47,20 +42,14 @@ public void invalidChooserConfigured() throws Exception { conf.set(Property.INSTANCE_VOLUMES, String.join(",", volumes)); conf.set(Property.GENERAL_VOLUME_CHOOSER, "org.apache.accumulo.server.fs.ChooserThatDoesntExist"); - thrown.expect(RuntimeException.class); - try (var vm = VolumeManagerImpl.get(conf, hadoopConf)) { - fail("shouldn't reach here " + vm); - } + assertThrows(RuntimeException.class, () -> VolumeManagerImpl.get(conf, hadoopConf)); } @Test public void noViewFS() throws Exception { ConfigurationCopy conf = new ConfigurationCopy(); conf.set(Property.INSTANCE_VOLUMES, "viewfs://dummy"); - thrown.expect(IllegalArgumentException.class); - try (var vm = VolumeManagerImpl.get(conf, hadoopConf)) { - fail("shouldn't reach here " + vm); - } + assertThrows(IllegalArgumentException.class, () -> VolumeManagerImpl.get(conf, hadoopConf)); } public static class WrongVolumeChooser implements VolumeChooser { @@ -86,12 +75,10 @@ public void chooseFromOptions() throws Exception { conf.set(INSTANCE_DFS_URI, volumes.iterator().next()); conf.set(Property.INSTANCE_VOLUMES, String.join(",", volumes)); conf.set(Property.GENERAL_VOLUME_CHOOSER, WrongVolumeChooser.class.getName()); - thrown.expect(RuntimeException.class); try (var vm = VolumeManagerImpl.get(conf, hadoopConf)) { VolumeChooserEnvironment chooserEnv = new VolumeChooserEnvironmentImpl(TableId.of("sometable"), null, null); - vm.choose(chooserEnv, volumes); - fail("shouldn't reach here"); + assertThrows(RuntimeException.class, () -> vm.choose(chooserEnv, volumes)); } } } diff --git a/server/tserver/src/test/java/org/apache/accumulo/tserver/InMemoryMapTest.java b/server/tserver/src/test/java/org/apache/accumulo/tserver/InMemoryMapTest.java index fd670ee0e8b..bb7bdcddb32 100644 --- a/server/tserver/src/test/java/org/apache/accumulo/tserver/InMemoryMapTest.java +++ b/server/tserver/src/test/java/org/apache/accumulo/tserver/InMemoryMapTest.java @@ -20,6 +20,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertThrows; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; @@ -65,7 +66,6 @@ import org.easymock.EasyMock; import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; import org.junit.rules.TemporaryFolder; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; @@ -96,9 +96,6 @@ public SamplerConfiguration getSamplerConfiguration() { } } - @Rule - public ExpectedException thrown = ExpectedException.none(); - public static ServerContext getServerContext() { Configuration hadoopConf = new Configuration(); ServerContext context = EasyMock.createMock(ServerContext.class); @@ -799,9 +796,9 @@ public void testDeferredSamplerCreation() throws Exception { iter.seek(new Range(), LocalityGroupUtil.EMPTY_CF_SET, false); assertEquals(expectedAll, readAll(iter)); - iter = imm.skvIterator(sampleConfig1); - thrown.expect(SampleNotPresentException.class); - iter.seek(new Range(), LocalityGroupUtil.EMPTY_CF_SET, false); + final MemoryIterator iter2 = imm.skvIterator(sampleConfig1); + assertThrows(SampleNotPresentException.class, + () -> iter2.seek(new Range(), LocalityGroupUtil.EMPTY_CF_SET, false)); } private TreeMap readAll(SortedKeyValueIterator iter) throws IOException { diff --git a/server/tserver/src/test/java/org/apache/accumulo/tserver/compaction/CompactionPlanTest.java b/server/tserver/src/test/java/org/apache/accumulo/tserver/compaction/CompactionPlanTest.java index 09619b26cba..4a7383ed283 100644 --- a/server/tserver/src/test/java/org/apache/accumulo/tserver/compaction/CompactionPlanTest.java +++ b/server/tserver/src/test/java/org/apache/accumulo/tserver/compaction/CompactionPlanTest.java @@ -18,18 +18,15 @@ */ package org.apache.accumulo.tserver.compaction; +import static org.junit.Assert.assertThrows; + import java.util.Set; import org.apache.accumulo.core.metadata.StoredTabletFile; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; public class CompactionPlanTest { - @Rule - public ExpectedException exception = ExpectedException.none(); - @Test public void testOverlappingInputAndDelete() { CompactionPlan cp1 = new CompactionPlan(); @@ -44,8 +41,7 @@ public void testOverlappingInputAndDelete() { Set allFiles = Set.of(fr1, fr2); - exception.expect(IllegalStateException.class); - cp1.validate(allFiles); + assertThrows(IllegalStateException.class, () -> cp1.validate(allFiles)); } @Test @@ -62,8 +58,7 @@ public void testInputNotInAllFiles() { Set allFiles = Set.of(fr1, fr2); - exception.expect(IllegalStateException.class); - cp1.validate(allFiles); + assertThrows(IllegalStateException.class, () -> cp1.validate(allFiles)); } @Test @@ -80,8 +75,7 @@ public void testDeleteNotInAllFiles() { Set allFiles = Set.of(fr1, fr2); - exception.expect(IllegalStateException.class); - cp1.validate(allFiles); + assertThrows(IllegalStateException.class, () -> cp1.validate(allFiles)); } } diff --git a/server/tserver/src/test/java/org/apache/accumulo/tserver/log/SortedLogRecoveryTest.java b/server/tserver/src/test/java/org/apache/accumulo/tserver/log/SortedLogRecoveryTest.java index b76f50b261a..ed7e60aeb24 100644 --- a/server/tserver/src/test/java/org/apache/accumulo/tserver/log/SortedLogRecoveryTest.java +++ b/server/tserver/src/test/java/org/apache/accumulo/tserver/log/SortedLogRecoveryTest.java @@ -24,6 +24,7 @@ import static org.apache.accumulo.tserver.logger.LogEvents.MUTATION; import static org.apache.accumulo.tserver.logger.LogEvents.OPEN; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThrows; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; @@ -57,7 +58,6 @@ import org.apache.hadoop.io.Text; import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; import org.junit.rules.TemporaryFolder; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; @@ -74,9 +74,6 @@ public class SortedLogRecoveryTest { public TemporaryFolder tempFolder = new TemporaryFolder(new File(System.getProperty("user.dir") + "/target")); - @Rule - public ExpectedException thrown = ExpectedException.none(); - static class KeyValue implements Comparable { public final LogFileKey key; public final LogFileValue value; @@ -874,9 +871,8 @@ public void testConsecutiveCompactionFinishEvents() throws IOException { Map logs = new TreeMap<>(); logs.put("entries1", entries1); - thrown.expect(IllegalStateException.class); - thrown.expectMessage("consecutive " + LogEvents.COMPACTION_FINISH.name()); - recover(logs, extent); + var e = assertThrows(IllegalStateException.class, () -> recover(logs, extent)); + assertTrue(e.getMessage().contains("consecutive " + LogEvents.COMPACTION_FINISH.name())); } @Test @@ -996,8 +992,7 @@ public void testFileWithoutOpen() throws IOException { Map logs = new TreeMap<>(); logs.put("entries1", entries1); - thrown.expect(IllegalStateException.class); - thrown.expectMessage("not " + LogEvents.OPEN); - recover(logs, extent); + var e = assertThrows(IllegalStateException.class, () -> recover(logs, extent)); + assertTrue(e.getMessage().contains("not " + LogEvents.OPEN)); } } diff --git a/start/src/main/java/org/apache/accumulo/start/classloader/vfs/AccumuloReloadingVFSClassLoader.java b/start/src/main/java/org/apache/accumulo/start/classloader/vfs/AccumuloReloadingVFSClassLoader.java index 0b61f2fad83..9e52bb2b48b 100644 --- a/start/src/main/java/org/apache/accumulo/start/classloader/vfs/AccumuloReloadingVFSClassLoader.java +++ b/start/src/main/java/org/apache/accumulo/start/classloader/vfs/AccumuloReloadingVFSClassLoader.java @@ -265,21 +265,21 @@ public void close() { @Override public void fileCreated(FileChangeEvent event) throws Exception { if (log.isDebugEnabled()) - log.debug("{} created, recreating classloader", event.getFile().getURL()); + log.debug("{} created, recreating classloader", event.getFileObject().getURL()); scheduleRefresh(); } @Override public void fileDeleted(FileChangeEvent event) throws Exception { if (log.isDebugEnabled()) - log.debug("{} deleted, recreating classloader", event.getFile().getURL()); + log.debug("{} deleted, recreating classloader", event.getFileObject().getURL()); scheduleRefresh(); } @Override public void fileChanged(FileChangeEvent event) throws Exception { if (log.isDebugEnabled()) - log.debug("{} changed, recreating classloader", event.getFile().getURL()); + log.debug("{} changed, recreating classloader", event.getFileObject().getURL()); scheduleRefresh(); } diff --git a/test/pom.xml b/test/pom.xml index eff48141ae0..49232043b0f 100644 --- a/test/pom.xml +++ b/test/pom.xml @@ -174,10 +174,6 @@ org.easymock easymock - - org.hamcrest - hamcrest - org.slf4j slf4j-api diff --git a/test/src/main/java/org/apache/accumulo/test/functional/ClassLoaderIT.java b/test/src/main/java/org/apache/accumulo/test/functional/ClassLoaderIT.java index bac838bc101..21b5fdabca5 100644 --- a/test/src/main/java/org/apache/accumulo/test/functional/ClassLoaderIT.java +++ b/test/src/main/java/org/apache/accumulo/test/functional/ClassLoaderIT.java @@ -48,7 +48,6 @@ import org.apache.hadoop.fs.FSDataOutputStream; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; -import org.hamcrest.CoreMatchers; import org.junit.Assume; import org.junit.Before; import org.junit.Test; @@ -68,7 +67,7 @@ protected int defaultTimeoutSeconds() { @Before public void checkCluster() { - Assume.assumeThat(getClusterType(), CoreMatchers.is(ClusterType.MINI)); + Assume.assumeTrue(getClusterType() == ClusterType.MINI); MiniAccumuloClusterImpl mac = (MiniAccumuloClusterImpl) getCluster(); rootPath = mac.getConfig().getDir().getAbsolutePath(); } diff --git a/test/src/main/java/org/apache/accumulo/test/functional/ScannerContextIT.java b/test/src/main/java/org/apache/accumulo/test/functional/ScannerContextIT.java index 017f7435cf2..fb4152904c0 100644 --- a/test/src/main/java/org/apache/accumulo/test/functional/ScannerContextIT.java +++ b/test/src/main/java/org/apache/accumulo/test/functional/ScannerContextIT.java @@ -45,7 +45,6 @@ import org.apache.accumulo.miniclusterImpl.MiniAccumuloClusterImpl; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; -import org.hamcrest.CoreMatchers; import org.junit.Assume; import org.junit.Before; import org.junit.Test; @@ -68,7 +67,7 @@ protected int defaultTimeoutSeconds() { @Before public void checkCluster() throws Exception { - Assume.assumeThat(getClusterType(), CoreMatchers.is(ClusterType.MINI)); + Assume.assumeTrue(getClusterType() == ClusterType.MINI); MiniAccumuloClusterImpl.class.cast(getCluster()); fs = FileSystem.get(cluster.getServerContext().getHadoopConf()); } diff --git a/test/src/main/java/org/apache/accumulo/test/functional/TableIT.java b/test/src/main/java/org/apache/accumulo/test/functional/TableIT.java index 91f9617116f..3fd04371880 100644 --- a/test/src/main/java/org/apache/accumulo/test/functional/TableIT.java +++ b/test/src/main/java/org/apache/accumulo/test/functional/TableIT.java @@ -42,7 +42,6 @@ import org.apache.accumulo.test.categories.MiniClusterOnlyTests; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; -import org.hamcrest.CoreMatchers; import org.junit.Assume; import org.junit.Test; import org.junit.experimental.categories.Category; @@ -59,7 +58,7 @@ protected int defaultTimeoutSeconds() { @Test public void test() throws Exception { - Assume.assumeThat(getClusterType(), CoreMatchers.is(ClusterType.MINI)); + Assume.assumeTrue(getClusterType() == ClusterType.MINI); AccumuloCluster cluster = getCluster(); MiniAccumuloClusterImpl mac = (MiniAccumuloClusterImpl) cluster; diff --git a/test/src/main/java/org/apache/accumulo/test/rpc/ThriftBehaviorIT.java b/test/src/main/java/org/apache/accumulo/test/rpc/ThriftBehaviorIT.java index 9510c48b136..2515aa5c7f5 100644 --- a/test/src/main/java/org/apache/accumulo/test/rpc/ThriftBehaviorIT.java +++ b/test/src/main/java/org/apache/accumulo/test/rpc/ThriftBehaviorIT.java @@ -19,6 +19,8 @@ package org.apache.accumulo.test.rpc; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThrows; +import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import java.util.concurrent.TimeUnit; @@ -27,13 +29,11 @@ import org.apache.accumulo.test.rpc.thrift.SimpleThriftService; import org.apache.thrift.TApplicationException; import org.apache.thrift.TException; -import org.hamcrest.core.IsInstanceOf; import org.junit.After; import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.experimental.categories.Category; -import org.junit.rules.ExpectedException; import org.junit.rules.TestName; import org.junit.rules.Timeout; @@ -46,9 +46,6 @@ public class ThriftBehaviorIT { @Rule public TestName testName = new TestName(); - @Rule - public ExpectedException exception = ExpectedException.none(); - private SimpleThriftService.Client client; private SimpleThriftServiceHandler handler; private SimpleThriftServiceRunner serviceRunner; @@ -85,9 +82,8 @@ public void shutdownServer() { @Test public void echoFailHandler() throws TException { - exception.expect(TException.class); - exception.expectCause(IsInstanceOf.instanceOf(UnsupportedOperationException.class)); - handler.echoFail(KITTY_MSG); + var e = assertThrows(TException.class, () -> handler.echoFail(KITTY_MSG)); + assertTrue(e.getCause() instanceof UnsupportedOperationException); } @Test @@ -104,8 +100,7 @@ public void echoFail() throws TException { @Test public void echoRuntimeFailHandler() { - exception.expect(UnsupportedOperationException.class); - handler.echoRuntimeFail(KITTY_MSG); + assertThrows(UnsupportedOperationException.class, () -> handler.echoRuntimeFail(KITTY_MSG)); } @Test @@ -132,9 +127,8 @@ public void echoPass() throws TException { @Test public void onewayFailHandler() throws TException { - exception.expect(TException.class); - exception.expectCause(IsInstanceOf.instanceOf(UnsupportedOperationException.class)); - handler.onewayFail(KITTY_MSG); + var e = assertThrows(TException.class, () -> handler.onewayFail(KITTY_MSG)); + assertTrue(e.getCause() instanceof UnsupportedOperationException); } @Test @@ -146,8 +140,7 @@ public void onewayFail() throws TException { @Test public void onewayRuntimeFailHandler() { - exception.expect(UnsupportedOperationException.class); - handler.onewayRuntimeFail(KITTY_MSG); + assertThrows(UnsupportedOperationException.class, () -> handler.onewayRuntimeFail(KITTY_MSG)); } @Test From 9560efe2d2dbe9cb04b8e152253609fbf16daebe Mon Sep 17 00:00:00 2001 From: Christopher Tubbs Date: Fri, 13 Mar 2020 03:16:24 -0400 Subject: [PATCH 2/4] Enforce dep convergence and fix vfs2 transitive dep Enforce dependency convergence to versions specified in the dependencyManagement section when transitive dependencies from different direct dependencies conflict. Fix broken tests due to bad runtime class path for hadoop client jars by excluding hadoop-hdfs-client from transitive dependencies via commons-vfs2. The dependency is already included in the shaded hadoop-client-runtime and we should not have the non-shaded version on the class path. --- pom.xml | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/pom.xml b/pom.xml index 4e94155fdac..2e4580c4b3b 100644 --- a/pom.xml +++ b/pom.xml @@ -213,6 +213,11 @@ auto-service 1.0-rc6 + + com.google.code.findbugs + jsr305 + 3.0.2 + com.google.code.gson gson @@ -269,6 +274,11 @@ commons-logging 1.2 + + jakarta.annotation + jakarta.annotation-api + 1.3.5 + javax.activation javax.activation-api @@ -429,6 +439,12 @@ org.apache.commons commons-vfs2 2.6.0 + + + org.apache.hadoop + hadoop-hdfs-client + + org.apache.curator @@ -471,11 +487,6 @@ hadoop-distcp ${hadoop.version} - - org.apache.hadoop - hadoop-hdfs-client - ${hadoop.version} - org.apache.hadoop hadoop-minicluster @@ -555,6 +566,11 @@ bcprov-jdk15on ${bouncycastle.version} + + org.checkerframework + checker-qual + 3.1.0 + org.easymock easymock @@ -740,6 +756,11 @@ jboss-logging 3.4.1.Final + + org.objenesis + objenesis + 3.1 + org.powermock powermock-api-easymock @@ -1074,7 +1095,6 @@ org.apache.curator:curator-client:jar:* org.apache.hadoop:hadoop-common:jar:* org.apache.hadoop:hadoop-hdfs:*:* - org.apache.hadoop:hadoop-hdfs-client:*:* org.apache.hadoop:hadoop-mapreduce-client-core:jar:* org.apache.hadoop:hadoop-auth:jar:* org.apache.httpcomponents:httpcore:jar:* @@ -1161,6 +1181,7 @@ [11,) + From a96aec4899a0b7a3ad43af22e0b1d1c82dacd68e Mon Sep 17 00:00:00 2001 From: Christopher Tubbs Date: Fri, 13 Mar 2020 12:08:54 -0400 Subject: [PATCH 3/4] Fix vfs test due to change in behavior for class reloading --- .../vfs/AccumuloReloadingVFSClassLoaderTest.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/start/src/test/java/org/apache/accumulo/start/classloader/vfs/AccumuloReloadingVFSClassLoaderTest.java b/start/src/test/java/org/apache/accumulo/start/classloader/vfs/AccumuloReloadingVFSClassLoaderTest.java index aaa33f719be..4c434b59fe5 100644 --- a/start/src/test/java/org/apache/accumulo/start/classloader/vfs/AccumuloReloadingVFSClassLoaderTest.java +++ b/start/src/test/java/org/apache/accumulo/start/classloader/vfs/AccumuloReloadingVFSClassLoaderTest.java @@ -20,8 +20,8 @@ import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNotSame; import static org.junit.Assert.assertTrue; import java.io.File; @@ -171,9 +171,13 @@ public void testReloadingWithLongerTimeout() throws Exception { Object o2 = clazz2.getDeclaredConstructor().newInstance(); assertEquals("Hello World!", o2.toString()); - // This is true because they are loaded by the same classloader due to the new retry - assertTrue(clazz1.equals(clazz2)); - assertFalse(o1.equals(o2)); + // This is false because even though it's the same class, it's loaded from a different jar + // this is a change in behavior from previous versions of vfs2 where it would load the same + // class from different jars as though it was from the first jar + assertNotEquals(clazz1, clazz2); + assertNotSame(o1, o2); + assertEquals(clazz1.getName(), clazz2.getName()); + assertEquals(o1.toString(), o2.toString()); arvcl.close(); } From cdce04d9aec24360ffade5105ced228d25231165 Mon Sep 17 00:00:00 2001 From: Christopher Tubbs Date: Fri, 13 Mar 2020 15:24:08 -0400 Subject: [PATCH 4/4] Fix spotbugs and improve CryptoTest --- .../accumulo/core/crypto/CryptoTest.java | 27 +++++++++++-------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/core/src/test/java/org/apache/accumulo/core/crypto/CryptoTest.java b/core/src/test/java/org/apache/accumulo/core/crypto/CryptoTest.java index 4cca2d74ad9..cec098630b2 100644 --- a/core/src/test/java/org/apache/accumulo/core/crypto/CryptoTest.java +++ b/core/src/test/java/org/apache/accumulo/core/crypto/CryptoTest.java @@ -279,22 +279,27 @@ public void testMissingConfigProperties() throws ReflectiveOperationException { () -> cs.init(aconf.getAllPropertiesWithPrefix(Property.TABLE_PREFIX))); } - @SuppressFBWarnings(value = "CIPHER_INTEGRITY", justification = "CBC is being tested") @Test public void testAESKeyUtilsGeneratesKey() throws NoSuchAlgorithmException, NoSuchProviderException, NoSuchPaddingException, InvalidKeyException { SecureRandom sr = SecureRandom.getInstance("SHA1PRNG", "SUN"); - java.security.Key key; - key = AESKeyUtils.generateKey(sr, 16); - Cipher.getInstance("AES/CBC/NoPadding").init(Cipher.ENCRYPT_MODE, key); - - key = AESKeyUtils.generateKey(sr, 24); - key = AESKeyUtils.generateKey(sr, 32); - key = AESKeyUtils.generateKey(sr, 11); + // verify valid key sizes (corresponds to 128, 192, and 256 bits) + for (int i : new int[] {16, 24, 32}) { + verifyKeySizeForCBC(sr, i); + } + // verify invalid key sizes + for (int i : new int[] {1, 2, 8, 11, 15, 64, 128}) { + assertThrows(InvalidKeyException.class, () -> verifyKeySizeForCBC(sr, i)); + } + } - final java.security.Key key2 = key; - assertThrows(InvalidKeyException.class, - () -> Cipher.getInstance("AES/CBC/NoPadding").init(Cipher.ENCRYPT_MODE, key2)); + // this has to be a separate method, for spotbugs, because spotbugs annotation doesn't seem to + // apply to the lambda inline + @SuppressFBWarnings(value = "CIPHER_INTEGRITY", justification = "CBC is being tested") + private void verifyKeySizeForCBC(SecureRandom sr, int sizeInBytes) + throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException { + java.security.Key key = AESKeyUtils.generateKey(sr, sizeInBytes); + Cipher.getInstance("AES/CBC/NoPadding").init(Cipher.ENCRYPT_MODE, key); } @Test