You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2022/06/20 08:51:55 UTC

[GitHub] [pulsar] fantapsody commented on a diff in pull request #16138: [improve][broker] Use LinkedHashSet for config items of type Set to preserve elements order

fantapsody commented on code in PR #16138:
URL: https://github.com/apache/pulsar/pull/16138#discussion_r901415236


##########
pulsar-common/src/main/java/org/apache/pulsar/common/util/FieldParser.java:
##########
@@ -212,7 +212,7 @@ public static <T> void setEmptyValue(String strValue, Field field, T obj)
             if (field.getType().equals(List.class)) {
                 field.set(obj, new ArrayList<>());
             } else if (field.getType().equals(Set.class)) {
-                field.set(obj, new HashSet<>());
+                field.set(obj, new LinkedHashSet<>());

Review Comment:
   It's true for new configuration fields. However, using `Set` ensures the uniqueness of the elements in the collection, so it's non-trivial to convert the type of these fields from `Set` to `List`, and there are quite a few existing configuration fields of the type `Set`. On the other hand, changing `HashSet` to `LinkedHashSet` makes all existing fields ordered and it seems harmless except for a bit increase in the per-element memory consumption which should be acceptable for configuration items.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org