You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by us...@apache.org on 2024/01/30 10:57:54 UTC

(lucene) branch branch_9x updated: Make static final Set immutable (#13055): EnumSet.of() returns a mutable Set that should not be used for static final constants.

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

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


The following commit(s) were added to refs/heads/branch_9x by this push:
     new 1e36b461474 Make static final Set immutable (#13055): EnumSet.of() returns a mutable Set that should not be used for static final constants.
1e36b461474 is described below

commit 1e36b461474dc2159bbb31938781a161736cdded
Author: Dmitry Cherniachenko <2s...@gmail.com>
AuthorDate: Tue Jan 30 11:53:42 2024 +0100

    Make static final Set immutable (#13055): EnumSet.of() returns a mutable Set that should not be used for static final constants.
    
    # Conflicts:
    #       lucene/analysis/nori/src/java/org/apache/lucene/analysis/ko/KoreanPartOfSpeechStopFilter.java
---
 lucene/CHANGES.txt                                 |  2 ++
 .../analysis/ko/KoreanPartOfSpeechStopFilter.java  | 40 ++++++++++++----------
 2 files changed, 23 insertions(+), 19 deletions(-)

diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index 1507a94c089..350da742a8d 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -43,6 +43,8 @@ Improvements
 
 * GITHUB#13043: Support getMaxScore of ConjunctionScorer for non top level scoring clause. (Shintaro Murakami)
 
+* GITHUB#13055: Make DEFAULT_STOP_TAGS in KoreanPartOfSpeechStopFilter immutable (Dmitry Cherniachenko)
+
 Optimizations
 ---------------------
 
diff --git a/lucene/analysis/nori/src/java/org/apache/lucene/analysis/ko/KoreanPartOfSpeechStopFilter.java b/lucene/analysis/nori/src/java/org/apache/lucene/analysis/ko/KoreanPartOfSpeechStopFilter.java
index 166cae91ea6..b0b2055eb57 100644
--- a/lucene/analysis/nori/src/java/org/apache/lucene/analysis/ko/KoreanPartOfSpeechStopFilter.java
+++ b/lucene/analysis/nori/src/java/org/apache/lucene/analysis/ko/KoreanPartOfSpeechStopFilter.java
@@ -16,6 +16,7 @@
  */
 package org.apache.lucene.analysis.ko;
 
+import java.util.Collections;
 import java.util.EnumSet;
 import java.util.Set;
 import org.apache.lucene.analysis.FilteringTokenFilter;
@@ -33,25 +34,26 @@ public final class KoreanPartOfSpeechStopFilter extends FilteringTokenFilter {
 
   /** Default list of tags to filter. */
   public static final Set<POS.Tag> DEFAULT_STOP_TAGS =
-      EnumSet.of(
-          POS.Tag.E,
-          POS.Tag.IC,
-          POS.Tag.J,
-          POS.Tag.MAG,
-          POS.Tag.MAJ,
-          POS.Tag.MM,
-          POS.Tag.SP,
-          POS.Tag.SSC,
-          POS.Tag.SSO,
-          POS.Tag.SC,
-          POS.Tag.SE,
-          POS.Tag.XPN,
-          POS.Tag.XSA,
-          POS.Tag.XSN,
-          POS.Tag.XSV,
-          POS.Tag.UNA,
-          POS.Tag.NA,
-          POS.Tag.VSV);
+      Collections.unmodifiableSet(
+          EnumSet.of(
+              POS.Tag.E,
+              POS.Tag.IC,
+              POS.Tag.J,
+              POS.Tag.MAG,
+              POS.Tag.MAJ,
+              POS.Tag.MM,
+              POS.Tag.SP,
+              POS.Tag.SSC,
+              POS.Tag.SSO,
+              POS.Tag.SC,
+              POS.Tag.SE,
+              POS.Tag.XPN,
+              POS.Tag.XSA,
+              POS.Tag.XSN,
+              POS.Tag.XSV,
+              POS.Tag.UNA,
+              POS.Tag.NA,
+              POS.Tag.VSV));
 
   /**
    * Create a new {@link KoreanPartOfSpeechStopFilter} with the default list of stop tags {@link