mirror of https://github.com/apache/lucene.git
LUCENE-8927: Set.copyOf and Set.of instead of Collections.unmodifiabl… (#796)
This commit is contained in:
parent
29f941baa2
commit
3e2ca05b8e
|
@ -145,21 +145,17 @@ public class DemoHTMLParser implements HTMLParser {
|
||||||
// assign body text
|
// assign body text
|
||||||
this.body = body.toString();
|
this.body = body.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Set<String> createElementNameSet(String... names) {
|
|
||||||
return Collections.unmodifiableSet(new HashSet<>(Arrays.asList(names)));
|
|
||||||
}
|
|
||||||
|
|
||||||
/** HTML elements that cause a line break (they are block-elements) */
|
/** HTML elements that cause a line break (they are block-elements) */
|
||||||
static final Set<String> ENDLINE_ELEMENTS = createElementNameSet(
|
static final Set<String> ENDLINE_ELEMENTS = Set.of(
|
||||||
"p", "h1", "h2", "h3", "h4", "h5", "h6", "div", "ul", "ol", "dl",
|
"p", "h1", "h2", "h3", "h4", "h5", "h6", "div", "ul", "ol", "dl",
|
||||||
"pre", "hr", "blockquote", "address", "fieldset", "table", "form",
|
"pre", "hr", "blockquote", "address", "fieldset", "table", "form",
|
||||||
"noscript", "li", "dt", "dd", "noframes", "br", "tr", "select", "option"
|
"noscript", "li", "dt", "dd", "noframes", "br", "tr", "select", "option"
|
||||||
);
|
);
|
||||||
|
|
||||||
/** HTML elements with contents that are ignored */
|
/** HTML elements with contents that are ignored */
|
||||||
static final Set<String> SUPPRESS_ELEMENTS = createElementNameSet(
|
static final Set<String> SUPPRESS_ELEMENTS = Set.of(
|
||||||
"style", "script"
|
"style", "script"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -421,7 +421,7 @@ public class FieldInfos implements Iterable<FieldInfo> {
|
||||||
return dvType == docValuesType.get(fieldName);
|
return dvType == docValuesType.get(fieldName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized void clear() {
|
synchronized void clear() {
|
||||||
numberToName.clear();
|
numberToName.clear();
|
||||||
nameToNumber.clear();
|
nameToNumber.clear();
|
||||||
|
|
|
@ -428,7 +428,7 @@ public abstract class FSDirectory extends BaseDirectory {
|
||||||
if (pendingDeletes.isEmpty()) {
|
if (pendingDeletes.isEmpty()) {
|
||||||
return Collections.emptySet();
|
return Collections.emptySet();
|
||||||
} else {
|
} else {
|
||||||
return Collections.unmodifiableSet(new HashSet<>(pendingDeletes));
|
return Set.copyOf(pendingDeletes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -136,7 +136,7 @@ public abstract class PrimaryNode extends Node {
|
||||||
message("top: now flushAndRefresh");
|
message("top: now flushAndRefresh");
|
||||||
Set<String> completedMergeFiles;
|
Set<String> completedMergeFiles;
|
||||||
synchronized(finishedMergedFiles) {
|
synchronized(finishedMergedFiles) {
|
||||||
completedMergeFiles = Collections.unmodifiableSet(new HashSet<>(finishedMergedFiles));
|
completedMergeFiles = Set.copyOf(finishedMergedFiles);
|
||||||
}
|
}
|
||||||
mgr.maybeRefreshBlocking();
|
mgr.maybeRefreshBlocking();
|
||||||
boolean result = setCurrentInfos(completedMergeFiles);
|
boolean result = setCurrentInfos(completedMergeFiles);
|
||||||
|
|
|
@ -593,14 +593,13 @@ public abstract class LuceneTestCase extends Assert {
|
||||||
private final static long STATIC_LEAK_THRESHOLD = 10 * 1024 * 1024;
|
private final static long STATIC_LEAK_THRESHOLD = 10 * 1024 * 1024;
|
||||||
|
|
||||||
/** By-name list of ignored types like loggers etc. */
|
/** By-name list of ignored types like loggers etc. */
|
||||||
private final static Set<String> STATIC_LEAK_IGNORED_TYPES = Collections.unmodifiableSet(new HashSet<>(Arrays.asList(
|
private final static Set<String> STATIC_LEAK_IGNORED_TYPES = Set.of(
|
||||||
"org.slf4j.Logger",
|
"org.slf4j.Logger",
|
||||||
"org.apache.solr.SolrLogFormatter",
|
"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
|
Path.class.getName(), // causes problems because interface is implemented by hidden classes
|
||||||
Class.class.getName(),
|
Class.class.getName(),
|
||||||
EnumSet.class.getName()
|
EnumSet.class.getName());
|
||||||
)));
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This controls how suite-level rules are nested. It is important that _all_ rules declared
|
* This controls how suite-level rules are nested. It is important that _all_ rules declared
|
||||||
|
|
Loading…
Reference in New Issue