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

Revert new abstract method (breaking change) #215

Merged
merged 1 commit into from
Jan 8, 2022

Conversation

jsquire
Copy link
Member

@jsquire jsquire commented Jan 7, 2022

Summary

The focus of these changes is to revert the breaking change in Singleton where a new abstract OnCreateAsync overload was added. Doing so required trade-offs which were not ideal.

To ensure that callers build against older versions of the AMQP library could
continue to function, the new overload OnCreateAsync(TimeSpan, CancellationToken) is now forwarding to the legacy overload OnCreateAsync(TimeSpan) and will silently ignore the cancellation token.

Because we cannot be sure which OnCreateAsync overload derived classes are calling, both have been marked virtual rather than any abstract; this required having the legacy overload throw when not implemented, since that is the target of delegation.

The defined derived classes FaultTolerantAmqpObject and AmqpCbsLink have been adjusted to implement both overrides, with the legacy overload calling into the new overload with CancellationToken.None specified. This is intended to ensure that callers bound to older versions continue to work.

The focus of these changes is to revert the breaking change in Singleton
where a new abstract OnCreateAsync overload was added.  Doing so required
trade-offs which were not ideal.

To ensure that callers build against older versions of the AMQP library could
continue to function, the new overload `"OnCreateAsync(TimeSpan, CancellationToken)`
is now forwarding to the legacy overload `OnCreateAsync(TimeSpan)` and will silently
ignore the cancellation token.

Because we cannot be sure which `OnCreateAsync` overload derived classes are
calling, both have been marked `virtual` rather than any `abstract`; this
required having the legacy overload throw when not implemented, since that is
the target of delegation.

The defined derived classes `FaultTolerantAmqpObject` and `AmqpCbsLink` have
been adjusted to implement both overrides, with the legacy overload calling into
the new overload with `CancellationToken.None` specified.  This is intended to
ensure that callers bound to older versions continue to work.
@jsquire jsquire marked this pull request as draft January 7, 2022 22:25
@jsquire
Copy link
Member Author

jsquire commented Jan 7, 2022

@xinchen10: The previous set of changes overlooked that a new abstract method was added to Singleton, which breaks callers bound to earlier versions because they do not have an implementation for it. To get around this, I had to invert the delegation flow.

I'd appreciate your thoughts on the approach and whether you see any further gaps from the cancellation token support changes that I may have overlooked. In the meantime, we're going to do some further validation on our end since the initial scenario did not cover this case.

@jsquire
Copy link
Member Author

jsquire commented Jan 7, 2022

//cc: @JoshLove-msft, @AlexGhiondea

@xinchen10
Copy link
Member

Changes look good to me. I am curious how you use Singleton class. Though it is public, it is not meant to be used outside of this library, as indicated by the xml comments. If you use FaultTolerantAmqpObject or AmqpCbsLink, it should work as no breaking changes were introduced on them.

@JoshLove-msft
Copy link
Member

Changes look good to me. I am curious how you use Singleton class. Though it is public, it is not meant to be used outside of this library, as indicated by the xml comments. If you use FaultTolerantAmqpObject or AmqpCbsLink, it should work as no breaking changes were introduced on them.

It is used here - https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/servicebus/Azure.Messaging.ServiceBus/src/Amqp/AmqpTransactionEnlistment.cs#L14

@xinchen10 xinchen10 marked this pull request as ready for review January 8, 2022 00:39
@xinchen10 xinchen10 merged commit b2e1d20 into Azure:hotfix Jan 8, 2022
@jsquire jsquire deleted the squire/abstract-add-fix branch January 10, 2022 13:42
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.

3 participants