Skip to content

Commit

Permalink
Re-visit previously disabled spotbugs patterns and enable them (#17560)
Browse files Browse the repository at this point in the history
  • Loading branch information
Akshat-Jain authored Dec 13, 2024
1 parent a26e4c0 commit fed3684
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 24 deletions.
6 changes: 0 additions & 6 deletions codestyle/spotbugs-exclude.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
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.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -294,7 +294,7 @@ private static String getPrefixedKeyColumn(String keyPrefix, String keyName)
private void createUserInternal(String prefix, String userName)
{
int attempts = 0;
while (attempts < numRetries) {
while (attempts < NUM_RETRIES) {
if (createUserOnce(prefix, userName)) {
return;
} else {
Expand All @@ -308,7 +308,7 @@ private void createUserInternal(String prefix, String userName)
private void deleteUserInternal(String prefix, String userName)
{
int attempts = 0;
while (attempts < numRetries) {
while (attempts < NUM_RETRIES) {
if (deleteUserOnce(prefix, userName)) {
return;
} else {
Expand Down Expand Up @@ -349,7 +349,7 @@ private void setUserCredentialsInternal(String prefix, String userName, BasicAut
}

int attempts = 0;
while (attempts < numRetries) {
while (attempts < NUM_RETRIES) {
if (setUserCredentialOnce(prefix, userName, credentials)) {
return;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

public class OIDCConfig
{
private final String DEFAULT_SCOPE = "name";
private static final String DEFAULT_SCOPE = "name";
@JsonProperty
private final String clientID;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@

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)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public String apply(@Nullable String value)
try {
return bucket(Double.parseDouble(value));
}
catch (NumberFormatException | NullPointerException ex) {
catch (NumberFormatException ex) {
return null;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,10 +213,14 @@ private boolean isJoinedSpatialDimValValid(String dimVal)
@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;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ public int getActiveConnections()
}

@VisibleForTesting
public static void setJettyServerThreadPool(QueuedThreadPool threadPool)
protected static void setJettyServerThreadPool(QueuedThreadPool threadPool)
{
jettyServerThreadPool = threadPool;
}
Expand Down

0 comments on commit fed3684

Please sign in to comment.