24 lines
1.1 KiB
Diff
24 lines
1.1 KiB
Diff
# UNDF: UNDF-2026-000000343
|
|
--- a/zookeeper-server/src/main/java/org/apache/zookeeper/server/PrepRequestProcessor.java
|
|
+++ b/zookeeper-server/src/main/java/org/apache/zookeeper/server/PrepRequestProcessor.java
|
|
@@ -943,12 +943,14 @@
|
|
private static List<ACL> removeDuplicates(final List<ACL> acls) {
|
|
if (acls == null || acls.isEmpty()) {
|
|
return Collections.emptyList();
|
|
}
|
|
- // This would be done better with a Set but ACL hashcode/equals do not
|
|
- // allow for null values
|
|
- final ArrayList<ACL> retval = new ArrayList<>(acls.size());
|
|
+ // LinkedHashSet gives O(1) contains/add while preserving insertion order.
|
|
+ // ACL.hashCode() and ACL.equals() are defined on (perms, id) — null Id fields
|
|
+ // are handled by the Thrift-generated equals(); no special-casing is needed.
|
|
+ final LinkedHashSet<ACL> seen = new LinkedHashSet<>(acls.size() * 2);
|
|
for (final ACL acl : acls) {
|
|
- if (!retval.contains(acl)) {
|
|
- retval.add(acl);
|
|
- }
|
|
+ seen.add(acl);
|
|
}
|
|
- return retval;
|
|
+ return new ArrayList<>(seen);
|
|
}
|