This is an automated email from the ASF dual-hosted git repository. ctubbsii pushed a commit to branch 1.10 in repository https://gitbox.apache.org/repos/asf/accumulo.git
The following commit(s) were added to refs/heads/1.10 by this push: new 7eda641 Minor pre-release cleanup 7eda641 is described below commit 7eda64176f4f8ed44efdbc9b6e1b6b3315024128 Author: Christopher Tubbs <ctubb...@apache.org> AuthorDate: Tue Feb 8 02:09:02 2022 -0500 Minor pre-release cleanup * Bump some plugins to improve build quality * Fix redundant null check compiler warnings seen in Eclipse * Suppress unimportant spotbugs fings for single use Random * Bump bouncycastle, jetty, reload4j, gson, and jcommander * Bump junit, powermock, easymock --- .../core/client/impl/TabletServerBatchWriter.java | 14 +++-- .../core/file/rfile/VisMetricsGatherer.java | 4 +- .../core/metadata/MetadataLocationObtainer.java | 17 ++---- .../core/metadata/TableMetadataServicer.java | 5 +- core/src/main/spotbugs/exclude-filter.xml | 4 ++ .../simple/src/main/spotbugs/exclude-filter.xml | 4 ++ .../apache/accumulo/fate/zookeeper/ZooLock.java | 2 +- .../iteratortest/testcases/YieldingTestCase.java | 5 -- pom.xml | 62 ++++++++++++---------- .../accumulo/server/util/SendLogToChainsaw.java | 9 +--- server/base/src/main/spotbugs/exclude-filter.xml | 4 ++ .../tserver/src/main/spotbugs/exclude-filter.xml | 4 ++ .../main/java/org/apache/accumulo/shell/Shell.java | 3 +- .../accumulo/test/BadDeleteMarkersCreatedIT.java | 1 - .../accumulo/test/functional/KerberosProxyIT.java | 52 +++++++----------- .../apache/accumulo/test/randomwalk/Module.java | 4 +- test/src/main/spotbugs/exclude-filter.xml | 4 ++ 17 files changed, 87 insertions(+), 111 deletions(-) diff --git a/core/src/main/java/org/apache/accumulo/core/client/impl/TabletServerBatchWriter.java b/core/src/main/java/org/apache/accumulo/core/client/impl/TabletServerBatchWriter.java index 77850c5..7cf4663 100644 --- a/core/src/main/java/org/apache/accumulo/core/client/impl/TabletServerBatchWriter.java +++ b/core/src/main/java/org/apache/accumulo/core/client/impl/TabletServerBatchWriter.java @@ -758,14 +758,12 @@ public class TabletServerBatchWriter { @Override public void run() { - if (null != mutationsToSend) { - try { - log.trace("{} - binning {} mutations", Thread.currentThread().getName(), - mutationsToSend.size()); - addMutations(mutationsToSend); - } catch (Exception e) { - updateUnknownErrors("Error processing mutation set", e); - } + try { + log.trace("{} - binning {} mutations", Thread.currentThread().getName(), + mutationsToSend.size()); + addMutations(mutationsToSend); + } catch (Exception e) { + updateUnknownErrors("Error processing mutation set", e); } } })); diff --git a/core/src/main/java/org/apache/accumulo/core/file/rfile/VisMetricsGatherer.java b/core/src/main/java/org/apache/accumulo/core/file/rfile/VisMetricsGatherer.java index 17aa0b6..29d4306 100644 --- a/core/src/main/java/org/apache/accumulo/core/file/rfile/VisMetricsGatherer.java +++ b/core/src/main/java/org/apache/accumulo/core/file/rfile/VisMetricsGatherer.java @@ -75,9 +75,7 @@ public class VisMetricsGatherer ByteSequence cf = new ArrayByteSequence(oneCF.toString()); for (Entry<String,ArrayList<ByteSequence>> entry : localityGroupCF.entrySet()) { if (entry.getValue().contains(cf)) { - if (entry.getKey() == null) - name = null; - else + if (entry.getKey() != null) name = entry.getKey().toString(); break; } diff --git a/core/src/main/java/org/apache/accumulo/core/metadata/MetadataLocationObtainer.java b/core/src/main/java/org/apache/accumulo/core/metadata/MetadataLocationObtainer.java index 0be5f93..b693ac1 100644 --- a/core/src/main/java/org/apache/accumulo/core/metadata/MetadataLocationObtainer.java +++ b/core/src/main/java/org/apache/accumulo/core/metadata/MetadataLocationObtainer.java @@ -220,12 +220,8 @@ public class MetadataLocationObtainer implements TabletLocationObtainer { } public static TabletLocations getMetadataLocationEntries(SortedMap<Key,Value> entries) { - Key key; - Value val; Text location = null; Text session = null; - Value prevRow = null; - KeyExtent ke; List<TabletLocation> results = new ArrayList<>(); ArrayList<KeyExtent> locationless = new ArrayList<>(); @@ -237,11 +233,10 @@ public class MetadataLocationObtainer implements TabletLocationObtainer { Text colq = new Text(); for (Entry<Key,Value> entry : entries.entrySet()) { - key = entry.getKey(); - val = entry.getValue(); + Key key = entry.getKey(); + Value val = entry.getValue(); if (key.compareRow(lastRowFromKey) != 0) { - prevRow = null; location = null; session = null; key.getRow(lastRowFromKey); @@ -259,18 +254,14 @@ public class MetadataLocationObtainer implements TabletLocationObtainer { location = new Text(val.toString()); session = new Text(colq); } else if (TabletsSection.TabletColumnFamily.PREV_ROW_COLUMN.equals(colf, colq)) { - prevRow = new Value(val); - } - - if (prevRow != null) { - ke = new KeyExtent(key.getRow(), prevRow); + Value prevRow = new Value(val); + KeyExtent ke = new KeyExtent(key.getRow(), prevRow); if (location != null) results.add(new TabletLocation(ke, location.toString(), session.toString())); else locationless.add(ke); location = null; - prevRow = null; } } diff --git a/core/src/main/java/org/apache/accumulo/core/metadata/TableMetadataServicer.java b/core/src/main/java/org/apache/accumulo/core/metadata/TableMetadataServicer.java index 7b12e5a..f29ffe2 100644 --- a/core/src/main/java/org/apache/accumulo/core/metadata/TableMetadataServicer.java +++ b/core/src/main/java/org/apache/accumulo/core/metadata/TableMetadataServicer.java @@ -74,14 +74,12 @@ abstract class TableMetadataServicer extends MetadataServicer { Text colf = new Text(); Text colq = new Text(); - KeyExtent currentKeyExtent = null; String location = null; Text row = null; // acquire this table's tablets from the metadata table which services it for (Entry<Key,Value> entry : scanner) { if (row != null) { if (!row.equals(entry.getKey().getRow())) { - currentKeyExtent = null; location = null; row = entry.getKey().getRow(); } @@ -93,9 +91,8 @@ abstract class TableMetadataServicer extends MetadataServicer { colq = entry.getKey().getColumnQualifier(colq); if (TabletsSection.TabletColumnFamily.PREV_ROW_COLUMN.equals(colf, colq)) { - currentKeyExtent = new KeyExtent(entry.getKey().getRow(), entry.getValue()); + KeyExtent currentKeyExtent = new KeyExtent(entry.getKey().getRow(), entry.getValue()); tablets.put(currentKeyExtent, location); - currentKeyExtent = null; location = null; } else if (colf.equals(TabletsSection.CurrentLocationColumnFamily.NAME)) { location = entry.getValue().toString(); diff --git a/core/src/main/spotbugs/exclude-filter.xml b/core/src/main/spotbugs/exclude-filter.xml index f0ccc5b..e88d64a 100644 --- a/core/src/main/spotbugs/exclude-filter.xml +++ b/core/src/main/spotbugs/exclude-filter.xml @@ -114,4 +114,8 @@ <!-- More convenient to ignore these everywhere, because it's very common and unimportant --> <Bug pattern="JUA_DONT_ASSERT_INSTANCEOF_IN_TESTS" /> </Match> + <Match> + <!-- More convenient to ignore these everywhere, because it's very common and unimportant --> + <Bug pattern="DMI_RANDOM_USED_ONLY_ONCE" /> + </Match> </FindBugsFilter> diff --git a/examples/simple/src/main/spotbugs/exclude-filter.xml b/examples/simple/src/main/spotbugs/exclude-filter.xml index 1b68b74..6d171e4 100644 --- a/examples/simple/src/main/spotbugs/exclude-filter.xml +++ b/examples/simple/src/main/spotbugs/exclude-filter.xml @@ -25,4 +25,8 @@ <!-- https://github.com/spotbugs/spotbugs/issues/756 --> <Bug pattern="RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE" /> </Match> + <Match> + <!-- More convenient to ignore these everywhere, because it's very common and unimportant --> + <Bug pattern="DMI_RANDOM_USED_ONLY_ONCE" /> + </Match> </FindBugsFilter> diff --git a/fate/src/main/java/org/apache/accumulo/fate/zookeeper/ZooLock.java b/fate/src/main/java/org/apache/accumulo/fate/zookeeper/ZooLock.java index cba6cf4..9fb2215 100644 --- a/fate/src/main/java/org/apache/accumulo/fate/zookeeper/ZooLock.java +++ b/fate/src/main/java/org/apache/accumulo/fate/zookeeper/ZooLock.java @@ -401,7 +401,7 @@ public class ZooLock implements Watcher { if (lock != null || asyncLock != null) { lockWatcher.unableToMonitorLockNode(ex); log.error( - "Error resetting watch on ZooLock " + lock == null ? asyncLock : lock + " " + event, + "Error resetting watch on ZooLock " + (lock == null ? asyncLock : lock) + " " + event, ex); } } diff --git a/iterator-test-harness/src/main/java/org/apache/accumulo/iteratortest/testcases/YieldingTestCase.java b/iterator-test-harness/src/main/java/org/apache/accumulo/iteratortest/testcases/YieldingTestCase.java index 392770d..a314c3c 100644 --- a/iterator-test-harness/src/main/java/org/apache/accumulo/iteratortest/testcases/YieldingTestCase.java +++ b/iterator-test-harness/src/main/java/org/apache/accumulo/iteratortest/testcases/YieldingTestCase.java @@ -61,7 +61,6 @@ public class YieldingTestCase extends OutputVerifyingTestCase { TreeMap<Key,Value> consume(IteratorTestInput testInput, SortedKeyValueIterator<Key,Value> skvi, YieldCallback<Key> yield) throws IOException { TreeMap<Key,Value> data = new TreeMap<>(); - Key lastKey = null; while (yield.hasYielded() || skvi.hasTop()) { if (yield.hasYielded()) { Range r = testInput.getRange(); @@ -74,10 +73,6 @@ public class YieldingTestCase extends OutputVerifyingTestCase { throw new IOException( "Underlying iterator reports having a top, but has yielded: " + yieldPosition); } - if (lastKey != null && yieldPosition.compareTo(lastKey) <= 0) { - throw new IOException( - "Underlying iterator yielded at a position that is not past the last key returned"); - } skvi.seek(new Range(yieldPosition, false, r.getEndKey(), r.isEndKeyInclusive()), testInput.getFamilies(), testInput.isInclusive()); } else { diff --git a/pom.xml b/pom.xml index 702d91a..209fd58 100644 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ <parent> <groupId>org.apache</groupId> <artifactId>apache</artifactId> - <version>23</version> + <version>24</version> </parent> <groupId>org.apache.accumulo</groupId> <artifactId>accumulo-project</artifactId> @@ -116,11 +116,13 @@ <!-- used for filtering the java source with the current version --> <accumulo.release.version>${project.version}</accumulo.release.version> <!-- bouncycastle version for test dependencies --> - <bouncycastle.version>1.66</bouncycastle.version> + <bouncycastle.version>1.70</bouncycastle.version> <!-- Curator version --> <curator.version>2.11.0</curator.version> <!-- relative path for Eclipse format; should override in child modules if necessary --> <eclipseFormatterStyle>${project.parent.basedir}/contrib/Eclipse-Accumulo-Codestyle.xml</eclipseFormatterStyle> + <!-- avoid error shutting down built-in ForkJoinPool.commonPool() during exec:java tasks --> + <exec.cleanupDaemonThreads>false</exec.cleanupDaemonThreads> <failsafe.excludedGroups /> <failsafe.forkCount>1</failsafe.forkCount> <failsafe.groups /> @@ -131,14 +133,16 @@ <htrace.version>3.1.0-incubating</htrace.version> <it.failIfNoSpecifiedTests>false</it.failIfNoSpecifiedTests> <!-- jetty 9.2 is the last version to support jdk less than 1.8 --> - <jetty.version>9.2.26.v20180806</jetty.version> + <jetty.version>9.2.30.v20200428</jetty.version> <maven.compiler.release>8</maven.compiler.release> <maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.target>1.8</maven.compiler.target> <maven.plugin-version>3.5.0</maven.plugin-version> <!-- surefire/failsafe plugin option --> <maven.test.redirectTestOutputToFile>true</maven.test.redirectTestOutputToFile> - <powermock.version>2.0.7</powermock.version> + <minimalJavaBuildVersion>11</minimalJavaBuildVersion> + <minimalMavenBuildVersion>3.5.0</minimalMavenBuildVersion> + <powermock.version>2.0.9</powermock.version> <!-- timestamp for reproducible outputs, updated on release by the release plugin --> <project.build.outputTimestamp>2020-12-17T22:06:50Z</project.build.outputTimestamp> <rat.consoleOutput>true</rat.consoleOutput> @@ -150,7 +154,8 @@ <surefire.failIfNoSpecifiedTests>false</surefire.failIfNoSpecifiedTests> <surefire.forkCount>1C</surefire.forkCount> <surefire.groups /> - <surefire.version>3.0.0-M3</surefire.version> + <!-- 3.0.0-M5 causes RowHashIT.test and ShellServerIT.scansWithClassLoaderContext to fail --> + <surefire.version>3.0.0-M4</surefire.version> <!-- Thrift version --> <thrift.version>0.9.3-1</thrift.version> <!-- ZooKeeper version --> @@ -161,12 +166,12 @@ <dependency> <groupId>ch.qos.reload4j</groupId> <artifactId>reload4j</artifactId> - <version>1.2.18.4</version> + <version>1.2.18.5</version> </dependency> <dependency> <groupId>com.beust</groupId> <artifactId>jcommander</artifactId> - <version>1.78</version> + <version>1.82</version> </dependency> <dependency> <groupId>com.google.auto.service</groupId> @@ -177,7 +182,7 @@ <dependency> <groupId>com.google.code.gson</groupId> <artifactId>gson</artifactId> - <version>2.8.6</version> + <version>2.8.9</version> </dependency> <dependency> <groupId>com.google.guava</groupId> @@ -243,7 +248,7 @@ <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> - <version>4.13.1</version> + <version>4.13.2</version> </dependency> <dependency> <groupId>org.apache.accumulo</groupId> @@ -524,7 +529,7 @@ <dependency> <groupId>org.easymock</groupId> <artifactId>easymock</artifactId> - <version>4.0.2</version> + <version>4.3</version> </dependency> <dependency> <groupId>org.eclipse.jetty</groupId> @@ -625,7 +630,7 @@ <plugin> <groupId>com.github.spotbugs</groupId> <artifactId>spotbugs-maven-plugin</artifactId> - <version>4.2.0</version> + <version>4.4.2.2</version> <configuration> <xmlOutput>true</xmlOutput> <effort>Max</effort> @@ -648,15 +653,17 @@ <plugin> <groupId>com.github.ekryd.sortpom</groupId> <artifactId>sortpom-maven-plugin</artifactId> - <version>2.13.1</version> + <version>3.0.0</version> <configuration> - <predefinedSortOrder>recommended_2008_06</predefinedSortOrder> <createBackupFile>false</createBackupFile> - <lineSeparator>\n</lineSeparator> <expandEmptyElements>false</expandEmptyElements> + <keepBlankLines>false</keepBlankLines> + <lineSeparator>\n</lineSeparator> <nrOfIndentSpace>2</nrOfIndentSpace> + <predefinedSortOrder>recommended_2008_06</predefinedSortOrder> <sortDependencies>scope,groupId,artifactId</sortDependencies> <sortProperties>true</sortProperties> + <spaceBeforeCloseEmptyElement>true</spaceBeforeCloseEmptyElement> <verifyFail>Stop</verifyFail> </configuration> </plugin> @@ -713,7 +720,6 @@ <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-javadoc-plugin</artifactId> - <version>3.2.0</version> <configuration> <quiet>true</quiet> <additionalJOption>-J-Xmx512m</additionalJOption> @@ -771,12 +777,12 @@ <plugin> <groupId>org.asciidoctor</groupId> <artifactId>asciidoctor-maven-plugin</artifactId> - <version>2.1.0</version> + <version>2.2.2</version> </plugin> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>build-helper-maven-plugin</artifactId> - <version>3.2.0</version> + <version>3.3.0</version> </plugin> <plugin> <groupId>org.codehaus.mojo</groupId> @@ -791,23 +797,24 @@ <plugin> <groupId>net.revelc.code.formatter</groupId> <artifactId>formatter-maven-plugin</artifactId> - <version>2.15.0</version> + <version>2.17.1</version> <configuration> - <configFile>${eclipseFormatterStyle}</configFile> <compilerCompliance>${maven.compiler.source}</compilerCompliance> <compilerSource>${maven.compiler.source}</compilerSource> <compilerTargetPlatform>${maven.compiler.target}</compilerTargetPlatform> + <configFile>${eclipseFormatterStyle}</configFile> <excludes> <exclude>**/thrift/*.java</exclude> <exclude>**/proto/*.java</exclude> </excludes> <lineEnding>LF</lineEnding> <overrideConfigCompilerVersion>true</overrideConfigCompilerVersion> - <skipJsFormatting>true</skipJsFormatting> + <removeTrailingWhitespace>true</removeTrailingWhitespace> + <skipCssFormatting>true</skipCssFormatting> <skipHtmlFormatting>true</skipHtmlFormatting> - <skipXmlFormatting>true</skipXmlFormatting> + <skipJsFormatting>true</skipJsFormatting> <skipJsonFormatting>true</skipJsonFormatting> - <skipCssFormatting>true</skipCssFormatting> + <skipXmlFormatting>true</skipXmlFormatting> </configuration> </plugin> <plugin> @@ -830,7 +837,7 @@ <plugin> <groupId>net.revelc.code</groupId> <artifactId>impsort-maven-plugin</artifactId> - <version>1.6.1</version> + <version>1.6.2</version> <configuration> <removeUnused>true</removeUnused> <groups>java.,javax.,org.,com.</groups> @@ -879,19 +886,16 @@ <executions> <execution> <!-- must be same id as in the apache parent pom, to override the version --> - <id>enforce-maven-version</id> + <id>enforce-java-version</id> <goals> <goal>enforce</goal> </goals> <phase>validate</phase> <configuration> <rules> - <requireMavenVersion> - <version>[3.5.0,)</version> - </requireMavenVersion> <requireJavaVersion> <!-- 15 dropped support for UseConcMarkSweepGC flag that Accumulo 1.x uses --> - <version>[11,15)</version> + <version>[${minimalJavaBuildVersion},15)</version> </requireJavaVersion> </rules> </configuration> @@ -1027,7 +1031,7 @@ <dependency> <groupId>com.puppycrawl.tools</groupId> <artifactId>checkstyle</artifactId> - <version>8.42</version> + <version>9.3</version> </dependency> </dependencies> <executions> diff --git a/server/base/src/main/java/org/apache/accumulo/server/util/SendLogToChainsaw.java b/server/base/src/main/java/org/apache/accumulo/server/util/SendLogToChainsaw.java index b65da30..c628fea 100644 --- a/server/base/src/main/java/org/apache/accumulo/server/util/SendLogToChainsaw.java +++ b/server/base/src/main/java/org/apache/accumulo/server/util/SendLogToChainsaw.java @@ -119,7 +119,6 @@ public class SendLogToChainsaw extends XMLLayout { public void processLogFiles() throws IOException { String line = null; String out = null; - BufferedReader reader = null; try { for (File log : logFiles) { // Parse the server type and name from the log file name @@ -131,9 +130,7 @@ public class SendLogToChainsaw extends XMLLayout { System.out.println("Unable to find file: " + log.getAbsolutePath()); throw e; } - reader = new BufferedReader(new InputStreamReader(fis, UTF_8)); - - try { + try (BufferedReader reader = new BufferedReader(new InputStreamReader(fis, UTF_8))) { line = reader.readLine(); while (null != line) { out = convertLine(line, threadName); @@ -148,10 +145,6 @@ public class SendLogToChainsaw extends XMLLayout { } catch (IOException e) { System.out.println("Error processing line: " + line + ". Output was " + out); throw e; - } finally { - if (reader != null) { - reader.close(); - } } } } finally { diff --git a/server/base/src/main/spotbugs/exclude-filter.xml b/server/base/src/main/spotbugs/exclude-filter.xml index 04b8fe8..bc23205 100644 --- a/server/base/src/main/spotbugs/exclude-filter.xml +++ b/server/base/src/main/spotbugs/exclude-filter.xml @@ -40,4 +40,8 @@ <!-- https://github.com/spotbugs/spotbugs/issues/756 --> <Bug pattern="RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE" /> </Match> + <Match> + <!-- More convenient to ignore these everywhere, because it's very common and unimportant --> + <Bug pattern="DMI_RANDOM_USED_ONLY_ONCE" /> + </Match> </FindBugsFilter> diff --git a/server/tserver/src/main/spotbugs/exclude-filter.xml b/server/tserver/src/main/spotbugs/exclude-filter.xml index 2c8a66d..3146edc 100644 --- a/server/tserver/src/main/spotbugs/exclude-filter.xml +++ b/server/tserver/src/main/spotbugs/exclude-filter.xml @@ -32,4 +32,8 @@ <!-- https://github.com/spotbugs/spotbugs/issues/756 --> <Bug pattern="RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE" /> </Match> + <Match> + <!-- More convenient to ignore these everywhere, because it's very common and unimportant --> + <Bug pattern="DMI_RANDOM_USED_ONLY_ONCE" /> + </Match> </FindBugsFilter> diff --git a/shell/src/main/java/org/apache/accumulo/shell/Shell.java b/shell/src/main/java/org/apache/accumulo/shell/Shell.java index a3efa9a..71a1649 100644 --- a/shell/src/main/java/org/apache/accumulo/shell/Shell.java +++ b/shell/src/main/java/org/apache/accumulo/shell/Shell.java @@ -875,8 +875,7 @@ public class Shell extends ShellOptions implements KeywordExecutable { ++exitCode; printException(e); } - if (sc != null) - sc.printHelp(this); + sc.printHelp(this); } catch (UserInterruptException e) { ++exitCode; } catch (Exception e) { diff --git a/test/src/main/java/org/apache/accumulo/test/BadDeleteMarkersCreatedIT.java b/test/src/main/java/org/apache/accumulo/test/BadDeleteMarkersCreatedIT.java index c765679..33b0a2b 100644 --- a/test/src/main/java/org/apache/accumulo/test/BadDeleteMarkersCreatedIT.java +++ b/test/src/main/java/org/apache/accumulo/test/BadDeleteMarkersCreatedIT.java @@ -114,7 +114,6 @@ public class BadDeleteMarkersCreatedIT extends AccumuloClusterHarness { getCluster().getClusterControl().startAllServers(ServerType.GARBAGE_COLLECTOR); log.info("Garbage collector was restarted"); - gcLockData = null; do { gcLockData = ZooLock.getLockData(zcache, path, null); if (null == gcLockData) { diff --git a/test/src/main/java/org/apache/accumulo/test/functional/KerberosProxyIT.java b/test/src/main/java/org/apache/accumulo/test/functional/KerberosProxyIT.java index 4ea76d1..d0bc1df 100644 --- a/test/src/main/java/org/apache/accumulo/test/functional/KerberosProxyIT.java +++ b/test/src/main/java/org/apache/accumulo/test/functional/KerberosProxyIT.java @@ -193,9 +193,7 @@ public class KerberosProxyIT extends AccumuloITBase { TSaslClientTransport transport = new TSaslClientTransport("GSSAPI", null, proxyPrimary, hostname, Collections.singletonMap("javax.security.sasl.qop", "auth"), null, socket); - final UGIAssumingTransport ugiTransport = new UGIAssumingTransport(transport, ugi); - - try { + try (UGIAssumingTransport ugiTransport = new UGIAssumingTransport(transport, ugi)) { // UGI transport will perform the doAs for us ugiTransport.open(); success = true; @@ -207,10 +205,6 @@ public class KerberosProxyIT extends AccumuloITBase { proxyProcess = checkProxyAndRestart(proxyProcess, cfg); continue; } - } finally { - if (null != ugiTransport) { - ugiTransport.close(); - } } } @@ -416,17 +410,16 @@ public class KerberosProxyIT extends AccumuloITBase { TSaslClientTransport transport = new TSaslClientTransport("GSSAPI", null, proxyPrimary, hostname, Collections.singletonMap("javax.security.sasl.qop", "auth"), null, socket); - final UGIAssumingTransport ugiTransport = new UGIAssumingTransport(transport, ugi); + try (UGIAssumingTransport ugiTransport = new UGIAssumingTransport(transport, ugi)) { - // UGI transport will perform the doAs for us - ugiTransport.open(); + // UGI transport will perform the doAs for us + ugiTransport.open(); - AccumuloProxy.Client.Factory factory = new AccumuloProxy.Client.Factory(); - Client client = - factory.getClient(new TCompactProtocol(ugiTransport), new TCompactProtocol(ugiTransport)); + AccumuloProxy.Client.Factory factory = new AccumuloProxy.Client.Factory(); + Client client = + factory.getClient(new TCompactProtocol(ugiTransport), new TCompactProtocol(ugiTransport)); - // Will fail because the proxy can't impersonate this user (per the site configuration) - try { + // Will fail because the proxy can't impersonate this user (per the site configuration) // Error msg would look like: // // org.apache.accumulo.core.client.AccumuloSecurityException: Error BAD_CREDENTIALS for user @@ -439,10 +432,6 @@ public class KerberosProxyIT extends AccumuloITBase { assertTrue(thriftExceptionMatchesPattern(e, ".*Error BAD_CREDENTIALS.*")); assertTrue(thriftExceptionMatchesPattern(e, ".*Expected '" + proxyPrincipal + "' but was '" + kdc.qualifyUser(user) + "'.*")); - } finally { - if (null != ugiTransport) { - ugiTransport.close(); - } } } @@ -469,27 +458,22 @@ public class KerberosProxyIT extends AccumuloITBase { TSaslClientTransport transport = new TSaslClientTransport("GSSAPI", null, proxyPrimary, hostname, Collections.singletonMap("javax.security.sasl.qop", "auth"), null, socket); - final UGIAssumingTransport ugiTransport = new UGIAssumingTransport(transport, ugi); + try (UGIAssumingTransport ugiTransport = new UGIAssumingTransport(transport, ugi)) { - // UGI transport will perform the doAs for us - ugiTransport.open(); + // UGI transport will perform the doAs for us + ugiTransport.open(); - AccumuloProxy.Client.Factory factory = new AccumuloProxy.Client.Factory(); - Client client = - factory.getClient(new TCompactProtocol(ugiTransport), new TCompactProtocol(ugiTransport)); + AccumuloProxy.Client.Factory factory = new AccumuloProxy.Client.Factory(); + Client client = + factory.getClient(new TCompactProtocol(ugiTransport), new TCompactProtocol(ugiTransport)); - // The proxy needs to recognize that the requested principal isn't the same as the SASL - // principal and fail - // Accumulo should let this through -- we need to rely on the proxy to dump me before talking to - // accumulo - try { + // The proxy needs to recognize that the requested principal isn't the same as the SASL + // principal and fail + // Accumulo should let this through -- we need to rely on the proxy to dump me before talking + // to accumulo AccumuloSecurityException e = assertThrows(AccumuloSecurityException.class, () -> client.login(rootUser.getPrincipal(), Collections.<String,String>emptyMap())); assertTrue(thriftExceptionMatchesPattern(e, ProxyServer.RPC_ACCUMULO_PRINCIPAL_MISMATCH_MSG)); - } finally { - if (null != ugiTransport) { - ugiTransport.close(); - } } } diff --git a/test/src/main/java/org/apache/accumulo/test/randomwalk/Module.java b/test/src/main/java/org/apache/accumulo/test/randomwalk/Module.java index dba47a3..6fff36f 100644 --- a/test/src/main/java/org/apache/accumulo/test/randomwalk/Module.java +++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/Module.java @@ -361,9 +361,7 @@ public class Module extends Node { curNodeId = nextNodeId; } } finally { - if (null != service) { - service.shutdownNow(); - } + service.shutdownNow(); } if (teardown && (fixture != null)) { diff --git a/test/src/main/spotbugs/exclude-filter.xml b/test/src/main/spotbugs/exclude-filter.xml index 72d133f..3b01ce1 100644 --- a/test/src/main/spotbugs/exclude-filter.xml +++ b/test/src/main/spotbugs/exclude-filter.xml @@ -57,4 +57,8 @@ <!-- More convenient to ignore these everywhere, because it's very common and unimportant --> <Bug pattern="JUA_DONT_ASSERT_INSTANCEOF_IN_TESTS" /> </Match> + <Match> + <!-- More convenient to ignore these everywhere, because it's very common and unimportant --> + <Bug pattern="DMI_RANDOM_USED_ONLY_ONCE" /> + </Match> </FindBugsFilter>