Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public void checkAccess(ThreadGroup g) {
}

@SuppressForbidden(reason = "java.security.debug messages go to standard error")
private void debugThreadGroups(final ThreadGroup caller, final ThreadGroup target) {
private static void debugThreadGroups(final ThreadGroup caller, final ThreadGroup target) {
System.err.println("access: caller group=" + caller);
System.err.println("access: target group=" + target);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ private void diagnose(CertificateException cause, X509Certificate[] chain, SslDi
logger.warning(diagnostic, cause);
}

private SSLSession session(Socket socket) {
private static SSLSession session(Socket socket) {
if (socket instanceof final SSLSocket ssl) {
final SSLSession handshakeSession = ssl.getHandshakeSession();
if (handshakeSession == null) {
Expand All @@ -149,7 +149,7 @@ private SSLSession session(Socket socket) {
}
}

private SSLSession session(SSLEngine engine) {
private static SSLSession session(SSLEngine engine) {
return engine.getHandshakeSession();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ protected SslTrustConfig buildTrustConfig(Path basePath, SslVerificationMode ver
return buildDefaultTrustConfig(defaultTrustConfig, keyConfig);
}

protected SslTrustConfig buildDefaultTrustConfig(SslTrustConfig trustConfig, SslKeyConfig keyConfig) {
protected static SslTrustConfig buildDefaultTrustConfig(SslTrustConfig trustConfig, SslKeyConfig keyConfig) {
final SslTrustConfig trust = keyConfig.asTrustConfig();
if (trust == null) {
return trustConfig;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ private SslConfigException keystoreException(Path path, GeneralSecurityException
/**
* Verifies that the keystore contains at least 1 private key entry.
*/
private void checkKeyStore(KeyStore keyStore, Path path) throws KeyStoreException {
private static void checkKeyStore(KeyStore keyStore, Path path) throws KeyStoreException {
Enumeration<String> aliases = keyStore.aliases();
while (aliases.hasMoreElements()) {
String alias = aliases.nextElement();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ private String fileTypeForException() {
/**
* Verifies that the keystore contains at least 1 trusted certificate entry.
*/
private void checkTrustStore(KeyStore store, Path path) throws GeneralSecurityException {
private static void checkTrustStore(KeyStore store, Path path) throws GeneralSecurityException {
Enumeration<String> aliases = store.aliases();
while (aliases.hasMoreElements()) {
String alias = aliases.nextElement();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ public void close() {
IOUtils.closeWhileHandlingException(parser);
}

private NumberType convertNumberType(JsonParser.NumberType numberType) {
private static NumberType convertNumberType(JsonParser.NumberType numberType) {
return switch (numberType) {
case INT -> NumberType.INT;
case BIG_INTEGER -> NumberType.BIG_INTEGER;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ int getNumberOfFields() {
* Constructor arguments are detected by this "marker" consumer. It
* keeps the API looking clean even if it is a bit sleezy.
*/
private boolean isConstructorArg(BiConsumer<?, ?> consumer) {
private static boolean isConstructorArg(BiConsumer<?, ?> consumer) {
return consumer == REQUIRED_CONSTRUCTOR_ARG_MARKER || consumer == OPTIONAL_CONSTRUCTOR_ARG_MARKER;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public MediaTypeRegistry<T> register(T[] mediaTypes) {
return this;
}

private Map<String, Pattern> convertPatterns(Map<String, String> paramNameAndValueRegex) {
private static Map<String, Pattern> convertPatterns(Map<String, String> paramNameAndValueRegex) {
Map<String, Pattern> parametersForMediaType = new HashMap<>(paramNameAndValueRegex.size());
for (Map.Entry<String, String> params : paramNameAndValueRegex.entrySet()) {
String parameterName = params.getKey().toLowerCase(Locale.ROOT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public NamedXContentRegistry(List<Entry> entries) {
this.registry = unmodifiableMap(createRegistry(entries));
}

private Map<RestApiVersion, Map<Class<?>, Map<String, Entry>>> createRegistry(List<Entry> entries) {
private static Map<RestApiVersion, Map<Class<?>, Map<String, Entry>>> createRegistry(List<Entry> entries) {
if (entries.isEmpty()) {
return emptyMap();
}
Expand All @@ -109,7 +109,7 @@ private Map<RestApiVersion, Map<Class<?>, Map<String, Entry>>> createRegistry(Li
return newRegistry;
}

private void registerParsers(
private static void registerParsers(
Map<RestApiVersion, Map<Class<?>, Map<String, Entry>>> newRegistry,
Entry entry,
String name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -340,15 +340,15 @@ private void throwNoFieldFound(XContentParser parser) {
throw new XContentParseException(parser.getTokenLocation(), "[" + name + "] no field found");
}

private void throwMissingRequiredFields(List<String[]> requiredFields) {
private static void throwMissingRequiredFields(List<String[]> requiredFields) {
final StringBuilder message = new StringBuilder();
for (String[] fields : requiredFields) {
message.append("Required one of fields ").append(Arrays.toString(fields)).append(", but none were specified. ");
}
throw new IllegalArgumentException(message.toString());
}

private void ensureExclusiveFields(List<List<String>> exclusiveFields) {
private static void ensureExclusiveFields(List<List<String>> exclusiveFields) {
StringBuilder message = null;
for (List<String> fieldset : exclusiveFields) {
if (fieldset.size() > 1) {
Expand All @@ -373,7 +373,7 @@ private void maybeMarkExclusiveField(String currentFieldName, List<List<String>>
}
}

private void maybeMarkRequiredField(String currentFieldName, List<String[]> requiredFields) {
private static void maybeMarkRequiredField(String currentFieldName, List<String[]> requiredFields) {
Iterator<String[]> iter = requiredFields.iterator();
while (iter.hasNext()) {
String[] requiredFieldNames = iter.next();
Expand Down Expand Up @@ -522,7 +522,7 @@ public <T> void declareNamedObjects(
}, field, ValueType.OBJECT_ARRAY);
}

private <T> void parseObjectsInArray(
private static <Value, Context, T> void parseObjectsInArray(
Consumer<Value> orderedModeCallback,
ParseField field,
BiFunction<XContentParser, Context, T> objectParser,
Expand All @@ -546,7 +546,7 @@ private <T> void parseObjectsInArray(
}
}

private XContentParseException wrapCanBeObjectOrArrayOfObjects(ParseField field, XContentParser p) {
private static XContentParseException wrapCanBeObjectOrArrayOfObjects(ParseField field, XContentParser p) {
return new XContentParseException(
p.getTokenLocation(),
"["
Expand All @@ -556,11 +556,11 @@ private XContentParseException wrapCanBeObjectOrArrayOfObjects(ParseField field,
);
}

private XContentParseException wrapParseError(ParseField field, XContentParser p, IOException e, String s) {
private static XContentParseException wrapParseError(ParseField field, XContentParser p, IOException e, String s) {
return new XContentParseException(p.getTokenLocation(), "[" + field + "] " + s, e);
}

private XContentParseException rethrowFieldParseFailure(ParseField field, XContentParser p, String currentName, Exception e) {
private static XContentParseException rethrowFieldParseFailure(ParseField field, XContentParser p, String currentName, Exception e) {
return new XContentParseException(p.getTokenLocation(), "[" + field + "] failed to parse field [" + currentName + "]", e);
}

Expand Down Expand Up @@ -668,7 +668,7 @@ private void parseSub(XContentParser parser, FieldParser fieldParser, String cur
}
}

private void throwMustEndOn(String currentFieldName, XContentParser.Token token) {
private static void throwMustEndOn(String currentFieldName, XContentParser.Token token) {
throw new IllegalStateException("parser for [" + currentFieldName + "] did not end on " + token);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public <T extends MediaType> T toMediaType(MediaTypeRegistry<T> mediaTypeRegistr
return null;
}

private boolean isValidParameter(String paramName, String value, Map<String, Pattern> registeredParams) {
private static boolean isValidParameter(String paramName, String value, Map<String, Pattern> registeredParams) {
if (registeredParams.containsKey(paramName)) {
Pattern regex = registeredParams.get(paramName);
return regex.matcher(value).matches();
Expand All @@ -162,7 +162,7 @@ public String responseContentTypeHeader(Map<String, String> params) {
return mediaTypeWithoutParameters() + formatParameters(params);
}

private String formatParameters(Map<String, String> params) {
private static String formatParameters(Map<String, String> params) {
String joined = params.entrySet().stream().map(e -> e.getKey() + "=" + e.getValue()).collect(Collectors.joining(";"));
return joined.isEmpty() ? "" : ";" + joined;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ private boolean matchFieldNamesWithDots(String name, int dotIndex, List<FilterPa
}

private static class FilterPathBuilder {
private class BuildNode {
private static class BuildNode {
private final Map<String, BuildNode> children;
private final boolean isFinalNode;

Expand All @@ -141,7 +141,7 @@ private class BuildNode {
}
}

private BuildNode root = new BuildNode(false);
private final BuildNode root = new BuildNode(false);

void insert(String filter) {
insertNode(filter, root);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public CharGroupTokenizerFactory(IndexSettings indexSettings, Environment enviro
}
}

private char parseEscapedChar(final String s) {
private static char parseEscapedChar(final String s) {
int len = s.length();
char c = s.charAt(0);
if (c == '\\') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public TokenStream create(TokenStream tokenStream) {
return minHashFilterFactory.create(tokenStream);
}

private Map<String, String> convertSettings(Settings settings) {
private static Map<String, String> convertSettings(Settings settings) {
Map<String, String> settingMap = new HashMap<>();
if (settings.hasValue("hash_count")) {
settingMap.put("hashCount", settings.get("hash_count"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public AnalysisMode getAnalysisMode() {
};
}

private TokenFilterFactory chainFilters(String name, List<TokenFilterFactory> filters) {
private static TokenFilterFactory chainFilters(String name, List<TokenFilterFactory> filters) {
return new TokenFilterFactory() {
@Override
public String name() {
Expand All @@ -137,7 +137,7 @@ private TokenFilterFactory resolveFilterFactory(Function<String, TokenFilterFact
}
}

private final class MultiplexTokenFilter extends TokenFilter {
private static final class MultiplexTokenFilter extends TokenFilter {

private final TokenStream source;
private final int filterCount;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public TokenFilterFactory getChainAwareTokenFilterFactory(
List<TokenFilterFactory> previousTokenFilters,
Function<String, TokenFilterFactory> allFilters
) {
final Analyzer analyzer = buildSynonymAnalyzer(tokenizer, charFilters, previousTokenFilters, allFilters);
final Analyzer analyzer = buildSynonymAnalyzer(tokenizer, charFilters, previousTokenFilters);
final SynonymMap synonyms = buildSynonyms(analyzer, getRulesFromSettings(environment));
final String name = name();
return new TokenFilterFactory() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public TokenFilterFactory getChainAwareTokenFilterFactory(
List<TokenFilterFactory> previousTokenFilters,
Function<String, TokenFilterFactory> allFilters
) {
final Analyzer analyzer = buildSynonymAnalyzer(tokenizer, charFilters, previousTokenFilters, allFilters);
final Analyzer analyzer = buildSynonymAnalyzer(tokenizer, charFilters, previousTokenFilters);
final SynonymMap synonyms = buildSynonyms(analyzer, getRulesFromSettings(environment));
final String name = name();
return new TokenFilterFactory() {
Expand Down Expand Up @@ -108,11 +108,10 @@ public AnalysisMode getAnalysisMode() {
};
}

Analyzer buildSynonymAnalyzer(
static Analyzer buildSynonymAnalyzer(
TokenizerFactory tokenizer,
List<CharFilterFactory> charFilters,
List<TokenFilterFactory> tokenFilters,
Function<String, TokenFilterFactory> allFilters
List<TokenFilterFactory> tokenFilters
) {
return new CustomAnalyzer(
tokenizer,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public TokenFilterFactory getSynonymFilter() {
throw new IllegalArgumentException("Token filter [" + name() + "] cannot be used to parse synonyms");
}

private int getFlag(int flag, Settings settings, String key, boolean defaultValue) {
private static int getFlag(int flag, Settings settings, String key, boolean defaultValue) {
if (settings.getAsBoolean(key, defaultValue)) {
return flag;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,15 @@ public TokenFilterFactory getSynonymFilter() {
throw new IllegalArgumentException("Token filter [" + name() + "] cannot be used to parse synonyms");
}

public int getFlag(int flag, Settings settings, String key, boolean defaultValue) {
public static int getFlag(int flag, Settings settings, String key, boolean defaultValue) {
if (settings.getAsBoolean(key, defaultValue)) {
return flag;
}
return 0;
}

// source => type
private static Pattern typePattern = Pattern.compile("(.*)\\s*=>\\s*(.*)\\s*$");
private static final Pattern typePattern = Pattern.compile("(.*)\\s*=>\\s*(.*)\\s*$");

/**
* parses a list of MappingCharFilter style rules into a custom byte[] type table
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,11 @@ public void testTokenFiltersBypassSynonymAnalysis() throws IOException {
TokenFilterFactory tff = plugin.getTokenFilters().get(factory).get(idxSettings, null, factory, settings);
TokenizerFactory tok = new KeywordTokenizerFactory(idxSettings, null, "keyword", settings);
SynonymTokenFilterFactory stff = new SynonymTokenFilterFactory(idxSettings, null, "synonym", settings);
Analyzer analyzer = stff.buildSynonymAnalyzer(tok, Collections.emptyList(), Collections.singletonList(tff), null);
Analyzer analyzer = SynonymTokenFilterFactory.buildSynonymAnalyzer(
tok,
Collections.emptyList(),
Collections.singletonList(tff)
);

try (TokenStream ts = analyzer.tokenStream("field", "text")) {
assertThat(ts, instanceOf(KeywordTokenizer.class));
Expand Down Expand Up @@ -308,7 +312,7 @@ public void testDisallowedTokenFilters() throws IOException {
IllegalArgumentException e = expectThrows(
IllegalArgumentException.class,
"Expected IllegalArgumentException for factory " + factory,
() -> stff.buildSynonymAnalyzer(tok, Collections.emptyList(), Collections.singletonList(tff), null)
() -> SynonymTokenFilterFactory.buildSynonymAnalyzer(tok, Collections.emptyList(), Collections.singletonList(tff))
);

assertEquals(factory, "Token filter [" + factory + "] cannot be used to parse synonyms", e.getMessage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ private char currentChar() {
return line.charAt(currentIndex);
}

private boolean isWhitespace(char c) {
private static boolean isWhitespace(char c) {
return c == SPACE || c == TAB;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ Function<String, ZonedDateTime> getFunction(String format, ZoneId timezone, Loca
return date -> Instant.ofEpochMilli(parseMillis(date)).atZone(timezone);
}

private long parseMillis(String date) {
private static long parseMillis(String date) {
if (date.startsWith("@")) {
date = date.substring(1);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ public byte[] digest() {

@Override
public String getAlgorithm() {
return mh.getAlgorithm();
return Murmur3Hasher.getAlgorithm();
}
}

Expand Down
Loading