Skip to content

Commit be5388e

Browse files
committed
Moved Jackson from being an external SDK dependency to an internal dependency.
Jackson-databind was removed from being a dependency (except in the code generator). Jackson-core and Jackson-dataformat-cbor were moved to shaded dependencies. This was done because Jackson versions are not 100% compatible between minor versions and keeping them up to date were problematic for SDK customers. Customers will see a change in artifact sizes. Customers which do not use Jackson-databind outside of the SDK today will see a ~1 MB artifact size decrease. Customers which do use Jackson-databind outside of the SDK will see a ~0.5 MB artifact size increase. This change required breaking inter-module (protected) APIs, so it should not be released outside of an SDK minor version bump. Customers will not be able to use older client versions with this version of the core libraries. Change summary: 1. Added 'jackson-core' and 'jackson-dataformat-cbor' which contain the SDK's shaded versions with the Jackson packages of the same names. 2. Removed 'aws-ion-protocol' module. This was not used by any public AWS services and can be re-added when service support is needed. 3. Added 'json-utils', a library for reading and parsing JSON.
1 parent 361afd8 commit be5388e

File tree

102 files changed

+2159
-4940
lines changed

Some content is hidden

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

102 files changed

+2159
-4940
lines changed

.brazil.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"modules": {
3+
"third-party-jackson-core": {
4+
"artifactType": "JAR",
5+
"includes": ["target/aws-sdk-java-third-party-jackson-core-*.jar"]
6+
},
7+
"third-party-jackson-dataformat-cbor": {
8+
"artifactType": "JAR",
9+
"includes": ["target/aws-sdk-java-third-party-jackson-dataformat-cbor-*.jar"]
10+
}
11+
}
12+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"category": "AWS SDK for Java v2",
3+
"contributor": "",
4+
"type": "feature",
5+
"description": "Moved Jackson from being an external SDK dependency to an internal dependency.\n\nCustomers will see a change in artifact sizes. Customers which do not use Jackson-databind outside of the SDK today will see a ~1 MB artifact size decrease. Customers which do use Jackson-databind outside of the SDK will see a ~0.5 MB artifact size increase.\n\nThis change required breaking inter-module (protected) APIs, so customers will not be able to use older client versions with this version of the core libraries. Customers that have previously added Jackson classes to their module path may need to remove them if Jackson is no longer a runtime dependency of their application."
6+
}

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414
# Maven
1515
target/
1616

17+
# JEnv
18+
.java-version
19+
20+
# Shade
1721
**/dependency-reduced-pom.xml
1822

1923
*.pyc

NOTICE.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ This software includes third party software subject to the following copyrights:
1212
- PKCS#1 PEM encoded private key parsing and utility functions from oauth.googlecode.com - Copyright 1998-2010 AOL Inc.
1313
- Apache Commons Lang - https://github.com/apache/commons-lang
1414
- Netty Reactive Streams - https://github.com/playframework/netty-reactive-streams
15+
- Jackson-core - https://github.com/FasterXML/jackson-core
16+
- Jackson-dataformat-cbor - https://github.com/FasterXML/jackson-dataformats-binary
1517

1618
The licenses for these third party components are included in LICENSE.txt
1719

bom-internal/pom.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,6 @@
8484
<artifactId>jackson-datatype-jsr310</artifactId>
8585
<version>${jackson.version}</version>
8686
</dependency>
87-
<dependency>
88-
<groupId>software.amazon.ion</groupId>
89-
<artifactId>ion-java</artifactId>
90-
<version>${ion.java.version}</version>
91-
</dependency>
9287
<dependency>
9388
<groupId>org.apache.httpcomponents</groupId>
9489
<artifactId>httpclient</artifactId>

bom/pom.xml

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,27 +64,37 @@
6464
</dependency>
6565
<dependency>
6666
<groupId>software.amazon.awssdk</groupId>
67-
<artifactId>auth</artifactId>
67+
<artifactId>json-utils</artifactId>
6868
<version>${awsjavasdk.version}</version>
6969
</dependency>
7070
<dependency>
7171
<groupId>software.amazon.awssdk</groupId>
72-
<artifactId>aws-core</artifactId>
72+
<artifactId>third-party-jackson-core</artifactId>
7373
<version>${awsjavasdk.version}</version>
7474
</dependency>
7575
<dependency>
7676
<groupId>software.amazon.awssdk</groupId>
77-
<artifactId>profiles</artifactId>
77+
<artifactId>third-party-jackson-dataformat-cbor</artifactId>
7878
<version>${awsjavasdk.version}</version>
7979
</dependency>
8080
<dependency>
8181
<groupId>software.amazon.awssdk</groupId>
82-
<artifactId>aws-cbor-protocol</artifactId>
82+
<artifactId>auth</artifactId>
83+
<version>${awsjavasdk.version}</version>
84+
</dependency>
85+
<dependency>
86+
<groupId>software.amazon.awssdk</groupId>
87+
<artifactId>aws-core</artifactId>
88+
<version>${awsjavasdk.version}</version>
89+
</dependency>
90+
<dependency>
91+
<groupId>software.amazon.awssdk</groupId>
92+
<artifactId>profiles</artifactId>
8393
<version>${awsjavasdk.version}</version>
8494
</dependency>
8595
<dependency>
8696
<groupId>software.amazon.awssdk</groupId>
87-
<artifactId>aws-ion-protocol</artifactId>
97+
<artifactId>aws-cbor-protocol</artifactId>
8898
<version>${awsjavasdk.version}</version>
8999
</dependency>
90100
<dependency>

bundle/pom.xml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -70,31 +70,20 @@
7070
<include>com.fasterxml.jackson.jr:*</include>
7171
<include>io.netty:*</include>
7272
<include>com.typesafe.netty:*</include>
73-
<include>com.fasterxml.jackson.core:*</include>
74-
<include>com.fasterxml.jackson.dataformat:jackson-dataformat-cbor</include>
7573
<include>org.apache.httpcomponents:*</include>
7674
<include>org.reactivestreams:*</include>
7775
<include>org.slf4j:*</include>
7876
<include>commons-codec:commons-codec</include>
79-
<include>software.amazon.ion:ion-java</include>
8077
<include>software.amazon.awssdk:*</include>
8178
<include>software.amazon:*</include>
8279
<include>commons-logging:*</include>
8380
</includes>
8481
</artifactSet>
8582
<relocations>
86-
<relocation>
87-
<pattern>com.fasterxml.jackson</pattern>
88-
<shadedPattern>software.amazon.awssdk.thirdparty.com.fasterxml.jackson</shadedPattern>
89-
</relocation>
9083
<relocation>
9184
<pattern>org.apache</pattern>
9285
<shadedPattern>software.amazon.awssdk.thirdparty.org.apache</shadedPattern>
9386
</relocation>
94-
<relocation>
95-
<pattern>software.amazon.ion</pattern>
96-
<shadedPattern>software.amazon.awssdk.thirdparty.ion</shadedPattern>
97-
</relocation>
9887
<relocation>
9988
<pattern>io.netty</pattern>
10089
<shadedPattern>software.amazon.awssdk.thirdparty.io.netty</shadedPattern>

change

Whitespace-only changes.

codegen/pom.xml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,6 @@
102102
<artifactId>aws-cbor-protocol</artifactId>
103103
<version>${awsjavasdk.version}</version>
104104
</dependency>
105-
<dependency>
106-
<groupId>software.amazon.awssdk</groupId>
107-
<artifactId>aws-ion-protocol</artifactId>
108-
<version>${awsjavasdk.version}</version>
109-
</dependency>
110105
<dependency>
111106
<groupId>software.amazon.awssdk</groupId>
112107
<artifactId>aws-query-protocol</artifactId>
@@ -143,6 +138,14 @@
143138
<groupId>com.fasterxml.jackson.jr</groupId>
144139
<artifactId>jackson-jr-stree</artifactId>
145140
</dependency>
141+
<dependency>
142+
<groupId>com.fasterxml.jackson.core</groupId>
143+
<artifactId>jackson-annotations</artifactId>
144+
</dependency>
145+
<dependency>
146+
<groupId>com.fasterxml.jackson.core</groupId>
147+
<artifactId>jackson-databind</artifactId>
148+
</dependency>
146149
<dependency>
147150
<groupId>org.slf4j</groupId>
148151
<artifactId>slf4j-api</artifactId>

codegen/src/main/java/software/amazon/awssdk/codegen/model/intermediate/Metadata.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -499,17 +499,12 @@ public Metadata withJsonVersion(String jsonVersion) {
499499
return this;
500500
}
501501

502-
public boolean isIonProtocol() {
503-
return protocol == Protocol.ION;
504-
}
505-
506502
public boolean isCborProtocol() {
507503
return protocol == Protocol.CBOR;
508504
}
509505

510506
public boolean isJsonProtocol() {
511507
return protocol == Protocol.CBOR ||
512-
protocol == Protocol.ION ||
513508
protocol == Protocol.AWS_JSON ||
514509
protocol == Protocol.REST_JSON;
515510
}

codegen/src/main/java/software/amazon/awssdk/codegen/model/intermediate/Protocol.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ public enum Protocol {
2424
REST_JSON("rest-json"),
2525
CBOR("cbor"),
2626
QUERY("query"),
27-
REST_XML("rest-xml"),
28-
ION("ion");
27+
REST_XML("rest-xml");
2928

3029
private String protocol;
3130

codegen/src/main/java/software/amazon/awssdk/codegen/poet/client/SyncClientClass.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,6 @@ static ProtocolSpec getProtocolSpecs(PoetExtensions poetExtensions, Intermediate
339339
case AWS_JSON:
340340
case REST_JSON:
341341
case CBOR:
342-
case ION:
343342
return new JsonProtocolSpec(poetExtensions, model);
344343
default:
345344
throw new RuntimeException("Unknown protocol: " + protocol.name());

codegen/src/main/java/software/amazon/awssdk/codegen/poet/client/specs/JsonProtocolSpec.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@
5151
import software.amazon.awssdk.core.http.HttpResponseHandler;
5252
import software.amazon.awssdk.core.protocol.VoidSdkResponse;
5353
import software.amazon.awssdk.protocols.cbor.AwsCborProtocolFactory;
54-
import software.amazon.awssdk.protocols.ion.AwsIonProtocolFactory;
5554
import software.amazon.awssdk.protocols.json.AwsJsonProtocol;
5655
import software.amazon.awssdk.protocols.json.AwsJsonProtocolFactory;
5756
import software.amazon.awssdk.protocols.json.BaseAwsJsonProtocolFactory;
@@ -119,8 +118,6 @@ private CodeBlock customErrorCodeFieldName() {
119118
private Class<?> protocolFactoryClass() {
120119
if (model.getMetadata().isCborProtocol()) {
121120
return AwsCborProtocolFactory.class;
122-
} else if (model.getMetadata().isIonProtocol()) {
123-
return AwsIonProtocolFactory.class;
124121
} else {
125122
return AwsJsonProtocolFactory.class;
126123
}
@@ -377,7 +374,6 @@ public Optional<MethodSpec> createErrorResponseHandler() {
377374
private String protocolEnumName(software.amazon.awssdk.codegen.model.intermediate.Protocol protocol) {
378375
switch (protocol) {
379376
case CBOR:
380-
case ION:
381377
case AWS_JSON:
382378
return AWS_JSON.name();
383379
default:

codegen/src/main/java/software/amazon/awssdk/codegen/poet/transform/MarshallerSpec.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,6 @@ private MarshallerProtocolSpec getProtocolSpecs(software.amazon.awssdk.codegen.m
117117
switch (protocol) {
118118
case REST_JSON:
119119
case CBOR:
120-
case ION:
121120
case AWS_JSON:
122121
return getJsonMarshallerSpec();
123122

core/auth/pom.xml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,9 @@
6363
<version>${awsjavasdk.version}</version>
6464
</dependency>
6565
<dependency>
66-
<groupId>com.fasterxml.jackson.core</groupId>
67-
<artifactId>jackson-databind</artifactId>
66+
<groupId>software.amazon.awssdk</groupId>
67+
<artifactId>json-utils</artifactId>
68+
<version>${awsjavasdk.version}</version>
6869
</dependency>
6970
<dependency>
7071
<groupId>software.amazon.eventstream</groupId>

core/auth/src/main/java/software/amazon/awssdk/auth/credentials/HttpCredentialsProvider.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@
1515

1616
package software.amazon.awssdk.auth.credentials;
1717

18-
import com.fasterxml.jackson.databind.JsonMappingException;
19-
import com.fasterxml.jackson.databind.JsonNode;
2018
import java.io.IOException;
2119
import java.time.Duration;
2220
import java.time.Instant;
21+
import java.util.Map;
2322
import java.util.Optional;
2423
import software.amazon.awssdk.annotations.SdkProtectedApi;
2524
import software.amazon.awssdk.core.exception.SdkClientException;
26-
import software.amazon.awssdk.core.util.json.JacksonUtils;
25+
import software.amazon.awssdk.protocols.jsoncore.JsonNode;
26+
import software.amazon.awssdk.protocols.jsoncore.JsonNodeParser;
2727
import software.amazon.awssdk.regions.util.HttpResourcesUtils;
2828
import software.amazon.awssdk.regions.util.ResourcesEndpointProvider;
2929
import software.amazon.awssdk.utils.ComparableUtils;
@@ -40,6 +40,11 @@
4040
*/
4141
@SdkProtectedApi
4242
public abstract class HttpCredentialsProvider implements AwsCredentialsProvider, SdkAutoCloseable {
43+
private static final JsonNodeParser SENSITIVE_PARSER =
44+
JsonNodeParser.builder()
45+
.removeErrorLocations(true)
46+
.build();
47+
4348
private final Optional<CachedSupplier<AwsCredentials>> credentialsCache;
4449

4550
protected HttpCredentialsProvider(BuilderImpl<?, ?> builder) {
@@ -73,7 +78,7 @@ private RefreshResult<AwsCredentials> refreshCredentials() {
7378
try {
7479
String credentialsResponse = HttpResourcesUtils.instance().readResource(getCredentialsEndpointProvider());
7580

76-
JsonNode node = JacksonUtils.sensitiveJsonNodeOf(credentialsResponse);
81+
Map<String, JsonNode> node = SENSITIVE_PARSER.parse(credentialsResponse).asObject();
7782
JsonNode accessKey = node.get("AccessKeyId");
7883
JsonNode secretKey = node.get("SecretAccessKey");
7984
JsonNode token = node.get("Token");
@@ -83,8 +88,8 @@ private RefreshResult<AwsCredentials> refreshCredentials() {
8388
Validate.notNull(secretKey, "Failed to load secret key.");
8489

8590
AwsCredentials credentials =
86-
token == null ? AwsBasicCredentials.create(accessKey.asText(), secretKey.asText())
87-
: AwsSessionCredentials.create(accessKey.asText(), secretKey.asText(), token.asText());
91+
token == null ? AwsBasicCredentials.create(accessKey.text(), secretKey.text())
92+
: AwsSessionCredentials.create(accessKey.text(), secretKey.text(), token.text());
8893

8994
Instant expiration = getExpiration(expirationNode).orElse(null);
9095
if (expiration != null && Instant.now().isAfter(expiration)) {
@@ -98,11 +103,6 @@ private RefreshResult<AwsCredentials> refreshCredentials() {
98103
.build();
99104
} catch (SdkClientException e) {
100105
throw e;
101-
} catch (JsonMappingException e) {
102-
throw SdkClientException.builder()
103-
.message("Unable to parse response returned from service endpoint.")
104-
.cause(e)
105-
.build();
106106
} catch (RuntimeException | IOException e) {
107107
throw SdkClientException.builder()
108108
.message("Unable to load credentials from service endpoint.")
@@ -114,7 +114,7 @@ private RefreshResult<AwsCredentials> refreshCredentials() {
114114
private Optional<Instant> getExpiration(JsonNode expirationNode) {
115115
return Optional.ofNullable(expirationNode).map(node -> {
116116
// Convert the expirationNode string to ISO-8601 format.
117-
String expirationValue = node.asText().replaceAll("\\+0000$", "Z");
117+
String expirationValue = node.text().replaceAll("\\+0000$", "Z");
118118

119119
try {
120120
return DateUtils.parseIso8601Date(expirationValue);

core/auth/src/main/java/software/amazon/awssdk/auth/credentials/ProcessCredentialsProvider.java

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

1616
package software.amazon.awssdk.auth.credentials;
1717

18-
import com.fasterxml.jackson.databind.JsonNode;
1918
import java.io.ByteArrayOutputStream;
2019
import java.io.IOException;
2120
import java.nio.charset.StandardCharsets;
@@ -25,11 +24,8 @@
2524
import java.util.Collections;
2625
import java.util.List;
2726
import software.amazon.awssdk.annotations.SdkPublicApi;
28-
import software.amazon.awssdk.auth.credentials.AwsBasicCredentials;
29-
import software.amazon.awssdk.auth.credentials.AwsCredentials;
30-
import software.amazon.awssdk.auth.credentials.AwsCredentialsProvider;
31-
import software.amazon.awssdk.auth.credentials.AwsSessionCredentials;
32-
import software.amazon.awssdk.core.util.json.JacksonUtils;
27+
import software.amazon.awssdk.protocols.jsoncore.JsonNode;
28+
import software.amazon.awssdk.protocols.jsoncore.JsonNodeParser;
3329
import software.amazon.awssdk.utils.DateUtils;
3430
import software.amazon.awssdk.utils.IoUtils;
3531
import software.amazon.awssdk.utils.Platform;
@@ -58,6 +54,10 @@
5854
*/
5955
@SdkPublicApi
6056
public final class ProcessCredentialsProvider implements AwsCredentialsProvider {
57+
private static final JsonNodeParser PARSER = JsonNodeParser.builder()
58+
.removeErrorLocations(true)
59+
.build();
60+
6161
private final List<String> command;
6262
private final Duration credentialRefreshThreshold;
6363
private final long processOutputLimit;
@@ -129,14 +129,14 @@ private RefreshResult<AwsCredentials> refreshCredentials() {
129129
* Parse the output from the credentials process.
130130
*/
131131
private JsonNode parseProcessOutput(String processOutput) {
132-
JsonNode credentialsJson = JacksonUtils.sensitiveJsonNodeOf(processOutput);
132+
JsonNode credentialsJson = PARSER.parse(processOutput);
133133

134134
if (!credentialsJson.isObject()) {
135135
throw new IllegalStateException("Process did not return a JSON object.");
136136
}
137137

138-
JsonNode version = credentialsJson.get("Version");
139-
if (version == null || !version.isInt() || version.asInt() != 1) {
138+
JsonNode version = credentialsJson.field("Version").orElse(null);
139+
if (version == null || !version.isNumber() || !version.asNumber().equals("1")) {
140140
throw new IllegalStateException("Unsupported credential version: " + version);
141141
}
142142
return credentialsJson;
@@ -174,21 +174,10 @@ private Instant credentialExpirationTime(JsonNode credentialsJson) {
174174
}
175175

176176
/**
177-
* Get a textual value from a json object, throwing an exception if the node is missing or not textual.
177+
* Get a textual value from a json object.
178178
*/
179179
private String getText(JsonNode jsonObject, String nodeName) {
180-
JsonNode subNode = jsonObject.get(nodeName);
181-
182-
if (subNode == null) {
183-
return null;
184-
}
185-
186-
if (!subNode.isTextual()) {
187-
throw new IllegalStateException(nodeName + " from credential process should be textual, but was " +
188-
subNode.getNodeType());
189-
}
190-
191-
return subNode.asText();
180+
return jsonObject.field(nodeName).map(JsonNode::text).orElse(null);
192181
}
193182

194183
/**

0 commit comments

Comments
 (0)