Skip to content

Commit

Permalink
Remove commons-collections 3.2.2 (#2924)
Browse files Browse the repository at this point in the history
Signed-off-by: Andrey Pleskach <[email protected]>
(cherry picked from commit 49cbf52)
Signed-off-by: Andrey Pleskach <[email protected]>
  • Loading branch information
willyborankin committed Jul 8, 2023
1 parent a198148 commit 4e0ac23
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 9 deletions.
1 change: 0 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,6 @@ dependencies {
runtimeOnly 'org.opensaml:opensaml-soap-impl:3.4.5'
implementation 'org.opensaml:opensaml-storage-api:3.4.5'
implementation 'commons-lang:commons-lang:2.4'
implementation 'commons-collections:commons-collections:3.2.2'
implementation 'com.jayway.jsonpath:json-path:2.4.0'
implementation "org.apache.httpcomponents:httpclient:${versions.httpclient}"
implementation 'net.minidev:json-smart:2.4.10'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@
import java.util.List;
import java.util.ListIterator;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.regex.PatternSyntaxException;
import java.util.stream.Collectors;

import com.google.common.collect.ImmutableSet;
import org.apache.commons.collections.keyvalue.MultiKey;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.greenrobot.eventbus.Subscribe;
Expand Down Expand Up @@ -112,7 +112,7 @@ public IndexResolverReplacer(IndexNameExpressionResolver resolver, ClusterServic
this.clusterInfoHolder = clusterInfoHolder;
}

private static final boolean isAllWithNoRemote(final String... requestedPatterns) {
private static boolean isAllWithNoRemote(final String... requestedPatterns) {

final List<String> patterns = requestedPatterns == null ? null : Arrays.asList(requestedPatterns);

Expand All @@ -131,11 +131,11 @@ private static final boolean isAllWithNoRemote(final String... requestedPatterns
return false;
}

private static final boolean isLocalAll(String... requestedPatterns) {
private static boolean isLocalAll(String... requestedPatterns) {
return isLocalAll(requestedPatterns == null ? null : Arrays.asList(requestedPatterns));
}

private static final boolean isLocalAll(Collection<String> patterns) {
private static boolean isLocalAll(Collection<String> patterns) {
if (IndexNameExpressionResolver.isAllIndices(patterns)) {
return true;
}
Expand All @@ -158,9 +158,49 @@ private class ResolvedIndicesProvider implements IndicesProvider {
private final ImmutableSet.Builder<String> remoteIndices;
// set of previously resolved index requests to avoid resolving
// the same index more than once while processing bulk requests
private final Set<MultiKey> alreadyResolved;
private final Set<AlreadyResolvedKey> alreadyResolved;
private final String name;

private final class AlreadyResolvedKey {

private final IndicesOptions indicesOptions;

private final boolean enableCrossClusterResolution;

private final String[] original;

private AlreadyResolvedKey(final IndicesOptions indicesOptions, final boolean enableCrossClusterResolution) {
this(indicesOptions, enableCrossClusterResolution, null);
}

private AlreadyResolvedKey(
final IndicesOptions indicesOptions,
final boolean enableCrossClusterResolution,
final String[] original
) {
this.indicesOptions = indicesOptions;
this.enableCrossClusterResolution = enableCrossClusterResolution;
this.original = original;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
AlreadyResolvedKey that = (AlreadyResolvedKey) o;
return enableCrossClusterResolution == that.enableCrossClusterResolution
&& Objects.equals(indicesOptions, that.indicesOptions)
&& Arrays.equals(original, that.original);
}

@Override
public int hashCode() {
int result = Objects.hash(indicesOptions, enableCrossClusterResolution);
result = 31 * result + Arrays.hashCode(original);
return result;
}
}

ResolvedIndicesProvider(Object request) {
aliases = ImmutableSet.builder();
allIndices = ImmutableSet.builder();
Expand Down Expand Up @@ -336,9 +376,13 @@ public String[] provide(String[] original, Object localRequest, boolean supports
|| localRequest instanceof SearchRequest
|| localRequest instanceof ResolveIndexAction.Request;
// skip the whole thing if we have seen this exact resolveIndexPatterns request
if (alreadyResolved.add(
new MultiKey(indicesOptions, enableCrossClusterResolution, (original != null) ? new MultiKey(original, false) : null)
)) {
final AlreadyResolvedKey alreadyResolvedKey;
if (original != null) {
alreadyResolvedKey = new AlreadyResolvedKey(indicesOptions, enableCrossClusterResolution, original);
} else {
alreadyResolvedKey = new AlreadyResolvedKey(indicesOptions, enableCrossClusterResolution);
}
if (alreadyResolved.add(alreadyResolvedKey)) {
resolveIndexPatterns(localRequest.getClass().getSimpleName(), indicesOptions, enableCrossClusterResolution, original);
}
return IndicesProvider.NOOP;
Expand Down

0 comments on commit 4e0ac23

Please sign in to comment.