Skip to content

Commit

Permalink
Fix spotbugs bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
zoewangg committed Jun 13, 2018
1 parent bffab64 commit 16dafbc
Show file tree
Hide file tree
Showing 40 changed files with 142 additions and 81 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,7 @@ public boolean shouldRetry(int retriesAttempted, ResourcesEndpointRetryParameter
return true;
}

if (retryParams.getException() != null && retryParams.getException() instanceof IOException) {
return true;
}

return false;
return retryParams.getException() instanceof IOException;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
* @see ContainerCredentialsProvider
* @see InstanceProfileCredentialsProvider
*/
public class DefaultCredentialsProvider implements AwsCredentialsProvider, SdkAutoCloseable {
public final class DefaultCredentialsProvider implements AwsCredentialsProvider, SdkAutoCloseable {

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* {@link AwsCredentialsProvider} implementation that loads credentials from the aws.accessKeyId, aws.secretAccessKey and
* aws.sessionToken system properties.
*/
public class SystemPropertyCredentialsProvider extends SystemSettingsCredentialsProvider {
public final class SystemPropertyCredentialsProvider extends SystemSettingsCredentialsProvider {

private SystemPropertyCredentialsProvider() {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public final class Aws4SignerRequestParams {
/**
* The signing algorithm to be used for computing the signature.
*/
private final String signingAlgorithm = SignerConstant.AWS4_SIGNING_ALGORITHM;
private static final String SIGNING_ALGORITHM = SignerConstant.AWS4_SIGNING_ALGORITHM;

/**
* The datetime in milliseconds for which the signature needs to be
Expand Down Expand Up @@ -144,6 +144,6 @@ public String getFormattedSigningDate() {
* Returns the signing algorithm used for computing the signature.
*/
public String getSigningAlgorithm() {
return signingAlgorithm;
return SIGNING_ALGORITHM;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ public Builder enablePayloadSigning(Boolean enablePayloadSigning) {
return this;
}

@Override
public AwsS3V4SignerParams build() {
return new AwsS3V4SignerParams(this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* A set of static methods used to validate that a {@link SdkClientConfiguration} contains all of
* the values required for the AWS client handlers to function.
*/
public class AwsClientOptionValidation extends SdkClientOptionValidation {
public final class AwsClientOptionValidation extends SdkClientOptionValidation {
private AwsClientOptionValidation() {}

public static void validateAsyncClientOptions(SdkClientConfiguration c) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ public StaxResponseHandler(Unmarshaller<T, StaxUnmarshallerContext> responseUnma
/**
* @see HttpResponseHandler#handle(HttpResponse, ExecutionAttributes)
*/
@Override
public T handle(HttpResponse response, ExecutionAttributes executionAttributes) throws Exception {
SdkStandardLogger.REQUEST_LOGGER.trace(() -> "Parsing service response XML.");
InputStream content = response.getContent();
Expand Down Expand Up @@ -136,6 +137,7 @@ protected void registerAdditionalMetadataExpressions(StaxUnmarshallerContext unm
*
* @see HttpResponseHandler#needsConnectionLeftOpen()
*/
@Override
public boolean needsConnectionLeftOpen() {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* Provides additional metadata about AWS Json protocol.
*/
@SdkProtectedApi
public class AwsJsonProtocolMetadata {
public final class AwsJsonProtocolMetadata {

private final AwsJsonProtocol protocol;
private final String protocolVersion;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
/**
* Collection of StAX unmarshallers for simple data types.
*/
public class SimpleTypeStaxUnmarshallers {
public final class SimpleTypeStaxUnmarshallers {
/** Shared logger. */
private static Logger log = LoggerFactory.getLogger(SimpleTypeStaxUnmarshallers.class);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import software.amazon.awssdk.awscore.internal.AwsErrorCode;
import software.amazon.awssdk.core.retry.RetryPolicy;
import software.amazon.awssdk.core.retry.conditions.RetryCondition;
import software.amazon.awssdk.core.retry.conditions.SdkRetryCondition;

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

public static final RetryCondition AWS_DEFAULT_RETRY_CONDITION =
RetryCondition.DEFAULT.or(new RetryOnErrorCodeCondition(AwsErrorCode.RETRYABLE_ERROR_CODES));
SdkRetryCondition.DEFAULT.or(new RetryOnErrorCodeCondition(AwsErrorCode.RETRYABLE_ERROR_CODES));

public static final RetryPolicy DEFAULT =
RetryPolicy.DEFAULT.toBuilder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,40 @@
<Method name="onComplete" />
<Bug pattern="NP_NONNULL_PARAM_VIOLATION" />
</Match>

<!-- False positive -->
<Match>
<Class name="software.amazon.awssdk.core.ResponseBytes" />
<Bug pattern="EI_EXPOSE_REP2" />
</Match>

<!-- False positive Unconfirmed cast-->
<Match>
<Or>
<Class name="software.amazon.awssdk.core.client.BaseAsyncClientHandler$InterceptorCallingHttpResponseHandler" />
<Class name="software.amazon.awssdk.core.client.BaseAsyncClientHandler$UnmarshallingSdkHttpResponseHandler" />
<Class name="software.amazon.awssdk.core.internal.http.async.SyncResponseHandlerAdapter" />
</Or>
<Bug pattern="BC_UNCONFIRMED_CAST" />
</Match>

<Match>
<Or>
<Class name="software.amazon.awssdk.awscore.protocol.xml.StandardErrorUnmarshaller" />
<Class name="software.amazon.awssdk.awscore.protocol.xml.LegacyErrorUnmarshaller" />
</Or>
<Bug pattern="BC_UNCONFIRMED_CAST_OF_RETURN_VALUE" />
</Match>

<!-- Currently they look the same and we will revisit this when we add APIG -->
<Match>
<Or>
<Class name="software.amazon.awssdk.core.client.SdkAsyncClientHandler" />
<Class name="software.amazon.awssdk.core.client.SdkSyncClientHandler" />
<Class name="software.amazon.awssdk.awscore.client.handler.AwsSyncClientHandler" />
<Class name="software.amazon.awssdk.awscore.client.handler.AwsAsyncClientHandler" />
</Or>
<Bug pattern="RI_REDUNDANT_INTERFACES" />
</Match>

</FindBugsFilter>
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
class ModelBuilderSpecs {
private final IntermediateModel intermediateModel;
private final ShapeModel shapeModel;
private final ShapeModelSpec shapeModelSpec;
private final TypeProvider typeProvider;
private final PoetExtensions poetExtensions;
private final AccessorsFactory accessorsFactory;
Expand All @@ -51,7 +50,6 @@ class ModelBuilderSpecs {
TypeProvider typeProvider) {
this.intermediateModel = intermediateModel;
this.shapeModel = shapeModel;
this.shapeModelSpec = shapeModelSpec;
this.typeProvider = typeProvider;
this.poetExtensions = new PoetExtensions(this.intermediateModel);
this.accessorsFactory = new AccessorsFactory(this.shapeModel, this.intermediateModel, this.typeProvider, poetExtensions);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

package software.amazon.awssdk.core;

import java.time.Duration;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
Expand All @@ -24,7 +23,6 @@
import java.util.Optional;
import java.util.TreeMap;
import java.util.function.Consumer;

import software.amazon.awssdk.annotations.Immutable;

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

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

private Duration requestExecutionTimeout;

private List<ApiName> apiNames;

protected BuilderImpl() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* just these loggers to get the type of that they want instead of having to enable all logging.
*/
@SdkInternalApi
public class SdkStandardLogger {
public final class SdkStandardLogger {
/**
* Logger providing detailed information on requests/responses. Users can enable this logger to get access to AWS request IDs
* for responses, individual requests and parameters sent to AWS, etc.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ private interface ResponseHandlerFactory<ReturnT> extends
Function<HttpResponseAdapter, SdkHttpResponseHandler<ReturnT>> {
}

private static class InterceptorCallingHttpResponseHandler<T> implements SdkHttpResponseHandler<T> {
private static final class InterceptorCallingHttpResponseHandler<T> implements SdkHttpResponseHandler<T> {
private final SdkHttpResponseHandler<T> delegate;
private final ExecutionContext context;

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

private final AsyncRequestBody asyncRequestBody;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,6 @@ public Builder advancedOptions(Map<SdkAdvancedAsyncClientOption<?>, ?> advancedO
return this;
}

private Builder advancedOptions(AttributeMap.Builder attributeMap) {
this.advancedOptions = attributeMap;
return this;
}

public void setAdvancedOptions(Map<SdkAdvancedAsyncClientOption<?>, Object> advancedOptions) {
advancedOptions(advancedOptions);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
*/
@NotThreadSafe
@SdkProtectedApi
public class ExecutionContext implements ToCopyableBuilder<ExecutionContext.Builder, ExecutionContext> {
public final class ExecutionContext implements ToCopyableBuilder<ExecutionContext.Builder, ExecutionContext> {
private final Signer signer;
private InterceptorContext interceptorContext;
private final ExecutionInterceptorChain interceptorChain;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
* RequestPipeline} implementations by {@link RequestPipelineBuilder}.
*/
@SdkInternalApi
public class HttpClientDependencies implements SdkAutoCloseable {
public final class HttpClientDependencies implements SdkAutoCloseable {
private final SdkClientConfiguration clientConfiguration;
private final CapacityManager capacityManager;
private final ClientExecutionTimer clientExecutionTimer;
Expand Down Expand Up @@ -87,7 +87,7 @@ public void updateTimeOffset(int timeOffset) {
}

@Override
public final void close() {
public void close() {
this.clientConfiguration.close();
this.clientExecutionTimer.close();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import software.amazon.awssdk.annotations.Immutable;
import software.amazon.awssdk.annotations.SdkInternalApi;
import software.amazon.awssdk.core.internal.http.HttpClientDependencies;
import software.amazon.awssdk.core.internal.http.HttpClientDependencies;
import software.amazon.awssdk.core.internal.http.RequestExecutionContext;

/**
Expand All @@ -36,11 +35,11 @@
*/
@Immutable
@SdkInternalApi
public class RequestPipelineBuilder<InputT, OutputT> {
public final class RequestPipelineBuilder<InputT, OutputT> {

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

RequestPipelineBuilder(Function<HttpClientDependencies, RequestPipeline<InputT, OutputT>> pipelineFactory) {
private RequestPipelineBuilder(Function<HttpClientDependencies, RequestPipeline<InputT, OutputT>> pipelineFactory) {
this.pipelineFactory = pipelineFactory;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@
/**
* Wrapper around the pipeline for a single request to provide retry functionality.
*/
public class AsyncRetryableStage<OutputT> implements RequestPipeline<SdkHttpFullRequest, CompletableFuture<Response<OutputT>>> {
public final class AsyncRetryableStage<OutputT> implements RequestPipeline<SdkHttpFullRequest,
CompletableFuture<Response<OutputT>>> {

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,11 @@ public class ClientExecutionTimedStage<OutputT> implements RequestToResponsePipe

private final RequestPipeline<SdkHttpFullRequest, Response<OutputT>> wrapped;
private final ClientExecutionTimer clientExecutionTimer;
private final SdkClientConfiguration clientConfig;

public ClientExecutionTimedStage(HttpClientDependencies dependencies,
RequestPipeline<SdkHttpFullRequest, Response<OutputT>> wrapped) {
this.wrapped = wrapped;
this.clientExecutionTimer = dependencies.clientExecutionTimer();
this.clientConfig = dependencies.clientConfiguration();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
/**
* Delegate to the HTTP implementation to make an HTTP request and receive the response.
*/
public class MakeAsyncHttpRequestStage<OutputT>
public final class MakeAsyncHttpRequestStage<OutputT>
implements RequestPipeline<SdkHttpFullRequest, CompletableFuture<Response<OutputT>>> {

private static final Logger log = LoggerFactory.getLogger(MakeAsyncHttpRequestStage.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
/**
* Wrapper around the pipeline for a single request to provide retry functionality.
*/
public class RetryableStage<OutputT> implements RequestToResponsePipeline<OutputT> {
public final class RetryableStage<OutputT> implements RequestToResponsePipeline<OutputT> {

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* Dummy implementation of {@link ClientExecutionAbortTrackerTask} used when the timer is disabled
* for a request
*/
public class NoOpClientExecutionAbortTrackerTask implements ClientExecutionAbortTrackerTask {
public final class NoOpClientExecutionAbortTrackerTask implements ClientExecutionAbortTrackerTask {

public static final NoOpClientExecutionAbortTrackerTask INSTANCE = new NoOpClientExecutionAbortTrackerTask();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
* and additional directives about how to transform it (i.e. is it binary data, should it be auto generated, etc).
*/
@SdkProtectedApi
public class MarshallingInfo<T> {
public final class MarshallingInfo<T> {

private final MarshallingType<T> marshallingType;
private final String marshallLocationName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* Static information about an API operation used to marshall it correctly.
*/
@SdkProtectedApi
public class OperationInfo {
public final class OperationInfo {

private final String requestUri;
private final HttpMethodName httpMethodName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
* Dependencies needed by implementations of {@link JsonMarshaller}.
*/
@SdkInternalApi
public class JsonMarshallerContext {
public final class JsonMarshallerContext {

private final StructuredJsonGenerator jsonGenerator;
private final JsonProtocolMarshaller protocolHandler;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import software.amazon.awssdk.core.protocol.StructuredPojo;

@SdkInternalApi
public class MarshallerRegistry {
public final class MarshallerRegistry {

private final Map<MarshallLocation, Map<MarshallingType, JsonMarshaller<?>>> marshallers;
private final Set<MarshallingType<?>> marshallingTypes;
Expand Down
Loading

0 comments on commit 16dafbc

Please sign in to comment.