Skip to content
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

Add InMemoryBufferingS3OutputStream #400

Merged
merged 7 commits into from
Jun 6, 2022

Conversation

sgarfinkel
Copy link
Contributor

@sgarfinkel sgarfinkel commented May 26, 2022

📢 Type of change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring

📜 Description

Resolves #392 by adding a new InMemoryBufferingS3OutputStream which uses MultiPartUploads to stream large files to S3 without using the Filesystem.

💡 Motivation and Context

As discussed in the issue, this feature existed in the old version of spring-cloud-aws. It has been brought over in this new implementation, which although inspired by it, is entirely new.

💚 How did you test it?

There's a pretty extensive set of tests in the new InMemoryBufferingS3OutputStreamTests file. Test coverage is quite good, at about 75% of lines. That 25% represents conditionals that log warnings and thrown exceptions and the like. All the business logic is fully covered.

📝 Checklist

  • I reviewed submitted code
  • I added tests to verify changes
  • I updated reference documentation to reflect the change
  • All tests passing
  • No breaking changes

🔮 Next steps

Consider making this the default implementation used by the AutoConfiguration to backport the old functionality that used this same mechanism by default.

@sgarfinkel
Copy link
Contributor Author

sgarfinkel commented May 26, 2022

The failed security gate is complaining about the MD5 algorithm being used to generate a hash of the content...

Copy link
Contributor

@maciejwalkowiak maciejwalkowiak left a comment

Choose a reason for hiding this comment

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

Thanks @sgarfinkel for a great contribution! I agree that we should consider it making a default one.

Some things to polish:

S3ResourceIntegrationTests should be updated to also use InMemoryBufferingS3OutputStream among other output stream providers (as far as i can see one tests for InMemoryBufferingS3OutputStream is going to fail).

@maciejwalkowiak
Copy link
Contributor

I did some polishing. Docs update still pending. @MatejNedic take a look please.

@maciejwalkowiak maciejwalkowiak added this to the 3.0.0 M1 milestone Jun 3, 2022
@maciejwalkowiak maciejwalkowiak added component: s3 S3 integration related issue type: enhancement Smaller enhancement in existing integration labels Jun 3, 2022
@sgarfinkel
Copy link
Contributor Author

I did some polishing. Docs update still pending. @MatejNedic take a look please.

Thank you! I’ve had some personal things come up and have had very little time to do OSS work the past week.

@maciejwalkowiak
Copy link
Contributor

maciejwalkowiak commented Jun 3, 2022

@sgarfinkel no worries, you've done great job already!

btw, perhaps you can consider contributing it to aws-sdk-v2? (aws/aws-sdk-java-v2#3128)

Copy link
Member

@MatejNedic MatejNedic left a comment

Choose a reason for hiding this comment

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

Hey @sgarfinkel ,
Tnx on contribution. Looks good to me, only 1 thing I am thinking if we should introduce as well.

Optional<S3ObjectContentTypeResolver> contentTypeResolver) {
return new DiskBufferingS3OutputStreamProvider(s3Client,
return new InMemoryBufferingS3OutputStreamProvider(s3Client,
Copy link
Member

Choose a reason for hiding this comment

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

We should provide a way that bufferSize can be set in properties.

Copy link
Contributor

Choose a reason for hiding this comment

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

it can be easily defined by overwriting a bean. i am not sure how to structure it at this stage, we can add a property later when feedback like this comes.

@github-actions github-actions bot added the type: documentation Documentation or Samples related issue label Jun 6, 2022
@maciejwalkowiak maciejwalkowiak merged commit 629a7d4 into awspring:main Jun 6, 2022
@sonarcloud
Copy link

sonarcloud bot commented Jun 6, 2022

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot E 1 Security Hotspot
Code Smell A 2 Code Smells

No Coverage information No Coverage information
17.8% 17.8% Duplication

@sgarfinkel sgarfinkel deleted the spring-cloud-aws-392 branch June 7, 2022 16:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: s3 S3 integration related issue type: documentation Documentation or Samples related issue type: enhancement Smaller enhancement in existing integration
Projects
None yet
Development

Successfully merging this pull request may close these issues.

In-Memory Buffered S3 OutputStream
3 participants