-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Fixed duplicate metadata in ModelDataSource #36337
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
Conversation
- Today when we make endpoints for the ModelDataSource, we apply the callbacks to the EndpointBuilder before creating the endpoint. This happens every time anyone accesses the endpoints property. Instead of re-applying the conventions, we do it once on Build. We also throw if more conventions are added after building. - Added tests
| { | ||
| foreach (var convention in _conventions) | ||
| // Only apply the conventions once | ||
| var conventions = Interlocked.Exchange(ref _conventions, null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's interlocked because we're worried about Add / Build being called concurrently?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm just being extra defensive. It's unclear if these APIs are intended to be called thread safe. This is just to prevent any corruption.
| // Access endpoints a couple of times to make sure it gets built | ||
| _ = dataSource.Endpoints; | ||
| _ = dataSource.Endpoints; | ||
| _ = dataSource.Endpoints; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3 is more than a "couple".
Co-authored-by: Pranav K <[email protected]>
|
/backport to release/6.0 |
|
Started backporting to release/6.0: https://github.com/dotnet/aspnetcore/actions/runs/1218396825 |
Fixes #34199