Skip to content

Stop publishing after Content-Length bytes #539

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

Merged
merged 2 commits into from
Jun 12, 2018
Merged

Conversation

dagnir
Copy link
Contributor

@dagnir dagnir commented Jun 11, 2018

Stop publishing after Content-Length bytes

Fixes #460

Description

Stop publishing after Content-Length bytes

Fixes #460

Motivation and Context

Fix #460

Testing

mvn clean install with new unit test.

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

License

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

subscriber.onNext(content);
written += newLimit;

if (!shouldContinuePublishing()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to cancel or can we just call on complete?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we should also cancel the subscription to so the adapted publisher can do any cleanup if it wanted to

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 just do that in onComplete right?

If a Publisher signals either onError or onComplete on a Subscriber, that Subscriber’s Subscription MUST be considered cancelled.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm I might be confused but since our adapter sits between the streamed request subscriber and the user supplied request content publisher, we need to cancel the subscription to the content publisher and call onComplete the streamed request right?

Copy link
Contributor

Choose a reason for hiding this comment

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

Was reading again and found this so this looks right to me.

The intent of this rule is to establish that Subscribers cannot just throw Subscriptions away when they are no longer needed, they have to call cancel so that resources held by that Subscription can be safely, and timely, reclaimed. An example of this would be a Subscriber which is only interested in a specific element, which would then cancel its Subscription to signal its completion to the Publisher.

subscriber.onNext(content);
written += newLimit;

if (!shouldContinuePublishing()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Was reading again and found this so this looks right to me.

The intent of this rule is to establish that Subscribers cannot just throw Subscriptions away when they are no longer needed, they have to call cancel so that resources held by that Subscription can be safely, and timely, reclaimed. An example of this would be a Subscriber which is only interested in a specific element, which would then cancel its Subscription to signal its completion to the Publisher.

@dagnir dagnir merged commit c3891a4 into aws:master Jun 12, 2018
@dagnir dagnir deleted the issue-460-fix branch June 12, 2018 19:20
aws-sdk-java-automation added a commit that referenced this pull request Jun 19, 2019
…9c1a9443

Pull request: release <- staging/79945b4c-f3b4-41ba-ac45-1d319c1a9443
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.

SDK ignores "Content-Length" header when sending the body of S3 PUT requests
2 participants