diff --git a/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/DemoHTMLParser.java b/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/DemoHTMLParser.java index a1e6a3c013f..79eafbc5415 100644 --- a/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/DemoHTMLParser.java +++ b/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/DemoHTMLParser.java @@ -145,21 +145,17 @@ public class DemoHTMLParser implements HTMLParser { // assign body text this.body = body.toString(); } - - private static final Set createElementNameSet(String... names) { - return Collections.unmodifiableSet(new HashSet<>(Arrays.asList(names))); - } - + /** HTML elements that cause a line break (they are block-elements) */ - static final Set ENDLINE_ELEMENTS = createElementNameSet( - "p", "h1", "h2", "h3", "h4", "h5", "h6", "div", "ul", "ol", "dl", - "pre", "hr", "blockquote", "address", "fieldset", "table", "form", - "noscript", "li", "dt", "dd", "noframes", "br", "tr", "select", "option" + static final Set ENDLINE_ELEMENTS = Set.of( + "p", "h1", "h2", "h3", "h4", "h5", "h6", "div", "ul", "ol", "dl", + "pre", "hr", "blockquote", "address", "fieldset", "table", "form", + "noscript", "li", "dt", "dd", "noframes", "br", "tr", "select", "option" ); /** HTML elements with contents that are ignored */ - static final Set SUPPRESS_ELEMENTS = createElementNameSet( - "style", "script" + static final Set SUPPRESS_ELEMENTS = Set.of( + "style", "script" ); } diff --git a/lucene/core/src/java/org/apache/lucene/index/FieldInfos.java b/lucene/core/src/java/org/apache/lucene/index/FieldInfos.java index d9076d767d0..979a248f705 100644 --- a/lucene/core/src/java/org/apache/lucene/index/FieldInfos.java +++ b/lucene/core/src/java/org/apache/lucene/index/FieldInfos.java @@ -421,7 +421,7 @@ public class FieldInfos implements Iterable { return dvType == docValuesType.get(fieldName); } } - + synchronized void clear() { numberToName.clear(); nameToNumber.clear(); diff --git a/lucene/core/src/java/org/apache/lucene/store/FSDirectory.java b/lucene/core/src/java/org/apache/lucene/store/FSDirectory.java index cbaafb2f86d..d20df51d3ee 100644 --- a/lucene/core/src/java/org/apache/lucene/store/FSDirectory.java +++ b/lucene/core/src/java/org/apache/lucene/store/FSDirectory.java @@ -428,7 +428,7 @@ public abstract class FSDirectory extends BaseDirectory { if (pendingDeletes.isEmpty()) { return Collections.emptySet(); } else { - return Collections.unmodifiableSet(new HashSet<>(pendingDeletes)); + return Set.copyOf(pendingDeletes); } } } diff --git a/lucene/replicator/src/java/org/apache/lucene/replicator/nrt/PrimaryNode.java b/lucene/replicator/src/java/org/apache/lucene/replicator/nrt/PrimaryNode.java index 6b90c7843e5..f96f6d23395 100644 --- a/lucene/replicator/src/java/org/apache/lucene/replicator/nrt/PrimaryNode.java +++ b/lucene/replicator/src/java/org/apache/lucene/replicator/nrt/PrimaryNode.java @@ -136,7 +136,7 @@ public abstract class PrimaryNode extends Node { message("top: now flushAndRefresh"); Set completedMergeFiles; synchronized(finishedMergedFiles) { - completedMergeFiles = Collections.unmodifiableSet(new HashSet<>(finishedMergedFiles)); + completedMergeFiles = Set.copyOf(finishedMergedFiles); } mgr.maybeRefreshBlocking(); boolean result = setCurrentInfos(completedMergeFiles); diff --git a/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java b/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java index d6a875fcd9c..c0083b9167a 100644 --- a/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java +++ b/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java @@ -593,14 +593,13 @@ public abstract class LuceneTestCase extends Assert { private final static long STATIC_LEAK_THRESHOLD = 10 * 1024 * 1024; /** By-name list of ignored types like loggers etc. */ - private final static Set STATIC_LEAK_IGNORED_TYPES = Collections.unmodifiableSet(new HashSet<>(Arrays.asList( + private final static Set STATIC_LEAK_IGNORED_TYPES = Set.of( "org.slf4j.Logger", "org.apache.solr.SolrLogFormatter", - "java.io.File", // Solr sometimes refers to this in a static way, but it has a "java.nio.fs.Path" inside + "java.io.File", // Solr sometimes refers to this in a static way, but it has a "java.nio.fs.Path" inside Path.class.getName(), // causes problems because interface is implemented by hidden classes Class.class.getName(), - EnumSet.class.getName() - ))); + EnumSet.class.getName()); /** * This controls how suite-level rules are nested. It is important that _all_ rules declared