You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by dw...@apache.org on 2026/04/03 09:51:42 UTC

(lucene) branch main updated: Use List#copyOf instead of Collections#unmodifiableList in Explanation. (#15928)

This is an automated email from the ASF dual-hosted git repository.

dweiss pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/lucene.git


The following commit(s) were added to refs/heads/main by this push:
     new 6538d6835ce Use List#copyOf instead of Collections#unmodifiableList in Explanation. (#15928)
6538d6835ce is described below

commit 6538d6835cea6eae38f801d6bc84144f60b7b564
Author: Zhou Hui <vs...@163.com>
AuthorDate: Fri Apr 3 17:51:35 2026 +0800

    Use List#copyOf instead of Collections#unmodifiableList in Explanation. (#15928)
---
 lucene/core/src/java/org/apache/lucene/search/Explanation.java | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/lucene/core/src/java/org/apache/lucene/search/Explanation.java b/lucene/core/src/java/org/apache/lucene/search/Explanation.java
index 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;
   }