Skip to content

Commit 14f5d7b

Browse files
authored
Remove fast unmarshaller dialup code (#6050)
* Remove fast unmarshaller dialup code * Further cleanup and checkstyle fixes * Add the @deprecated javadoc tag * Add back the SdkClientJsonProtocolAdvancedOption class * Remove the parser setter, we don't need to be backwards compatible
1 parent 157f16c commit 14f5d7b

File tree

6 files changed

+9
-81
lines changed

6 files changed

+9
-81
lines changed

codegen/src/main/java/software/amazon/awssdk/codegen/poet/builder/BaseClientBuilderClass.java

-8
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@
8181
import software.amazon.awssdk.identity.spi.IdentityProvider;
8282
import software.amazon.awssdk.identity.spi.IdentityProviders;
8383
import software.amazon.awssdk.identity.spi.TokenIdentity;
84-
import software.amazon.awssdk.protocols.json.internal.unmarshall.SdkClientJsonProtocolAdvancedOption;
8584
import software.amazon.awssdk.regions.ServiceMetadataAdvancedOption;
8685
import software.amazon.awssdk.utils.AttributeMap;
8786
import software.amazon.awssdk.utils.CollectionUtils;
@@ -508,13 +507,6 @@ private MethodSpec finalizeServiceConfigurationMethod() {
508507
.addCode(" .fipsEnabled(c.get($T.FIPS_ENDPOINT_ENABLED))", AwsClientOption.class)
509508
.addCode(" .build());");
510509

511-
if (model.getMetadata().isJsonProtocol()) {
512-
if (model.getCustomizationConfig().getEnableFastUnmarshaller()) {
513-
builder.addStatement("builder.option($1T.ENABLE_FAST_UNMARSHALLER, true)",
514-
SdkClientJsonProtocolAdvancedOption.class);
515-
}
516-
}
517-
518510
if (hasRequestAlgorithmMember(model) || hasResponseAlgorithms(model)) {
519511
builder.addStatement("$T clientConfig = config", SdkClientConfiguration.class);
520512

core/protocols/aws-json-protocol/src/main/java/software/amazon/awssdk/protocols/json/BaseAwsJsonProtocolFactory.java

-10
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@
5353
import software.amazon.awssdk.protocols.json.internal.unmarshall.JsonProtocolUnmarshaller;
5454
import software.amazon.awssdk.protocols.json.internal.unmarshall.JsonResponseHandler;
5555
import software.amazon.awssdk.protocols.json.internal.unmarshall.ProtocolUnmarshallDependencies;
56-
import software.amazon.awssdk.protocols.json.internal.unmarshall.SdkClientJsonProtocolAdvancedOption;
5756

5857
@SdkProtectedApi
5958
public abstract class BaseAwsJsonProtocolFactory {
@@ -88,16 +87,7 @@ protected BaseAwsJsonProtocolFactory(Builder<?> builder) {
8887
this.customErrorCodeFieldName = builder.customErrorCodeFieldName;
8988
this.hasAwsQueryCompatible = builder.hasAwsQueryCompatible;
9089
this.clientConfiguration = builder.clientConfiguration;
91-
Boolean enableFastUnmarshalling = false;
92-
if (clientConfiguration != null) {
93-
enableFastUnmarshalling =
94-
clientConfiguration.option(SdkClientJsonProtocolAdvancedOption.ENABLE_FAST_UNMARSHALLER);
95-
if (enableFastUnmarshalling == null) {
96-
enableFastUnmarshalling = false;
97-
}
98-
}
9990
this.protocolUnmarshaller = JsonProtocolUnmarshaller.builder()
100-
.enableFastUnmarshalling(enableFastUnmarshalling)
10191
.protocolUnmarshallDependencies(
10292
builder.protocolUnmarshallDependencies.get())
10393
.build();

core/protocols/aws-json-protocol/src/main/java/software/amazon/awssdk/protocols/json/internal/unmarshall/JsonProtocolUnmarshaller.java

+8-57
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848
import software.amazon.awssdk.protocols.json.internal.MarshallerUtil;
4949
import software.amazon.awssdk.protocols.json.internal.unmarshall.document.DocumentUnmarshaller;
5050
import software.amazon.awssdk.protocols.jsoncore.JsonNode;
51-
import software.amazon.awssdk.protocols.jsoncore.JsonNodeParser;
5251
import software.amazon.awssdk.protocols.jsoncore.JsonValueNodeFactory;
5352
import software.amazon.awssdk.utils.Lazy;
5453
import software.amazon.awssdk.utils.builder.Buildable;
@@ -59,42 +58,24 @@
5958
*/
6059
@SdkInternalApi
6160
@ThreadSafe
62-
public class JsonProtocolUnmarshaller {
61+
public final class JsonProtocolUnmarshaller {
6362
private static final Lazy<DefaultProtocolUnmarshallDependencies> DEFAULT_DEPENDENCIES =
6463
new Lazy<>(JsonProtocolUnmarshaller::newProtocolUnmarshallDependencies);
6564

6665
private final JsonUnmarshallerRegistry registry;
6766
private final JsonUnmarshallingParser unmarshallingParser;
68-
private final JsonNodeParser parser;
6967

7068
private JsonProtocolUnmarshaller(Builder builder) {
7169
ProtocolUnmarshallDependencies dependencies = builder.protocolUnmarshallDependencies;
7270
this.registry = dependencies.jsonUnmarshallerRegistry();
73-
if (builder.enableFastUnmarshalling) {
74-
this.unmarshallingParser = JsonUnmarshallingParser.builder()
75-
.jsonValueNodeFactory(dependencies.nodeValueFactory())
76-
.jsonFactory(dependencies.jsonFactory())
77-
.unmarshallerRegistry(dependencies.jsonUnmarshallerRegistry())
78-
.defaultTimestampFormat(dependencies.timestampFormats()
79-
.get(MarshallLocation.PAYLOAD))
80-
81-
.build();
82-
this.parser = null;
83-
} else {
84-
this.unmarshallingParser = null;
85-
this.parser = createParser(builder, dependencies);
86-
}
87-
}
71+
this.unmarshallingParser = JsonUnmarshallingParser.builder()
72+
.jsonValueNodeFactory(dependencies.nodeValueFactory())
73+
.jsonFactory(dependencies.jsonFactory())
74+
.unmarshallerRegistry(dependencies.jsonUnmarshallerRegistry())
75+
.defaultTimestampFormat(dependencies.timestampFormats()
76+
.get(MarshallLocation.PAYLOAD))
8877

89-
private JsonNodeParser createParser(Builder builder, ProtocolUnmarshallDependencies dependencies) {
90-
if (builder.parser != null) {
91-
return builder.parser;
92-
}
93-
return JsonNodeParser
94-
.builder()
95-
.jsonFactory(dependencies.jsonFactory())
96-
.jsonValueNodeFactory(dependencies.nodeValueFactory())
97-
.build();
78+
.build();
9879
}
9980

10081
public static DefaultProtocolUnmarshallDependencies defaultProtocolUnmarshallDependencies() {
@@ -239,15 +220,6 @@ public T unmarshall(JsonUnmarshallerContext context,
239220

240221
public <TypeT extends SdkPojo> TypeT unmarshall(SdkPojo sdkPojo,
241222
SdkHttpFullResponse response) throws IOException {
242-
if (this.unmarshallingParser != null) {
243-
return fastUnmarshall(sdkPojo, response);
244-
}
245-
JsonNode jsonNode = hasJsonPayload(sdkPojo, response) ? parser.parse(response.content().get()) : null;
246-
return unmarshall(sdkPojo, response, jsonNode);
247-
}
248-
249-
private <TypeT extends SdkPojo> TypeT fastUnmarshall(SdkPojo sdkPojo,
250-
SdkHttpFullResponse response) throws IOException {
251223
if (!hasJsonPayload(sdkPojo, response)) {
252224
return unmarshallResponse(sdkPojo, response);
253225
}
@@ -453,23 +425,11 @@ public static JsonUnmarshallerRegistry timestampFormatRegistryFactory(
453425
* Builder for {@link JsonProtocolUnmarshaller}.
454426
*/
455427
public static final class Builder {
456-
457-
private JsonNodeParser parser;
458428
private ProtocolUnmarshallDependencies protocolUnmarshallDependencies;
459-
private boolean enableFastUnmarshalling = false;
460429

461430
private Builder() {
462431
}
463432

464-
/**
465-
* @param parser JSON parser to use.
466-
* @return This builder for method chaining.
467-
*/
468-
public Builder parser(JsonNodeParser parser) {
469-
this.parser = parser;
470-
return this;
471-
}
472-
473433
/**
474434
* @param formats The default timestamp formats for each location in the HTTP response.
475435
* @return This builder for method chaining.
@@ -491,15 +451,6 @@ public Builder protocolUnmarshallDependencies(
491451
return this;
492452
}
493453

494-
/**
495-
* @param enableFastUnmarshalling Whether to enable the fast unmarshalling codepath. Default to {@code false}.
496-
* @return This builder for method chaining.
497-
*/
498-
public Builder enableFastUnmarshalling(boolean enableFastUnmarshalling) {
499-
this.enableFastUnmarshalling = enableFastUnmarshalling;
500-
return this;
501-
}
502-
503454
/**
504455
* @return New instance of {@link JsonProtocolUnmarshaller}.
505456
*/

test/architecture-tests/src/test/java/software/amazon/awssdk/archtests/InternalApiBoundaryTest.java

+1-3
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,12 @@
3232
import java.util.stream.Collectors;
3333
import org.junit.jupiter.api.Test;
3434
import software.amazon.awssdk.annotations.SdkInternalApi;
35-
import software.amazon.awssdk.annotations.SdkProtectedApi;
3635
import software.amazon.awssdk.awscore.internal.AwsProtocolMetadata;
3736
import software.amazon.awssdk.awscore.internal.AwsServiceProtocol;
3837
import software.amazon.awssdk.core.internal.interceptor.trait.RequestCompression;
3938
import software.amazon.awssdk.core.internal.util.MetricUtils;
4039
import software.amazon.awssdk.core.internal.waiters.WaiterAttribute;
4140
import software.amazon.awssdk.http.auth.aws.internal.signer.util.ChecksumUtil;
42-
import software.amazon.awssdk.protocols.json.internal.unmarshall.SdkClientJsonProtocolAdvancedOption;
4341
import software.amazon.awssdk.utils.internal.EnumUtils;
4442
import software.amazon.awssdk.utils.internal.SystemSettingUtils;
4543

@@ -57,7 +55,7 @@ public class InternalApiBoundaryTest {
5755
private static final Set<Class<?>> ALLOWED_INTERNAL_API_ACROSS_MODULE_SUPPRESSION = new HashSet<>(
5856
Arrays.asList(WaiterAttribute.class, RequestCompression.class, RequestCompression.Builder.class, EnumUtils.class,
5957
AwsServiceProtocol.class, AwsProtocolMetadata.class, MetricUtils.class, SystemSettingUtils.class,
60-
ChecksumUtil.class, SdkClientJsonProtocolAdvancedOption.class));
58+
ChecksumUtil.class));
6159

6260
@Test
6361
void internalApi_shouldNotUsedAcrossModule() {

test/sdk-benchmarks/src/main/java/software/amazon/awssdk/benchmark/apicall/protocol/JsonCodec.java

-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ public SdkPojo unmarshall(AwsJsonProtocol protocol, SdkPojo pojo, byte[] bytes)
6767
JsonProtocolUnmarshaller unmarshaller =
6868
JsonProtocolUnmarshaller
6969
.builder()
70-
.enableFastUnmarshalling(true)
7170
.protocolUnmarshallDependencies(behavior.protocolUnmarshallDependencies())
7271
.build();
7372
SdkHttpFullResponse response = SdkHttpFullResponse

test/sdk-benchmarks/src/main/java/software/amazon/awssdk/benchmark/marshaller/dynamodb/V2DynamoDbAttributeValue.java

-2
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
import software.amazon.awssdk.protocols.json.AwsJsonProtocol;
4444
import software.amazon.awssdk.protocols.json.AwsJsonProtocolFactory;
4545
import software.amazon.awssdk.protocols.json.JsonOperationMetadata;
46-
import software.amazon.awssdk.protocols.json.internal.unmarshall.SdkClientJsonProtocolAdvancedOption;
4746
import software.amazon.awssdk.services.dynamodb.model.AttributeValue;
4847
import software.amazon.awssdk.services.dynamodb.model.BackupInUseException;
4948
import software.amazon.awssdk.services.dynamodb.model.BackupNotFoundException;
@@ -80,7 +79,6 @@ public class V2DynamoDbAttributeValue {
8079
.clientConfiguration(SdkClientConfiguration
8180
.builder()
8281
.option(SdkClientOption.ENDPOINT, URI.create("https://localhost"))
83-
.option(SdkClientJsonProtocolAdvancedOption.ENABLE_FAST_UNMARSHALLER, true)
8482
.build())
8583
.defaultServiceExceptionSupplier(DynamoDbException::builder)
8684
.protocol(AwsJsonProtocol.AWS_JSON)

0 commit comments

Comments
 (0)