Skip to content

Allow object serialization on DefaultSdkAutoConstructList and Default… #976

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from

Conversation

udaysagar2177
Copy link

@udaysagar2177 udaysagar2177 commented Dec 24, 2018

Description

Allow Object serialization on DefaultSdkAutoConstructList and DefaultSdkAutoConstructMap.

Motivation and Context

software.amazon.awssdk.services.ec2.model.InstanceStatus isn't serializable because DefaultSdkAutoConstructList instance doesn't implement Serializable.

Testing

Wrote simple tests to check if DefaultSdkAutoConstructList & DefaultSdkAutoConstructMap are serializable and deserializable. They fail before the fix and pass after the fix.

Screenshots (if appropriate)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Checklist

  • I have read the CONTRIBUTING document
  • Local run of mvn install succeeds
  • My code follows the code style of this project
  • My change requires a change to the Javadoc documentation
  • I have updated the Javadoc documentation accordingly
  • I have read the README document
  • I have added tests to cover my changes
  • All new and existing tests passed
  • A short description of the change has been added to the CHANGELOG
  • My change is to implement 1.11 parity feature and I have updated LaunchChangelog

License

  • I confirm that this pull request can be released under the Apache 2 license

@udaysagar2177
Copy link
Author

@zoewangg Could you please take a look at this PR? Thanks!

@@ -158,4 +162,8 @@ public int lastIndexOf(Object o) {
return impl.subList(fromIndex, toIndex);
}

// For deserialization
private Object readResolve() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you give us more context of why this is needed?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a serialization trick to ensure that we use the singleton instance (INSTANCE on line 37) when we deserialize this class's object. (Usually, deserialization constructs a new object without readResolve())

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zoewangg ping

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apologies for the delay. Hmm, I'm not sure if we want to add this. This seems a bit hacky to me.

@codecov-io
Copy link

Codecov Report

Merging #976 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #976      +/-   ##
============================================
+ Coverage     55.39%   55.39%   +<.01%     
- Complexity     4492     4494       +2     
============================================
  Files           799      799              
  Lines         27487    27489       +2     
  Branches       2224     2224              
============================================
+ Hits          15226    15228       +2     
  Misses        11543    11543              
  Partials        718      718
Impacted Files Coverage Δ Complexity Δ
.../awssdk/core/util/DefaultSdkAutoConstructList.java 22.58% <100%> (+2.58%) 5 <1> (+1) ⬆️
...n/awssdk/core/util/DefaultSdkAutoConstructMap.java 35% <100%> (+3.42%) 5 <1> (+1) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 858877f...1220ac9. Read the comment docs.

@@ -158,4 +162,8 @@ public int lastIndexOf(Object o) {
return impl.subList(fromIndex, toIndex);
}

// For deserialization
private Object readResolve() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apologies for the delay. Hmm, I'm not sure if we want to add this. This seems a bit hacky to me.

@@ -0,0 +1,29 @@
package software.amazon.awssdk.core.util;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test files are missing copyright header. You can copy paste the copyright header from other file in this repo

@dagnir
Copy link
Contributor

dagnir commented Jul 12, 2019

Closing this PR for now as it seems it hasn't been update since @zoewangg made some comments. Please feel free to reopen once it's updated and ready for another look.

@dagnir dagnir closed this Jul 12, 2019
aws-sdk-java-automation added a commit that referenced this pull request Sep 28, 2020
…a702002f

Pull request: release <- staging/f887abb7-3b40-41bf-8e0f-467fa702002f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants