Make DefaultSdkAutoConstructList/Map Serializable. #5936
+81
−2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation and Context
See Issue #3143
Classes AttributeValue, S3Object, DynamoDb GetItemRequest implement the Serializable interface, but throws a NotSerializableException since v2.
This is due to using DefaultSdkAutoConstructList/Map as member field. When a Map/List does not exist in the request, These DefaultSdkAutoConstruct represent the non-existence, in contrary to an existing but empty List/Map.
There is a 4 line fix, to make these 2 classes Serializable. The challenge here is that they are both singleton classes. Java provides a readResolve() interface to handle this case.
The official documentation is here:
https://docs.oracle.com/en/java/javase/17/docs/specs/serialization/input.html
Other 3rd party references:
https://www.baeldung.com/java-serialization-readobject-vs-readresolve
https://stackoverflow.com/questions/3930181/how-to-deal-with-singleton-along-with-serialization
This feature is available since java 8:
https://docs.oracle.com/javase/8/docs/api/java/io/Serializable.html
Modifications
Make DefaultSdkAutoConstructList/Map Serializable.
Testing
java version "1.8.0_441"
Java(TM) SE Runtime Environment (build 1.8.0_441-b07)
Java HotSpot(TM) 64-Bit Server VM (build 25.441-b07, mixed mode)
Darwin **** 23.4.0 Darwin Kernel Version 23.4.0: Fri Mar 15 00:19:22 PDT 2024; root:xnu-10063.101.17~1/RELEASE_ARM64_T8112 arm64
Screenshots (if appropriate)
Types of changes
Checklist
mvn install
succeedsscripts/new-change
script and following the instructions. Commit the new file created by the script in.changes/next-release
with your changes.License