Apache Lucene open-source search software
Use List#copyOf instead of Collections#unmodifiableList in Explanation. (#15928)
Zhou Hui6538d6835cea
diff --git a/lucene/core/src/java/org/apache/lucene/search/Explanation.java b/lucene/core/src/java/org/apache/lucene/search/Explanation.javaindex 7e9e474ecf2..6556f9bbaa5 100644--- a/lucene/core/src/java/org/apache/lucene/search/Explanation.java+++ b/lucene/core/src/java/org/apache/lucene/search/Explanation.java@@ -16,10 +16,8 @@*/package org.apache.lucene.search;-import java.util.ArrayList;import java.util.Arrays;import java.util.Collection;-import java.util.Collections;import java.util.List;import java.util.Objects;@@ -70,13 +68,13 @@ public final class Explanation {this.match = match;this.value = Objects.requireNonNull(value);this.description = Objects.requireNonNull(description);- this.details = Collections.unmodifiableList(new ArrayList<>(details));+ this.details = List.copyOf(details);for (Explanation detail : details) {Objects.requireNonNull(detail);}}- /** Indicates whether or not this Explanation models a match. */+ /** Indicates whether this Explanation models a match. */public boolean isMatch() {return match;}