Consistently use BuilderRefs for collections in builders#2743
Merged
Conversation
This adds static methods to BuilderRef for creating sorted maps and sets, including an optional custom comparator.
milesziemer
suggested changes
Aug 15, 2025
This updates every map, set, or list in a builder to use BuilderRef. BuilderRef exists to minimize the number of copies we have to do as well as to make it harder to forget to make immutable copies of collections. In a few cases the underlying collection was changed to preserve or enforce order.
f9aa14d to
26e3b2d
Compare
milesziemer
suggested changes
Aug 18, 2025
milesziemer
approved these changes
Aug 18, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This updates every map, set, or list in a builder to use BuilderRef. BuilderRef exists to minimize the number of copies we have to do as well as to make it harder to forget to make immutable copies of collections.
In a few cases the underlying collection was changed to preserve or enforce order. This fixes #2734 because the source of that issue was not having a consistent order for responseParameters. That's now kept sorted, like basically every other part of the openapi document.
This resulted in fixing a few other unknown bugs. In some instances we had been directly referencing collections from the builder instead of making any kind of copies. There was also at least one test that asserted non-existent behavior that only passed because of the accident of ordering.
Note that mutability was preserved where it existed already. I had initially removed all of that, but there were some areas relying on it (notably openapi plugins).
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.