Skip to content

Commit 0958a37

Browse files
author
AWS
committed
AWS SDK for Android 2.4.1
1 parent 66de079 commit 0958a37

File tree

718 files changed

+39993
-6413
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

718 files changed

+39993
-6413
lines changed

CHANGELOG.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
11
# Change Log - AWS SDK for Android
2+
## [Release 2.4.1](https://github.com/aws/aws-sdk-android/releases/tag/release_v2.4.1)
3+
4+
### New Features:
5+
- **Support for Amazon Cloudwatch Logs**: Amazon CloudWatch is a monitoring service for AWS cloud resources and the applications you run on AWS. You can use Amazon CloudWatch to collect and track metrics, collect and monitor log files, and set alarms.
6+
7+
### Bug Fixes:
8+
- **Amazon IoT**: fix an issue which triggers `NetworkOnMainThreadException` when calling `reconnectToSession()`. See [issue #261](https://github.com/aws/aws-sdk-android/issues/261)
9+
- **Amazon S3**: fixed maven dependencies. See [issue #276](https://github.com/aws/aws-sdk-android/issues/276) & [issue #268](https://github.com/aws/aws-sdk-android/issues/268)
10+
- **Amazon S3**: fixed an issue which caused resource path to be incorrectly encoded.See [AWS Forum Post](https://forums.aws.amazon.com/thread.jspa?threadID=252898)
11+
- **General**: checkstyle fixes across the sdk.
12+
- **General**: move all sdk's to use commons logging instead of LogCat.
13+
214
## [Release 2.4.0](https://github.com/aws/aws-sdk-android/releases/tag/release_v2.4.0) (03/21/2017)
315

416
### Improvements:
@@ -36,7 +48,7 @@
3648
- **Amazon Pinpoint**: Fixed a bug that caused a crash when opening a deep link. See [issue #246](https://github.com/aws/aws-sdk-android/pull/246).
3749
- **Amazon Lex**: Fix incorrect comparison for dialog states. See [issue #245](https://github.com/aws/aws-sdk-android/pull/245).
3850

39-
## [Release 2.3.8](https://github.com/aws/aws-sdk-android/release/tag/release_v2.3.8) (12/20/2016)
51+
## [Release 2.3.8] (https://github.com/aws/aws-sdk-android/release/tag/release_v2.3.8) (12/20/2016)
4052

4153
### Bug Fixes:
4254

@@ -361,4 +373,4 @@ Two new exceptions added for getSession API. These exceptions have been added to
361373

362374
### Bug Fixes
363375
- **Amazon S3**: Fixed an issue that occurs when required headers are not properly signed. This issue affects S3 in two regions: Frankfurt (eu-central-1) and China (cn-north-1). [#42](https://github.com/aws/aws-sdk-android/issues/42)
364-
- **AWS Core Runtime Library**: Fixed an issue in Maven distribution where an incorrect version string is set in "User-Agent".
376+
- **AWS Core Runtime Library**: Fixed an issue in Maven distribution where an incorrect version string is set in "User-Agent".

aws-android-sdk-apigateway-core/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@
1212
<parent>
1313
<groupId>com.amazonaws</groupId>
1414
<artifactId>aws-android-sdk-pom</artifactId>
15-
<version>2.4.0</version>
15+
<version>2.4.1</version>
1616
</parent>
1717

1818
<dependencies>
1919
<dependency>
2020
<groupId>com.amazonaws</groupId>
2121
<artifactId>aws-android-sdk-core</artifactId>
2222
<optional>false</optional>
23-
<version>2.4.0</version>
23+
<version>2.4.1</version>
2424
</dependency>
2525
</dependencies>
2626

aws-android-sdk-apigateway-core/src/main/java/com/amazonaws/mobileconnectors/apigateway/ApiClientException.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,21 @@ public class ApiClientException extends AmazonServiceException {
2424

2525
private static final long serialVersionUID = 1L;
2626

27+
/**
28+
* Constructor.
29+
*
30+
* @param errorMessage the error message.
31+
*/
2732
public ApiClientException(String errorMessage) {
2833
super(errorMessage);
2934
}
3035

36+
/**
37+
* Constructor.
38+
*
39+
* @param errorMessage the error message.
40+
* @param cause the root cause.
41+
*/
3142
public ApiClientException(String errorMessage, Exception cause) {
3243
super(errorMessage, cause);
3344
}

aws-android-sdk-apigateway-core/src/main/java/com/amazonaws/mobileconnectors/apigateway/ApiClientFactory.java

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ public class ApiClientFactory {
3333
private static final String AMAZON_API_GATEWAY_SERVICE_NAME = "execute-api";
3434
// endpoint pattern for extracting region out of an endpoint
3535
// e.g. https://my-api-id.execute-api.region-id.amazonaws.com/stage
36-
private static Pattern ENDPOINT_PATTERN = Pattern.compile("^https?://\\w+.execute-api.([a-z0-9-]+).amazonaws.com/.*");
36+
private static final Pattern ENDPOINT_PATTERN = Pattern
37+
.compile("^https?://\\w+.execute-api.([a-z0-9-]+).amazonaws.com/.*");
3738

3839
private String endpoint;
3940
private String apiKey;
@@ -47,6 +48,7 @@ public class ApiClientFactory {
4748
* @param endpoint endpoint url
4849
* @return the factory itself for chaining
4950
*/
51+
@SuppressWarnings("checkstyle:hiddenfield")
5052
public ApiClientFactory endpoint(String endpoint) {
5153
this.endpoint = endpoint;
5254
return this;
@@ -58,6 +60,7 @@ public ApiClientFactory endpoint(String endpoint) {
5860
* @param apiKey to send in header
5961
* @return the factory itself for chaining
6062
*/
63+
@SuppressWarnings("checkstyle:hiddenfield")
6164
public ApiClientFactory apiKey(String apiKey) {
6265
this.apiKey = apiKey;
6366
return this;
@@ -70,6 +73,7 @@ public ApiClientFactory apiKey(String apiKey) {
7073
* @param region a region string
7174
* @return the factory itself for chaining
7275
*/
76+
@SuppressWarnings("checkstyle:hiddenfield")
7377
public ApiClientFactory region(String region) {
7478
this.regionOverride = region;
7579
return this;
@@ -81,6 +85,7 @@ public ApiClientFactory region(String region) {
8185
* @param clientConfiguration Configuration to use
8286
* @return the factory itself for chaining
8387
*/
88+
@SuppressWarnings("checkstyle:hiddenfield")
8489
public ApiClientFactory clientConfiguration(ClientConfiguration clientConfiguration) {
8590
this.clientConfiguration = clientConfiguration;
8691
return this;
@@ -92,6 +97,7 @@ public ApiClientFactory clientConfiguration(ClientConfiguration clientConfigurat
9297
* @param provider an AWS credentials provider
9398
* @return the factory itself for chaining
9499
*/
100+
@SuppressWarnings("checkstyle:hiddenfield")
95101
public ApiClientFactory credentialsProvider(AWSCredentialsProvider provider) {
96102
this.provider = provider;
97103
return this;
@@ -100,20 +106,22 @@ public ApiClientFactory credentialsProvider(AWSCredentialsProvider provider) {
100106
/**
101107
* Instantiates a client for the given API.
102108
*
109+
* @param <T> the api client interface.
103110
* @param apiClass API class defined in API Gateway.
104-
* @return a client for the given API
111+
* @return a client for the given API.
105112
*/
113+
@SuppressWarnings("checkstyle:hiddenfield")
106114
public <T> T build(Class<T> apiClass) {
107115
if (apiClass == null) {
108116
throw new IllegalArgumentException("Missing API class");
109117
}
110-
String endpoint = getEndpoint(apiClass);
118+
final String endpoint = getEndpoint(apiClass);
111119
if (endpoint == null) {
112120
throw new IllegalArgumentException("Missing endpoint information");
113121
}
114-
String apiName = getApiName(apiClass);
115-
ApiClientHandler handler = getHandler(endpoint, apiName);
116-
Object proxy = Proxy.newProxyInstance(apiClass.getClassLoader(),
122+
final String apiName = getApiName(apiClass);
123+
final ApiClientHandler handler = getHandler(endpoint, apiName);
124+
final Object proxy = Proxy.newProxyInstance(apiClass.getClassLoader(),
117125
new Class<?>[] {
118126
apiClass
119127
}, handler);
@@ -127,11 +135,12 @@ public <T> T build(Class<T> apiClass) {
127135
* @param apiName API class name
128136
* @return an invocation handler
129137
*/
138+
@SuppressWarnings("checkstyle:hiddenfield")
130139
ApiClientHandler getHandler(String endpoint, String apiName) {
131-
Signer signer = provider == null ? null : getSigner(getRegion(endpoint));
140+
final Signer signer = provider == null ? null : getSigner(getRegion(endpoint));
132141

133142
// Ensure we always pass a configuration to the handler
134-
ClientConfiguration configuration = (clientConfiguration == null) ? new ClientConfiguration() : clientConfiguration;
143+
final ClientConfiguration configuration = (clientConfiguration == null) ? new ClientConfiguration() : clientConfiguration;
135144

136145
return new ApiClientHandler(endpoint, apiName, signer, provider, apiKey, configuration);
137146
}
@@ -143,7 +152,7 @@ ApiClientHandler getHandler(String endpoint, String apiName) {
143152
* @return endpoint
144153
*/
145154
String getEndpoint(Class<?> apiClass) {
146-
Service service = apiClass.getAnnotation(Service.class);
155+
final Service service = apiClass.getAnnotation(Service.class);
147156
if (service == null) {
148157
throw new IllegalArgumentException("Can't find annotation Service");
149158
}
@@ -168,7 +177,7 @@ String getApiName(Class<?> apiClass) {
168177
* @return signer
169178
*/
170179
Signer getSigner(String region) {
171-
AWS4Signer signer = new AWS4Signer();
180+
final AWS4Signer signer = new AWS4Signer();
172181
signer.setServiceName(AMAZON_API_GATEWAY_SERVICE_NAME);
173182
signer.setRegionName(region);
174183
return signer;
@@ -180,11 +189,12 @@ Signer getSigner(String region) {
180189
* @param endpoint endpoint string
181190
* @return region string
182191
*/
192+
@SuppressWarnings("checkstyle:hiddenfield")
183193
String getRegion(String endpoint) {
184194
if (regionOverride != null) {
185195
return regionOverride;
186196
}
187-
Matcher m = ENDPOINT_PATTERN.matcher(endpoint);
197+
final Matcher m = ENDPOINT_PATTERN.matcher(endpoint);
188198
if (m.matches()) {
189199
return m.group(1);
190200
}

aws-android-sdk-apigateway-core/src/main/java/com/amazonaws/mobileconnectors/apigateway/ApiClientHandler.java

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,15 @@
5656
class ApiClientHandler implements InvocationHandler {
5757

5858

59-
private static final Gson gson = new GsonBuilder()
59+
private static final Gson GSON_WITH_DATE_FORMATTER = new GsonBuilder()
6060
.registerTypeAdapter(Date.class, new DateDeserializer(new String[] {
61-
DateUtils.ISO8601_DATE_PATTERN, DateUtils.ALTERNATE_ISO8601_DATE_PATTERN,
62-
DateUtils.COMPRESSED_DATE_PATTERN, DateUtils.RFC822_DATE_PATTERN
61+
DateUtils.ISO8601_DATE_PATTERN, DateUtils.ALTERNATE_ISO8601_DATE_PATTERN,
62+
DateUtils.COMPRESSED_DATE_PATTERN, DateUtils.RFC822_DATE_PATTERN
6363
})).create();
6464

65+
private static final int HTTP_RESPONSE_OK = 200;
66+
private static final int HTTP_RESPONSE_LAST_SUCCESS_STATUSCODE = 300;
67+
6568
private final String endpoint;
6669
private final String apiName;
6770
private final Signer signer;
@@ -162,7 +165,7 @@ Request<?> buildRequest(Method method, Object[] args) {
162165
if (content != null) {
163166
throw new IllegalStateException("Can't have more than one Body");
164167
}
165-
content = args[i] == null ? null : gson.toJson(args[i]);
168+
content = args[i] == null ? null : GSON_WITH_DATE_FORMATTER.toJson(args[i]);
166169
continue;
167170
}
168171

@@ -271,12 +274,12 @@ Object handleResponse(HttpResponse response, Method method) throws Throwable {
271274
final int code = response.getStatusCode();
272275
final InputStream content = response.getContent();
273276
// successful request if code is 2xx
274-
if (code >= 200 && code < 300) {
277+
if (code >= HTTP_RESPONSE_OK && code < HTTP_RESPONSE_LAST_SUCCESS_STATUSCODE) {
275278
final Type t = method.getReturnType();
276279
if (t != void.class && content != null) {
277280
final Reader reader = new InputStreamReader(response.getContent(),
278281
StringUtils.UTF8);
279-
final Object obj = gson.fromJson(reader, t);
282+
final Object obj = GSON_WITH_DATE_FORMATTER.fromJson(reader, t);
280283
reader.close();
281284
return obj;
282285
} else {
@@ -301,7 +304,7 @@ Object handleResponse(HttpResponse response, Method method) throws Throwable {
301304

302305
boolean isExecuteMethod(Method method) {
303306
final Operation op = method.getAnnotation(Operation.class);
304-
return op == null && method.getName().equalsIgnoreCase("execute")
307+
return op == null && "execute".equalsIgnoreCase(method.getName())
305308
&& method.getReturnType().isAssignableFrom(ApiResponse.class)
306309
&& method.getParameterTypes().length == 1
307310
&& method.getParameterTypes()[0].isAssignableFrom(ApiRequest.class);

aws-android-sdk-apigateway-core/src/main/java/com/amazonaws/mobileconnectors/apigateway/ApiRequest.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ public ApiRequest() {
5353
/**
5454
* Sets all headers, clearing any existing ones.
5555
*
56+
* @param headers A map of all http headers
5657
* @return the updated request object.
5758
*/
5859
public ApiRequest withHeaders(Map<String, String> headers) {
@@ -63,8 +64,8 @@ public ApiRequest withHeaders(Map<String, String> headers) {
6364
/**
6465
* Sets the header in the request.
6566
*
66-
* @param header
67-
* @param value
67+
* @param header the http header name.
68+
* @param value the http header value.
6869
* @return the updated request object.
6970
*/
7071
public ApiRequest addHeader(String header, String value) {
@@ -104,6 +105,7 @@ public String getPath() {
104105
/**
105106
* Sets all parameters, clearing any existing values.
106107
*
108+
* @param parameters the http request parameters.
107109
* @return the updated request object.
108110
*/
109111
public ApiRequest withParameters(Map<String, String> parameters) {
@@ -123,8 +125,8 @@ public Map<String, String> getParameters() {
123125
/**
124126
* Set parameters with name and value.
125127
*
126-
* @param name
127-
* @param value
128+
* @param name the parameter name.
129+
* @param value the parameter value.
128130
* @return the updated request object.
129131
*/
130132
public ApiRequest withParameter(String name, String value) {
@@ -144,7 +146,7 @@ public ApiRequest withHttpMethod(HttpMethodName httpMethod) {
144146
}
145147

146148
/**
147-
* @return
149+
* @return the {@link HttpMethodName}
148150
*/
149151
public HttpMethodName getHttpMethod() {
150152
return request.getHttpMethod();
@@ -167,7 +169,7 @@ public ApiRequest withBody(InputStream body) {
167169
* Sets the optional stream containing the payload data from the byte array
168170
* to include for this request. Not all requests will contain payload data.
169171
*
170-
* @param body
172+
* @param body The request body represented as a array of bytes.
171173
* @return the updated request object.
172174
*/
173175
public ApiRequest withBody(byte[] body) {
@@ -180,7 +182,7 @@ public ApiRequest withBody(byte[] body) {
180182
* content to include for this request. Not all requests will contain
181183
* payload data.
182184
*
183-
* @param body
185+
* @param body the request body represented as a string.
184186
* @return the updated request object.
185187
*/
186188
public ApiRequest withBody(String body) {

aws-android-sdk-apigateway-core/src/main/java/com/amazonaws/mobileconnectors/apigateway/annotation/Operation.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
import java.lang.annotation.RetentionPolicy;
2121
import java.lang.annotation.Target;
2222

23+
/**
24+
* The Http Operation.
25+
*/
2326
@Retention(RetentionPolicy.RUNTIME)
2427
@Target(ElementType.METHOD)
2528
public @interface Operation {

aws-android-sdk-apigateway-core/src/main/java/com/amazonaws/mobileconnectors/apigateway/annotation/Parameter.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,24 @@
2020
import java.lang.annotation.RetentionPolicy;
2121
import java.lang.annotation.Target;
2222

23+
/**
24+
* The request parameter.
25+
*/
2326
@Retention(RetentionPolicy.RUNTIME)
2427
@Target(ElementType.PARAMETER)
2528
public @interface Parameter {
2629
/**
2730
* Name of the parameter.
28-
*
29-
* @return name of the parameter
31+
*
32+
* @return
3033
*/
3134
String name() default "";
3235

3336
/**
3437
* Location of this parameter. Possible values are <tt>header</tt>,
3538
* <tt>path</tt> , and <tt>query</tt>.
36-
*
37-
* @return location of the parameter
39+
*
40+
* @return
3841
*/
3942
String location();
4043
}

aws-android-sdk-apigateway-core/src/main/java/com/amazonaws/mobileconnectors/apigateway/annotation/Service.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,15 @@
2020
import java.lang.annotation.RetentionPolicy;
2121
import java.lang.annotation.Target;
2222

23+
/**
24+
* The APIGateway service.
25+
*/
2326
@Retention(RetentionPolicy.RUNTIME)
2427
@Target(ElementType.TYPE)
2528
public @interface Service {
2629
/**
2730
* Service endpoint.
2831
*
29-
* @return service endpoint
3032
*/
3133
String endpoint();
3234
}

aws-android-sdk-autoscaling/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@
1212
<parent>
1313
<groupId>com.amazonaws</groupId>
1414
<artifactId>aws-android-sdk-pom</artifactId>
15-
<version>2.4.0</version>
15+
<version>2.4.1</version>
1616
</parent>
1717

1818
<dependencies>
1919
<dependency>
2020
<groupId>com.amazonaws</groupId>
2121
<artifactId>aws-android-sdk-core</artifactId>
2222
<optional>false</optional>
23-
<version>2.4.0</version>
23+
<version>2.4.1</version>
2424
</dependency>
2525
</dependencies>
2626

0 commit comments

Comments
 (0)