Skip to content

Commit 94353f8

Browse files
committed
Fixes and checkstyle issues
1 parent 3c2f67f commit 94353f8

File tree

32 files changed

+344
-374
lines changed

32 files changed

+344
-374
lines changed

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,14 @@
2626
<suppress checks=".*"
2727
files=".*[\\/]generated-sources[\\/].+\.java$"/>
2828

29+
<!-- TODO want to contribute this back to Netty -->
30+
<suppress checks=".*"
31+
files=".*BetterFixedChannelPool\.java$"/>
32+
33+
<!-- Kinesis has some generated code in source for H2 which fails checkstyle -->
34+
<suppress checks=".*"
35+
files=".*[\\/]software/amazon/awssdk/services/kinesis[\\/].+\.java$"/>
36+
2937
<!-- Assumes getter/setter match JSON property -->
3038
<suppress checks="AbbreviationAsWordInName"
3139
files=".*[\\/]software[\\/]amazon[\\/]awssdk[\\/]services[\\/]s3[\\/]event[\\/]S3EventNotification.java$"/>

core/src/main/java/software/amazon/awssdk/core/async/BaseAsyncResponseTransformer.java

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
11
/*
2-
* Copyright 2012-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
* Copyright 2010-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
33
*
4-
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
5-
* the License. A copy of the License is located at
4+
* Licensed under the Apache License, Version 2.0 (the "License").
5+
* You may not use this file except in compliance with the License.
6+
* A copy of the License is located at
67
*
7-
* http://aws.amazon.com/apache2.0
8+
* http://aws.amazon.com/apache2.0
89
*
9-
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
10-
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
11-
* and limitations under the License.
10+
* or in the "license" file accompanying this file. This file is distributed
11+
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12+
* express or implied. See the License for the specific language governing
13+
* permissions and limitations under the License.
1214
*/
13-
package software.amazon.awssdk.core.async;
1415

15-
import java.nio.ByteBuffer;
16-
import org.reactivestreams.Publisher;
17-
import org.reactivestreams.Subscription;
16+
package software.amazon.awssdk.core.async;
1817

1918
/**
2019
* Callback interface to handle a streaming asynchronous response that produces a certain type of event.

core/src/main/java/software/amazon/awssdk/core/auth/Aws4Signer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public class Aws4Signer extends AbstractAwsSigner
5555

5656
private static final int SIGNER_CACHE_MAX_SIZE = 300;
5757
private static final FifoCache<SignerKey> SIGNER_CACHE = new FifoCache<>(SIGNER_CACHE_MAX_SIZE);
58-
private static final List<String> LIST_OF_HEADERS_TO_IGNORE_IN_LOWER_CASE = Arrays.asList("connection", "x-amzn-trace-id" );
58+
private static final List<String> LIST_OF_HEADERS_TO_IGNORE_IN_LOWER_CASE = Arrays.asList("connection", "x-amzn-trace-id");
5959

6060
/**
6161
* Service name override for use when the endpoint can't be used to

core/src/main/java/software/amazon/awssdk/core/flow/FlowPublisher.java

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
/*
2-
* Copyright 2012-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
* Copyright 2010-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
33
*
4-
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
5-
* the License. A copy of the License is located at
4+
* Licensed under the Apache License, Version 2.0 (the "License").
5+
* You may not use this file except in compliance with the License.
6+
* A copy of the License is located at
67
*
7-
* http://aws.amazon.com/apache2.0
8+
* http://aws.amazon.com/apache2.0
89
*
9-
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
10-
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
11-
* and limitations under the License.
10+
* or in the "license" file accompanying this file. This file is distributed
11+
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12+
* express or implied. See the License for the specific language governing
13+
* permissions and limitations under the License.
1214
*/
15+
1316
package software.amazon.awssdk.core.flow;
1417

1518
import java.util.Iterator;

core/src/main/java/software/amazon/awssdk/core/flow/FlowResponseTransformer.java

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
/*
2-
* Copyright 2012-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
* Copyright 2010-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
33
*
4-
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
5-
* the License. A copy of the License is located at
4+
* Licensed under the Apache License, Version 2.0 (the "License").
5+
* You may not use this file except in compliance with the License.
6+
* A copy of the License is located at
67
*
7-
* http://aws.amazon.com/apache2.0
8+
* http://aws.amazon.com/apache2.0
89
*
9-
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
10-
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
11-
* and limitations under the License.
10+
* or in the "license" file accompanying this file. This file is distributed
11+
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12+
* express or implied. See the License for the specific language governing
13+
* permissions and limitations under the License.
1214
*/
15+
1316
package software.amazon.awssdk.core.flow;
1417

1518
import org.reactivestreams.Publisher;

core/src/main/java/software/amazon/awssdk/core/flow/ResponseIterator.java

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
/*
2-
* Copyright 2012-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
* Copyright 2010-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
33
*
4-
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
5-
* the License. A copy of the License is located at
4+
* Licensed under the Apache License, Version 2.0 (the "License").
5+
* You may not use this file except in compliance with the License.
6+
* A copy of the License is located at
67
*
7-
* http://aws.amazon.com/apache2.0
8+
* http://aws.amazon.com/apache2.0
89
*
9-
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
10-
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
11-
* and limitations under the License.
10+
* or in the "license" file accompanying this file. This file is distributed
11+
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12+
* express or implied. See the License for the specific language governing
13+
* permissions and limitations under the License.
1214
*/
15+
1316
package software.amazon.awssdk.core.flow;
1417

1518
import java.util.Iterator;

core/src/main/java/software/amazon/awssdk/core/flow/SubscriberIterator.java

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
/*
2-
* Copyright 2012-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
* Copyright 2010-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
33
*
4-
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
5-
* the License. A copy of the License is located at
4+
* Licensed under the Apache License, Version 2.0 (the "License").
5+
* You may not use this file except in compliance with the License.
6+
* A copy of the License is located at
67
*
7-
* http://aws.amazon.com/apache2.0
8+
* http://aws.amazon.com/apache2.0
89
*
9-
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
10-
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
11-
* and limitations under the License.
10+
* or in the "license" file accompanying this file. This file is distributed
11+
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12+
* express or implied. See the License for the specific language governing
13+
* permissions and limitations under the License.
1214
*/
15+
1316
package software.amazon.awssdk.core.flow;
1417

1518
import java.util.Iterator;
@@ -32,6 +35,10 @@
3235
@ReviewBeforeRelease("This was copied from RxJava. Take another pass")
3336
public final class SubscriberIterator<T> implements Subscriber<T>, Iterator<T> {
3437

38+
@SuppressWarnings("rawtypes")
39+
static final AtomicReferenceFieldUpdater<SubscriberIterator, Subscription> S =
40+
AtomicReferenceFieldUpdater.newUpdater(SubscriberIterator.class, Subscription.class, "s");
41+
3542
/**
3643
* Queue to buffer items and block in the iterator until the next item is available.
3744
*/
@@ -66,10 +73,6 @@ public final class SubscriberIterator<T> implements Subscriber<T>, Iterator<T> {
6673

6774
private volatile Subscription s;
6875

69-
@SuppressWarnings("rawtypes")
70-
static final AtomicReferenceFieldUpdater<SubscriberIterator, Subscription> S =
71-
AtomicReferenceFieldUpdater.newUpdater(SubscriberIterator.class, Subscription.class, "s");
72-
7376
/**
7477
* Set to true when all items have been published or an error occurs.
7578
*/

core/src/main/java/software/amazon/awssdk/core/flow/SubscriptionHelper.java

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
/*
2-
* Copyright 2012-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
* Copyright 2010-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
33
*
4-
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
5-
* the License. A copy of the License is located at
4+
* Licensed under the Apache License, Version 2.0 (the "License").
5+
* You may not use this file except in compliance with the License.
6+
* A copy of the License is located at
67
*
7-
* http://aws.amazon.com/apache2.0
8+
* http://aws.amazon.com/apache2.0
89
*
9-
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
10-
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
11-
* and limitations under the License.
10+
* or in the "license" file accompanying this file. This file is distributed
11+
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12+
* express or implied. See the License for the specific language governing
13+
* permissions and limitations under the License.
1214
*/
15+
1316
package software.amazon.awssdk.core.flow;
1417

1518
import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
@@ -23,6 +26,9 @@
2326
@ReviewBeforeRelease("This was copied from RxJava. Review more carefully")
2427
public class SubscriptionHelper {
2528

29+
private SubscriptionHelper(){
30+
}
31+
2632
/**
2733
* A singleton Subscription that represents a cancelled subscription instance and should not be leaked to clients as it
2834
* represents a terminal state. <br> If algorithms need to hand out a subscription, replace this with {@code
@@ -82,7 +88,7 @@ public static <F> boolean set(AtomicReferenceFieldUpdater<F, Subscription> field
8288
* @param s the subscription to set once
8389
* @return true if successful, false if the target was not empty or has been cancelled
8490
*/
85-
public static <F> boolean setOnce(AtomicReferenceFieldUpdater<F, Subscription> field, F instance, Subscription s) {
91+
static <F> boolean setOnce(AtomicReferenceFieldUpdater<F, Subscription> field, F instance, Subscription s) {
8692
Subscription a = field.get(instance);
8793
if (a == SubscriptionHelper.cancelled()) {
8894
s.cancel();

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ public void updateTimeOffset(int timeOffset) {
8383
public final void close() {
8484
doClose();
8585
this.clientExecutionTimer.close();
86-
doClose();
8786
}
8887

8988
/**

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public class ApplyTransactionIdStage implements MutableRequestToRequestPipeline
3737

3838
@Override
3939
public SdkHttpFullRequest.Builder execute(SdkHttpFullRequest.Builder request, RequestExecutionContext context)
40-
throws Exception {
40+
throws Exception {
4141
InterruptMonitor.checkInterrupted();
4242
return request.header(HEADER_SDK_TRANSACTION_ID, new UUID(random.nextLong(), random.nextLong()).toString());
4343
}

core/src/main/java/software/amazon/awssdk/core/protocol/json/SdkJsonProtocolFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121
import software.amazon.awssdk.annotations.SdkTestInternalApi;
2222
import software.amazon.awssdk.annotations.ThreadSafe;
2323
import software.amazon.awssdk.core.AwsSystemSetting;
24-
import software.amazon.awssdk.core.http.HttpResponse;
2524
import software.amazon.awssdk.core.SdkRequest;
2625
import software.amazon.awssdk.core.exception.SdkServiceException;
26+
import software.amazon.awssdk.core.http.HttpResponse;
2727
import software.amazon.awssdk.core.http.HttpResponseHandler;
2828
import software.amazon.awssdk.core.protocol.OperationInfo;
2929
import software.amazon.awssdk.core.protocol.Protocol;

http-client-spi/src/main/java/software/amazon/awssdk/http/Protocol.java

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
/*
2-
* Copyright 2012-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
* Copyright 2010-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
33
*
4-
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
5-
* the License. A copy of the License is located at
4+
* Licensed under the Apache License, Version 2.0 (the "License").
5+
* You may not use this file except in compliance with the License.
6+
* A copy of the License is located at
67
*
7-
* http://aws.amazon.com/apache2.0
8+
* http://aws.amazon.com/apache2.0
89
*
9-
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
10-
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
11-
* and limitations under the License.
10+
* or in the "license" file accompanying this file. This file is distributed
11+
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12+
* express or implied. See the License for the specific language governing
13+
* permissions and limitations under the License.
1214
*/
15+
1316
package software.amazon.awssdk.http;
1417

1518
public enum Protocol {

http-clients/apache-client/src/main/java/software/amazon/awssdk/http/apache/internal/impl/ApacheConnectionManagerFactory.java

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import java.io.IOException;
2121
import java.net.InetSocketAddress;
2222
import java.net.Socket;
23-
import java.net.UnknownHostException;
2423
import java.security.KeyManagementException;
2524
import java.security.NoSuchAlgorithmException;
2625
import java.security.cert.CertificateException;
@@ -77,10 +76,9 @@ public HttpClientConnectionManager create(ApacheSdkHttpClientFactory configurati
7776
}
7877

7978
private ConnectionSocketFactory getPreferredSocketFactory(AttributeMap standardOptions) {
80-
return new TrustingSocketFactory();
8179
// TODO v2 custom socket factory
82-
// return new SdkTlsSocketFactory(getPreferredSslContext(),
83-
// getHostNameVerifier(standardOptions));
80+
return new SdkTlsSocketFactory(getPreferredSslContext(),
81+
getHostNameVerifier(standardOptions));
8482
}
8583

8684
private static SSLContext getPreferredSslContext() {
@@ -132,7 +130,7 @@ private static class TrustingSocketFactory implements
132130

133131
private SSLContext sslcontext = null;
134132

135-
private static SSLContext createSSLContext() throws IOException {
133+
private static SSLContext createSslContext() throws IOException {
136134
try {
137135
SSLContext context = SSLContext.getInstance("TLS");
138136
context.init(null, new TrustManager[] {new TrustingX509TrustManager()}, null);
@@ -143,18 +141,19 @@ private static SSLContext createSSLContext() throws IOException {
143141
}
144142

145143
@Override
146-
public Socket createLayeredSocket(Socket socket, String target, int port, HttpContext context) throws IOException, UnknownHostException {
147-
return getSSLContext().getSocketFactory().createSocket(socket,
144+
public Socket createLayeredSocket(Socket socket, String target, int port, HttpContext context) throws IOException {
145+
return getSslContext().getSocketFactory().createSocket(socket,
148146
target, port, true);
149147
}
150148

151149
@Override
152150
public Socket createSocket(HttpContext context) throws IOException {
153-
return getSSLContext().getSocketFactory().createSocket();
151+
return getSslContext().getSocketFactory().createSocket();
154152
}
155153

156154
@Override
157-
public Socket connectSocket(int connectTimeout, Socket sock, HttpHost host, InetSocketAddress remoteAddress, InetSocketAddress localAddress, HttpContext context) throws IOException {
155+
public Socket connectSocket(int connectTimeout, Socket sock, HttpHost host, InetSocketAddress remoteAddress,
156+
InetSocketAddress localAddress, HttpContext context) throws IOException {
158157

159158
SSLSocket sslsock = (SSLSocket) ((sock != null) ? sock :
160159
createSocket(context));
@@ -169,9 +168,9 @@ public Socket connectSocket(int connectTimeout, Socket sock, HttpHost host, Inet
169168
return sslsock;
170169
}
171170

172-
private SSLContext getSSLContext() throws IOException {
171+
private SSLContext getSslContext() throws IOException {
173172
if (this.sslcontext == null) {
174-
this.sslcontext = createSSLContext();
173+
this.sslcontext = createSslContext();
175174
}
176175
return this.sslcontext;
177176
}
@@ -190,14 +189,12 @@ public X509Certificate[] getAcceptedIssuers() {
190189
}
191190

192191
@Override
193-
public void checkServerTrusted(X509Certificate[] chain, String authType)
194-
throws CertificateException {
192+
public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException {
195193
// No-op, to trust all certs
196194
}
197195

198196
@Override
199-
public void checkClientTrusted(X509Certificate[] chain, String authType)
200-
throws CertificateException {
197+
public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException {
201198
// No-op, to trust all certs
202199
}
203200
}

http-clients/netty-nio-client/src/main/java/software/amazon/awssdk/http/nio/netty/NettyNioAsyncHttpClient.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,10 @@ protected ChannelPool newPool(URI key) {
7878
.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, configuration.connectionTimeout())
7979
.option(ChannelOption.TCP_NODELAY, true)
8080
.remoteAddress(key.getHost(), key.getPort());
81+
ChannelPipelineInitializer pipelineInitializer = new ChannelPipelineInitializer(sslContext(key.getScheme()));
8182
return BetterFixedChannelPool.builder()
8283
.channelPool(new SimpleChannelPool(bootstrap,
83-
new ChannelPipelineInitializer(sslContext(key.getScheme())),
84+
pipelineInitializer,
8485
ChannelHealthChecker.ACTIVE))
8586
.executor(bootstrap.config().group().next())
8687
.acquireTimeoutAction(BetterFixedChannelPool.AcquireTimeoutAction.FAIL)

0 commit comments

Comments
 (0)