-
Notifications
You must be signed in to change notification settings - Fork 1
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
Sort availability zones for db cluster #662
Sort availability zones for db cluster #662
Conversation
@@ -182,7 +183,9 @@ public List<String> getAvailabilityZones() { | |||
} | |||
|
|||
public void setAvailabilityZones(List<String> availabilityZones) { | |||
this.availabilityZones = availabilityZones; | |||
List<String> modifiableList = new ArrayList<>(availabilityZones); // creates a new modifiable list |
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.
We probably shouldn't blindly create a new list every time.
We should handle the conversion in the copyFrom.
@Override
public void copyFrom(DBCluster cluster) {
setAvailabilityZones(new ArrayList<>(cluster.availabilityZones()));
@@ -182,7 +183,9 @@ public List<String> getAvailabilityZones() { | |||
} | |||
|
|||
public void setAvailabilityZones(List<String> availabilityZones) { | |||
this.availabilityZones = availabilityZones; | |||
List<String> modifiableList = new ArrayList<>(availabilityZones); // creates a new modifiable list | |||
Collections.sort(modifiableList); |
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.
The sort should take place on the getter instead.
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.
Added comments
Updated |
Fixes: #669
Description
This pull request addresses the need to maintain a consistently sorted order of 'availability zones' in our code.
Changes
The setter method now takes the input list of availability zones, creates a new modifiable list from it, sorts this list, and assigns it back to the availabilityZones field.