Skip to content

Commit f733782

Browse files
committed
Fix spotbugs bugs
1 parent bffab64 commit f733782

File tree

40 files changed

+142
-81
lines changed

40 files changed

+142
-81
lines changed

auth/src/main/java/software/amazon/awssdk/auth/credentials/ContainerCredentialsRetryPolicy.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,7 @@ public boolean shouldRetry(int retriesAttempted, ResourcesEndpointRetryParameter
3838
return true;
3939
}
4040

41-
if (retryParams.getException() != null && retryParams.getException() instanceof IOException) {
42-
return true;
43-
}
44-
45-
return false;
41+
return retryParams.getException() instanceof IOException;
4642
}
4743

4844
}

auth/src/main/java/software/amazon/awssdk/auth/credentials/DefaultCredentialsProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
* @see ContainerCredentialsProvider
3636
* @see InstanceProfileCredentialsProvider
3737
*/
38-
public class DefaultCredentialsProvider implements AwsCredentialsProvider, SdkAutoCloseable {
38+
public final class DefaultCredentialsProvider implements AwsCredentialsProvider, SdkAutoCloseable {
3939

4040
private static final DefaultCredentialsProvider DEFAULT_CREDENTIALS_PROVIDER = new DefaultCredentialsProvider(builder());
4141

auth/src/main/java/software/amazon/awssdk/auth/credentials/SystemPropertyCredentialsProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
* {@link AwsCredentialsProvider} implementation that loads credentials from the aws.accessKeyId, aws.secretAccessKey and
2424
* aws.sessionToken system properties.
2525
*/
26-
public class SystemPropertyCredentialsProvider extends SystemSettingsCredentialsProvider {
26+
public final class SystemPropertyCredentialsProvider extends SystemSettingsCredentialsProvider {
2727

2828
private SystemPropertyCredentialsProvider() {
2929
}

auth/src/main/java/software/amazon/awssdk/auth/signer/internal/Aws4SignerRequestParams.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public final class Aws4SignerRequestParams {
2727
/**
2828
* The signing algorithm to be used for computing the signature.
2929
*/
30-
private final String signingAlgorithm = SignerConstant.AWS4_SIGNING_ALGORITHM;
30+
private static final String SIGNING_ALGORITHM = SignerConstant.AWS4_SIGNING_ALGORITHM;
3131

3232
/**
3333
* The datetime in milliseconds for which the signature needs to be
@@ -144,6 +144,6 @@ public String getFormattedSigningDate() {
144144
* Returns the signing algorithm used for computing the signature.
145145
*/
146146
public String getSigningAlgorithm() {
147-
return signingAlgorithm;
147+
return SIGNING_ALGORITHM;
148148
}
149149
}

auth/src/main/java/software/amazon/awssdk/auth/signer/params/AwsS3V4SignerParams.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ public Builder enablePayloadSigning(Boolean enablePayloadSigning) {
9292
return this;
9393
}
9494

95+
@Override
9596
public AwsS3V4SignerParams build() {
9697
return new AwsS3V4SignerParams(this);
9798
}

aws-core/src/main/java/software/amazon/awssdk/awscore/config/options/AwsClientOptionValidation.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
* A set of static methods used to validate that a {@link SdkClientConfiguration} contains all of
2323
* the values required for the AWS client handlers to function.
2424
*/
25-
public class AwsClientOptionValidation extends SdkClientOptionValidation {
25+
public final class AwsClientOptionValidation extends SdkClientOptionValidation {
2626
private AwsClientOptionValidation() {}
2727

2828
public static void validateAsyncClientOptions(SdkClientConfiguration c) {

aws-core/src/main/java/software/amazon/awssdk/awscore/http/response/StaxResponseHandler.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ public StaxResponseHandler(Unmarshaller<T, StaxUnmarshallerContext> responseUnma
8282
/**
8383
* @see HttpResponseHandler#handle(HttpResponse, ExecutionAttributes)
8484
*/
85+
@Override
8586
public T handle(HttpResponse response, ExecutionAttributes executionAttributes) throws Exception {
8687
SdkStandardLogger.REQUEST_LOGGER.trace(() -> "Parsing service response XML.");
8788
InputStream content = response.getContent();
@@ -136,6 +137,7 @@ protected void registerAdditionalMetadataExpressions(StaxUnmarshallerContext unm
136137
*
137138
* @see HttpResponseHandler#needsConnectionLeftOpen()
138139
*/
140+
@Override
139141
public boolean needsConnectionLeftOpen() {
140142
return false;
141143
}

aws-core/src/main/java/software/amazon/awssdk/awscore/protocol/json/AwsJsonProtocolMetadata.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
* Provides additional metadata about AWS Json protocol.
2222
*/
2323
@SdkProtectedApi
24-
public class AwsJsonProtocolMetadata {
24+
public final class AwsJsonProtocolMetadata {
2525

2626
private final AwsJsonProtocol protocol;
2727
private final String protocolVersion;

aws-core/src/main/java/software/amazon/awssdk/awscore/protocol/xml/SimpleTypeStaxUnmarshallers.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
/**
3030
* Collection of StAX unmarshallers for simple data types.
3131
*/
32-
public class SimpleTypeStaxUnmarshallers {
32+
public final class SimpleTypeStaxUnmarshallers {
3333
/** Shared logger. */
3434
private static Logger log = LoggerFactory.getLogger(SimpleTypeStaxUnmarshallers.class);
3535

aws-core/src/main/java/software/amazon/awssdk/awscore/retry/AwsRetryPolicy.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import software.amazon.awssdk.awscore.internal.AwsErrorCode;
2020
import software.amazon.awssdk.core.retry.RetryPolicy;
2121
import software.amazon.awssdk.core.retry.conditions.RetryCondition;
22+
import software.amazon.awssdk.core.retry.conditions.SdkRetryCondition;
2223

2324
/**
2425
* Retry Policy used by clients when communicating with AWS services.
@@ -27,7 +28,7 @@
2728
public final class AwsRetryPolicy {
2829

2930
public static final RetryCondition AWS_DEFAULT_RETRY_CONDITION =
30-
RetryCondition.DEFAULT.or(new RetryOnErrorCodeCondition(AwsErrorCode.RETRYABLE_ERROR_CODES));
31+
SdkRetryCondition.DEFAULT.or(new RetryOnErrorCodeCondition(AwsErrorCode.RETRYABLE_ERROR_CODES));
3132

3233
public static final RetryPolicy DEFAULT =
3334
RetryPolicy.DEFAULT.toBuilder()

build-tools/src/main/resources/software/amazon/awssdk/spotbugs-suppressions.xml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,40 @@
6767
<Method name="onComplete" />
6868
<Bug pattern="NP_NONNULL_PARAM_VIOLATION" />
6969
</Match>
70+
71+
<!-- False positive -->
72+
<Match>
73+
<Class name="software.amazon.awssdk.core.ResponseBytes" />
74+
<Bug pattern="EI_EXPOSE_REP2" />
75+
</Match>
76+
77+
<!-- False positive Unconfirmed cast-->
78+
<Match>
79+
<Or>
80+
<Class name="software.amazon.awssdk.core.client.BaseAsyncClientHandler$InterceptorCallingHttpResponseHandler" />
81+
<Class name="software.amazon.awssdk.core.client.BaseAsyncClientHandler$UnmarshallingSdkHttpResponseHandler" />
82+
<Class name="software.amazon.awssdk.core.internal.http.async.SyncResponseHandlerAdapter" />
83+
</Or>
84+
<Bug pattern="BC_UNCONFIRMED_CAST" />
85+
</Match>
86+
87+
<Match>
88+
<Or>
89+
<Class name="software.amazon.awssdk.awscore.protocol.xml.StandardErrorUnmarshaller" />
90+
<Class name="software.amazon.awssdk.awscore.protocol.xml.LegacyErrorUnmarshaller" />
91+
</Or>
92+
<Bug pattern="BC_UNCONFIRMED_CAST_OF_RETURN_VALUE" />
93+
</Match>
94+
95+
<!-- Currently they look the same and we will revisit this when we add APIG -->
96+
<Match>
97+
<Or>
98+
<Class name="software.amazon.awssdk.core.client.SdkAsyncClientHandler" />
99+
<Class name="software.amazon.awssdk.core.client.SdkSyncClientHandler" />
100+
<Class name="software.amazon.awssdk.awscore.client.handler.AwsSyncClientHandler" />
101+
<Class name="software.amazon.awssdk.awscore.client.handler.AwsAsyncClientHandler" />
102+
</Or>
103+
<Bug pattern="RI_REDUNDANT_INTERFACES" />
104+
</Match>
105+
70106
</FindBugsFilter>

codegen/src/main/java/software/amazon/awssdk/codegen/poet/model/ModelBuilderSpecs.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
class ModelBuilderSpecs {
4141
private final IntermediateModel intermediateModel;
4242
private final ShapeModel shapeModel;
43-
private final ShapeModelSpec shapeModelSpec;
4443
private final TypeProvider typeProvider;
4544
private final PoetExtensions poetExtensions;
4645
private final AccessorsFactory accessorsFactory;
@@ -51,7 +50,6 @@ class ModelBuilderSpecs {
5150
TypeProvider typeProvider) {
5251
this.intermediateModel = intermediateModel;
5352
this.shapeModel = shapeModel;
54-
this.shapeModelSpec = shapeModelSpec;
5553
this.typeProvider = typeProvider;
5654
this.poetExtensions = new PoetExtensions(this.intermediateModel);
5755
this.accessorsFactory = new AccessorsFactory(this.shapeModel, this.intermediateModel, this.typeProvider, poetExtensions);

core/src/main/java/software/amazon/awssdk/core/RequestOverrideConfiguration.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
package software.amazon.awssdk.core;
1717

18-
import java.time.Duration;
1918
import java.util.ArrayList;
2019
import java.util.Collections;
2120
import java.util.HashMap;
@@ -24,7 +23,6 @@
2423
import java.util.Optional;
2524
import java.util.TreeMap;
2625
import java.util.function.Consumer;
27-
2826
import software.amazon.awssdk.annotations.Immutable;
2927

3028
/**
@@ -196,8 +194,6 @@ protected abstract static class BuilderImpl<B extends Builder> implements Builde
196194

197195
private Map<String, List<String>> rawQueryParameters;
198196

199-
private Duration requestExecutionTimeout;
200-
201197
private List<ApiName> apiNames;
202198

203199
protected BuilderImpl() {

core/src/main/java/software/amazon/awssdk/core/SdkStandardLogger.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
* just these loggers to get the type of that they want instead of having to enable all logging.
2424
*/
2525
@SdkInternalApi
26-
public class SdkStandardLogger {
26+
public final class SdkStandardLogger {
2727
/**
2828
* Logger providing detailed information on requests/responses. Users can enable this logger to get access to AWS request IDs
2929
* for responses, individual requests and parameters sent to AWS, etc.

core/src/main/java/software/amazon/awssdk/core/client/BaseAsyncClientHandler.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ private interface ResponseHandlerFactory<ReturnT> extends
170170
Function<HttpResponseAdapter, SdkHttpResponseHandler<ReturnT>> {
171171
}
172172

173-
private static class InterceptorCallingHttpResponseHandler<T> implements SdkHttpResponseHandler<T> {
173+
private static final class InterceptorCallingHttpResponseHandler<T> implements SdkHttpResponseHandler<T> {
174174
private final SdkHttpResponseHandler<T> delegate;
175175
private final ExecutionContext context;
176176

@@ -279,7 +279,7 @@ public ReturnT complete() {
279279
* provide the request content in a non-blocking manner. This adapts that interface to the
280280
* {@link SdkHttpRequestProvider} which the HTTP client SPI expects.
281281
*/
282-
private static class SdkHttpRequestProviderAdapter implements SdkHttpRequestProvider {
282+
private static final class SdkHttpRequestProviderAdapter implements SdkHttpRequestProvider {
283283

284284
private final AsyncRequestBody asyncRequestBody;
285285

core/src/main/java/software/amazon/awssdk/core/config/ClientAsyncConfiguration.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,6 @@ public Builder advancedOptions(Map<SdkAdvancedAsyncClientOption<?>, ?> advancedO
9494
return this;
9595
}
9696

97-
private Builder advancedOptions(AttributeMap.Builder attributeMap) {
98-
this.advancedOptions = attributeMap;
99-
return this;
100-
}
101-
10297
public void setAdvancedOptions(Map<SdkAdvancedAsyncClientOption<?>, Object> advancedOptions) {
10398
advancedOptions(advancedOptions);
10499
}

core/src/main/java/software/amazon/awssdk/core/http/ExecutionContext.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
*/
3333
@NotThreadSafe
3434
@SdkProtectedApi
35-
public class ExecutionContext implements ToCopyableBuilder<ExecutionContext.Builder, ExecutionContext> {
35+
public final class ExecutionContext implements ToCopyableBuilder<ExecutionContext.Builder, ExecutionContext> {
3636
private final Signer signer;
3737
private InterceptorContext interceptorContext;
3838
private final ExecutionInterceptorChain interceptorChain;

core/src/main/java/software/amazon/awssdk/core/internal/http/HttpClientDependencies.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
* RequestPipeline} implementations by {@link RequestPipelineBuilder}.
3333
*/
3434
@SdkInternalApi
35-
public class HttpClientDependencies implements SdkAutoCloseable {
35+
public final class HttpClientDependencies implements SdkAutoCloseable {
3636
private final SdkClientConfiguration clientConfiguration;
3737
private final CapacityManager capacityManager;
3838
private final ClientExecutionTimer clientExecutionTimer;
@@ -87,7 +87,7 @@ public void updateTimeOffset(int timeOffset) {
8787
}
8888

8989
@Override
90-
public final void close() {
90+
public void close() {
9191
this.clientConfiguration.close();
9292
this.clientExecutionTimer.close();
9393
}

core/src/main/java/software/amazon/awssdk/core/internal/http/pipeline/RequestPipelineBuilder.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import software.amazon.awssdk.annotations.Immutable;
2626
import software.amazon.awssdk.annotations.SdkInternalApi;
2727
import software.amazon.awssdk.core.internal.http.HttpClientDependencies;
28-
import software.amazon.awssdk.core.internal.http.HttpClientDependencies;
2928
import software.amazon.awssdk.core.internal.http.RequestExecutionContext;
3029

3130
/**
@@ -36,11 +35,11 @@
3635
*/
3736
@Immutable
3837
@SdkInternalApi
39-
public class RequestPipelineBuilder<InputT, OutputT> {
38+
public final class RequestPipelineBuilder<InputT, OutputT> {
4039

4140
private final Function<HttpClientDependencies, RequestPipeline<InputT, OutputT>> pipelineFactory;
4241

43-
RequestPipelineBuilder(Function<HttpClientDependencies, RequestPipeline<InputT, OutputT>> pipelineFactory) {
42+
private RequestPipelineBuilder(Function<HttpClientDependencies, RequestPipeline<InputT, OutputT>> pipelineFactory) {
4443
this.pipelineFactory = pipelineFactory;
4544
}
4645

core/src/main/java/software/amazon/awssdk/core/internal/http/pipeline/stages/AsyncRetryableStage.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@
4444
/**
4545
* Wrapper around the pipeline for a single request to provide retry functionality.
4646
*/
47-
public class AsyncRetryableStage<OutputT> implements RequestPipeline<SdkHttpFullRequest, CompletableFuture<Response<OutputT>>> {
47+
public final class AsyncRetryableStage<OutputT> implements RequestPipeline<SdkHttpFullRequest,
48+
CompletableFuture<Response<OutputT>>> {
4849

4950
private static final Logger log = LoggerFactory.getLogger(AsyncRetryableStage.class);
5051

core/src/main/java/software/amazon/awssdk/core/internal/http/pipeline/stages/ClientExecutionTimedStage.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,11 @@ public class ClientExecutionTimedStage<OutputT> implements RequestToResponsePipe
4040

4141
private final RequestPipeline<SdkHttpFullRequest, Response<OutputT>> wrapped;
4242
private final ClientExecutionTimer clientExecutionTimer;
43-
private final SdkClientConfiguration clientConfig;
4443

4544
public ClientExecutionTimedStage(HttpClientDependencies dependencies,
4645
RequestPipeline<SdkHttpFullRequest, Response<OutputT>> wrapped) {
4746
this.wrapped = wrapped;
4847
this.clientExecutionTimer = dependencies.clientExecutionTimer();
49-
this.clientConfig = dependencies.clientConfiguration();
5048
}
5149

5250
@Override

core/src/main/java/software/amazon/awssdk/core/internal/http/pipeline/stages/MakeAsyncHttpRequestStage.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
/**
4848
* Delegate to the HTTP implementation to make an HTTP request and receive the response.
4949
*/
50-
public class MakeAsyncHttpRequestStage<OutputT>
50+
public final class MakeAsyncHttpRequestStage<OutputT>
5151
implements RequestPipeline<SdkHttpFullRequest, CompletableFuture<Response<OutputT>>> {
5252

5353
private static final Logger log = LoggerFactory.getLogger(MakeAsyncHttpRequestStage.class);

core/src/main/java/software/amazon/awssdk/core/internal/http/pipeline/stages/RetryableStage.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
/**
4646
* Wrapper around the pipeline for a single request to provide retry functionality.
4747
*/
48-
public class RetryableStage<OutputT> implements RequestToResponsePipeline<OutputT> {
48+
public final class RetryableStage<OutputT> implements RequestToResponsePipeline<OutputT> {
4949

5050
private static final Logger log = LoggerFactory.getLogger(RetryableStage.class);
5151

core/src/main/java/software/amazon/awssdk/core/internal/http/timers/client/NoOpClientExecutionAbortTrackerTask.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
* Dummy implementation of {@link ClientExecutionAbortTrackerTask} used when the timer is disabled
2222
* for a request
2323
*/
24-
public class NoOpClientExecutionAbortTrackerTask implements ClientExecutionAbortTrackerTask {
24+
public final class NoOpClientExecutionAbortTrackerTask implements ClientExecutionAbortTrackerTask {
2525

2626
public static final NoOpClientExecutionAbortTrackerTask INSTANCE = new NoOpClientExecutionAbortTrackerTask();
2727

core/src/main/java/software/amazon/awssdk/core/protocol/MarshallingInfo.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
* and additional directives about how to transform it (i.e. is it binary data, should it be auto generated, etc).
2525
*/
2626
@SdkProtectedApi
27-
public class MarshallingInfo<T> {
27+
public final class MarshallingInfo<T> {
2828

2929
private final MarshallingType<T> marshallingType;
3030
private final String marshallLocationName;

core/src/main/java/software/amazon/awssdk/core/protocol/OperationInfo.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
* Static information about an API operation used to marshall it correctly.
2424
*/
2525
@SdkProtectedApi
26-
public class OperationInfo {
26+
public final class OperationInfo {
2727

2828
private final String requestUri;
2929
private final HttpMethodName httpMethodName;

core/src/main/java/software/amazon/awssdk/core/protocol/json/internal/JsonMarshallerContext.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
* Dependencies needed by implementations of {@link JsonMarshaller}.
2626
*/
2727
@SdkInternalApi
28-
public class JsonMarshallerContext {
28+
public final class JsonMarshallerContext {
2929

3030
private final StructuredJsonGenerator jsonGenerator;
3131
private final JsonProtocolMarshaller protocolHandler;

core/src/main/java/software/amazon/awssdk/core/protocol/json/internal/MarshallerRegistry.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
import software.amazon.awssdk.core.protocol.StructuredPojo;
2727

2828
@SdkInternalApi
29-
public class MarshallerRegistry {
29+
public final class MarshallerRegistry {
3030

3131
private final Map<MarshallLocation, Map<MarshallingType, JsonMarshaller<?>>> marshallers;
3232
private final Set<MarshallingType<?>> marshallingTypes;

0 commit comments

Comments
 (0)