From 69dbd9ac479017ae672e0c5bec06ad1e46b73cc2 Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Fri, 27 Mar 2026 14:41:14 -0400 Subject: [PATCH] [COLLECTIONS-888] PatriciaTrie incompatible with Java 21 (JEP 431 Sequenced Collections) --- .../trie/AbstractPatriciaTrie.java | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/apache/commons/collections4/trie/AbstractPatriciaTrie.java b/src/main/java/org/apache/commons/collections4/trie/AbstractPatriciaTrie.java index 472bbe17d4..4de933dc92 100644 --- a/src/main/java/org/apache/commons/collections4/trie/AbstractPatriciaTrie.java +++ b/src/main/java/org/apache/commons/collections4/trie/AbstractPatriciaTrie.java @@ -1432,10 +1432,13 @@ public Set> entrySet() { /** * Returns the first entry the {@link org.apache.commons.collections4.Trie} is storing. *

- * This is implemented by going always to the left until - * we encounter a valid uplink. That uplink is the first key. + * This is implemented by going always to the left until we encounter a valid uplink. That uplink is the first key. + *

+ * + * @return the first entry the {@link org.apache.commons.collections4.Trie} is storing. + * @since 4.6.0 */ - TrieEntry firstEntry() { + public TrieEntry firstEntry() { // if Trie is empty, no first node. if (isEmpty()) { return null; @@ -1715,10 +1718,14 @@ public Set keySet() { /** * Returns the last entry the {@link org.apache.commons.collections4.Trie} is storing. * - *

This is implemented by going always to the right until - * we encounter a valid uplink. That uplink is the last key. + *

+ * This is implemented by going always to the right until we encounter a valid uplink. That uplink is the last key. + *

+ * + * @return the last entry the {@link org.apache.commons.collections4.Trie} is storing. + * @since 4.6.0 */ - TrieEntry lastEntry() { + public TrieEntry lastEntry() { return followRight(root.left); }