Re-visit previously disabled spotbugs patterns and enable them (#17560)

This commit is contained in:
Akshat Jain 2024-12-13 19:54:40 +05:30 committed by GitHub
parent a26e4c0e06
commit fed36844f1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 22 additions and 24 deletions

View File

@ -137,15 +137,9 @@
<Bug pattern="SWL_SLEEP_WITH_LOCK_HELD"/>
<Bug pattern="UL_UNRELEASED_LOCK_EXCEPTION_PATH"/>
<Bug pattern="URF_UNREAD_FIELD"/>
<!-- The following patterns have been excluded as part of upgrading to Java 17 as there were 100s of occurrences.
We should revisit these later. -->
<Bug pattern="CT_CONSTRUCTOR_THROW"/>
<Bug pattern="SING_SINGLETON_HAS_NONPRIVATE_CONSTRUCTOR"/>
<Bug pattern="DCN_NULLPOINTER_EXCEPTION"/>
<Bug pattern="SING_SINGLETON_INDIRECTLY_IMPLEMENTS_CLONEABLE"/>
<Bug pattern="MS_EXPOSE_REP"/>
<Bug pattern="PA_PUBLIC_PRIMITIVE_ATTRIBUTE"/>
<Bug pattern="EI_EXPOSE_STATIC_REP2"/>
<Bug pattern="SS_SHOULD_BE_STATIC"/>
<Bug pattern="SING_SINGLETON_IMPLEMENTS_SERIALIZABLE"/>
</FindBugsFilter>

View File

@ -31,8 +31,8 @@ import javax.annotation.Nullable;
public class KubernetesAndWorkerTaskRunnerConfig
{
private final String RUNNER_STRATEGY_TYPE = "runnerStrategy.type";
private final String RUNNER_STRATEGY_WORKER_TYPE = "runnerStrategy.workerType";
private static final String RUNNER_STRATEGY_TYPE = "runnerStrategy.type";
private static final String RUNNER_STRATEGY_WORKER_TYPE = "runnerStrategy.workerType";
/**
* Select which runner type a task would run on, options are k8s or worker.
*/

View File

@ -74,7 +74,7 @@ public class CoordinatorBasicAuthenticatorMetadataStorageUpdater implements Basi
private final BasicAuthCommonCacheConfig commonCacheConfig;
private final ObjectMapper objectMapper;
private final BasicAuthenticatorCacheNotifier cacheNotifier;
private final int numRetries = 5;
private static final int NUM_RETRIES = 5;
private final Map<String, BasicAuthenticatorUserMapBundle> cachedUserMaps;
private final Set<String> authenticatorPrefixes;
@ -294,7 +294,7 @@ public class CoordinatorBasicAuthenticatorMetadataStorageUpdater implements Basi
private void createUserInternal(String prefix, String userName)
{
int attempts = 0;
while (attempts < numRetries) {
while (attempts < NUM_RETRIES) {
if (createUserOnce(prefix, userName)) {
return;
} else {
@ -308,7 +308,7 @@ public class CoordinatorBasicAuthenticatorMetadataStorageUpdater implements Basi
private void deleteUserInternal(String prefix, String userName)
{
int attempts = 0;
while (attempts < numRetries) {
while (attempts < NUM_RETRIES) {
if (deleteUserOnce(prefix, userName)) {
return;
} else {
@ -349,7 +349,7 @@ public class CoordinatorBasicAuthenticatorMetadataStorageUpdater implements Basi
}
int attempts = 0;
while (attempts < numRetries) {
while (attempts < NUM_RETRIES) {
if (setUserCredentialOnce(prefix, userName, credentials)) {
return;
} else {

View File

@ -91,7 +91,7 @@ public class CoordinatorBasicAuthorizerMetadataStorageUpdater implements BasicAu
private final BasicAuthorizerCacheNotifier cacheNotifier;
private final BasicAuthCommonCacheConfig commonCacheConfig;
private final ObjectMapper objectMapper;
private final int numRetries = 5;
private static final int numRetries = 5;
private final Map<String, BasicAuthorizerUserMapBundle> cachedUserMaps;
private final Map<String, BasicAuthorizerGroupMappingMapBundle> cachedGroupMappingMaps;

View File

@ -28,7 +28,7 @@ import javax.annotation.Nullable;
public class OIDCConfig
{
private final String DEFAULT_SCOPE = "name";
private static final String DEFAULT_SCOPE = "name";
@JsonProperty
private final String clientID;

View File

@ -41,8 +41,8 @@ public class ApproximateHistogram
// max size of the histogram (number of bincount/position pairs)
int size;
public float[] positions;
public long[] bins;
protected float[] positions;
protected long[] bins;
// used bincount
int binCount;

View File

@ -27,11 +27,11 @@ import java.util.Arrays;
public class Histogram
{
public float[] breaks;
public long[] bins;
public transient long count;
public float min;
public float max;
protected float[] breaks;
protected long[] bins;
protected transient long count;
protected float min;
protected float max;
public Histogram(float[] breaks)
{

View File

@ -81,7 +81,7 @@ public class BucketExtractionFn implements ExtractionFn
try {
return bucket(Double.parseDouble(value));
}
catch (NumberFormatException | NullPointerException ex) {
catch (NumberFormatException ex) {
return null;
}
}

View File

@ -213,10 +213,14 @@ public class SpatialDimensionRowTransformer implements Function<InputRow, InputR
@Nullable
private static Float tryParseFloat(String val)
{
if (val == null) {
return null;
}
try {
return Float.parseFloat(val);
}
catch (NullPointerException | NumberFormatException e) {
catch (NumberFormatException e) {
return null;
}
}

View File

@ -597,7 +597,7 @@ public class JettyServerModule extends JerseyServletModule
}
@VisibleForTesting
public static void setJettyServerThreadPool(QueuedThreadPool threadPool)
protected static void setJettyServerThreadPool(QueuedThreadPool threadPool)
{
jettyServerThreadPool = threadPool;
}