Skip to content

Commit ff07df3

Browse files
Fix ConstructorThrow SpotBugs warnings in core module (#5785)
* Fix ConstructorThrow SpotBugs warningins in core module --------- Co-authored-by: Christopher Tubbs <ctubbsii@apache.org>
1 parent 8907cf1 commit ff07df3

File tree

84 files changed

+219
-83
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+219
-83
lines changed

core/pom.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@
2929
<artifactId>accumulo-core</artifactId>
3030
<name>Apache Accumulo Core</name>
3131
<description>Apache Accumulo core libraries.</description>
32+
<properties>
33+
<spotbugs.omitVisitors>SharedVariableAtomicityDetector</spotbugs.omitVisitors>
34+
</properties>
3235
<dependencies>
3336
<dependency>
3437
<groupId>com.beust</groupId>

core/src/main/java/org/apache/accumulo/core/classloader/URLContextClassLoaderFactory.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import java.net.URL;
2323
import java.net.URLClassLoader;
2424
import java.util.Arrays;
25-
import java.util.concurrent.atomic.AtomicBoolean;
2625

2726
import org.apache.accumulo.core.spi.common.ContextClassLoaderFactory;
2827
import org.apache.accumulo.core.util.cache.Caches;
@@ -39,9 +38,7 @@
3938
*/
4039
public class URLContextClassLoaderFactory implements ContextClassLoaderFactory {
4140

42-
private static final AtomicBoolean isInstantiated = new AtomicBoolean(false);
4341
private static final Logger LOG = LoggerFactory.getLogger(URLContextClassLoaderFactory.class);
44-
private static final String className = URLContextClassLoaderFactory.class.getName();
4542

4643
// Cache the class loaders for re-use
4744
// WeakReferences are used so that the class loaders can be cleaned up when no longer needed
@@ -50,12 +47,6 @@ public class URLContextClassLoaderFactory implements ContextClassLoaderFactory {
5047
private final Cache<String,URLClassLoader> classloaders =
5148
Caches.getInstance().createNewBuilder(CacheName.CLASSLOADERS, true).weakValues().build();
5249

53-
public URLContextClassLoaderFactory() {
54-
if (!isInstantiated.compareAndSet(false, true)) {
55-
throw new IllegalStateException("Can only instantiate " + className + " once");
56-
}
57-
}
58-
5950
@Override
6051
public ClassLoader getClassLoader(String context) {
6152
if (context == null) {

core/src/main/java/org/apache/accumulo/core/client/IteratorSetting.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
* scanner.addScanIterator(cfg);
5252
* </pre>
5353
*/
54-
public class IteratorSetting implements Writable {
54+
public final class IteratorSetting implements Writable {
5555
private int priority;
5656
private String name;
5757
private String iteratorClass;

core/src/main/java/org/apache/accumulo/core/client/rfile/RFileScanner.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777

7878
import com.google.common.base.Preconditions;
7979

80-
class RFileScanner extends ScannerOptions implements Scanner {
80+
final class RFileScanner extends ScannerOptions implements Scanner {
8181

8282
private static class RFileScannerEnvironmentImpl extends ClientServiceEnvironmentImpl {
8383

core/src/main/java/org/apache/accumulo/core/client/security/tokens/CredentialProviderToken.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,13 @@
3030
import org.apache.accumulo.core.conf.HadoopCredentialProvider;
3131
import org.apache.hadoop.conf.Configuration;
3232

33+
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
34+
3335
/**
3436
* An {@link AuthenticationToken} backed by a Hadoop CredentialProvider.
3537
*/
38+
@SuppressFBWarnings(value = "CT_CONSTRUCTOR_THROW",
39+
justification = "Constructor validation is required for proper initialization")
3640
public class CredentialProviderToken extends PasswordToken {
3741
public static final String NAME_PROPERTY = "name";
3842
public static final String CREDENTIAL_PROVIDERS_PROPERTY = "credentialProviders";

core/src/main/java/org/apache/accumulo/core/client/security/tokens/KerberosToken.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,15 @@
3434
import org.apache.hadoop.security.UserGroupInformation;
3535
import org.apache.hadoop.security.UserGroupInformation.AuthenticationMethod;
3636

37+
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
38+
3739
/**
3840
* Authentication token for Kerberos authenticated clients
3941
*
4042
* @since 1.7.0
4143
*/
44+
@SuppressFBWarnings(value = "CT_CONSTRUCTOR_THROW",
45+
justification = "Constructor validation is required for proper initialization")
4246
public class KerberosToken implements AuthenticationToken {
4347

4448
public static final String CLASS_NAME = KerberosToken.class.getName();

core/src/main/java/org/apache/accumulo/core/client/summary/CounterSummary.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
*
3434
* @since 2.0.0
3535
*/
36-
public class CounterSummary {
36+
public final class CounterSummary {
3737
private Map<String,Long> stats;
3838

3939
private static final Logger log = LoggerFactory.getLogger(CounterSummary.class);

core/src/main/java/org/apache/accumulo/core/clientImpl/ActiveScanImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
*
4343
* @since 1.6.0
4444
*/
45-
public class ActiveScanImpl extends ActiveScan {
45+
public final class ActiveScanImpl extends ActiveScan {
4646

4747
private final long scanId;
4848
private final String client;

core/src/main/java/org/apache/accumulo/core/clientImpl/DelegationTokenImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
import org.apache.hadoop.io.Text;
3333
import org.apache.hadoop.security.token.Token;
3434

35-
public class DelegationTokenImpl extends PasswordToken implements DelegationToken {
35+
public final class DelegationTokenImpl extends PasswordToken implements DelegationToken {
3636

3737
public static final String SERVICE_NAME = "AccumuloDelegationToken";
3838

core/src/main/java/org/apache/accumulo/core/clientImpl/OfflineIterator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
import org.apache.hadoop.fs.FileSystem;
7373
import org.apache.hadoop.io.Text;
7474

75-
class OfflineIterator implements Iterator<Entry<Key,Value>> {
75+
final class OfflineIterator implements Iterator<Entry<Key,Value>> {
7676

7777
private SortedKeyValueIterator<Key,Value> iter;
7878
private Range range;

0 commit comments

Comments
 (0)