Skip to content

Commit bf32356

Browse files
committed
accidental commit, reverting
1 parent 8d39db9 commit bf32356

File tree

1 file changed

+9
-32
lines changed
  • x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/privilege

1 file changed

+9
-32
lines changed

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/privilege/IndexPrivilege.java

Lines changed: 9 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,8 @@
3333
import org.elasticsearch.action.search.TransportSearchShardsAction;
3434
import org.elasticsearch.action.support.IndexComponentSelector;
3535
import org.elasticsearch.common.Strings;
36-
import org.elasticsearch.common.cache.Cache;
37-
import org.elasticsearch.common.cache.CacheBuilder;
38-
import org.elasticsearch.common.settings.Setting;
39-
import org.elasticsearch.common.settings.Settings;
4036
import org.elasticsearch.common.util.set.Sets;
4137
import org.elasticsearch.core.Nullable;
42-
import org.elasticsearch.core.TimeValue;
4338
import org.elasticsearch.index.seqno.RetentionLeaseActions;
4439
import org.elasticsearch.xpack.core.ccr.action.ForgetFollowerAction;
4540
import org.elasticsearch.xpack.core.ccr.action.PutFollowAction;
@@ -58,7 +53,7 @@
5853
import java.util.Map;
5954
import java.util.Set;
6055
import java.util.SortedMap;
61-
import java.util.concurrent.ExecutionException;
56+
import java.util.concurrent.ConcurrentHashMap;
6257
import java.util.function.Predicate;
6358
import java.util.stream.Collectors;
6459
import java.util.stream.Stream;
@@ -290,21 +285,7 @@ private static Map<String, IndexPrivilege> combineSortedInOrder(
290285
public static final Predicate<String> ACTION_MATCHER = ALL.predicate();
291286
public static final Predicate<String> CREATE_INDEX_MATCHER = CREATE_INDEX.predicate();
292287

293-
static final Setting<Integer> CACHE_SIZE = Setting.intSetting(
294-
"xpack.security.privilege.index.cache.size",
295-
10_000,
296-
Setting.Property.NodeScope
297-
);
298-
static final Setting<TimeValue> CACHE_TTL = Setting.timeSetting(
299-
"xpack.security.privilege.index.cache.ttl",
300-
TimeValue.timeValueHours(48),
301-
Setting.Property.NodeScope
302-
);
303-
304-
private static final Cache<Set<String>, Set<IndexPrivilege>> CACHE = CacheBuilder.<Set<String>, Set<IndexPrivilege>>builder()
305-
.setExpireAfterAccess(CACHE_TTL.get(Settings.EMPTY))
306-
.setMaximumWeight(CACHE_SIZE.get(Settings.EMPTY))
307-
.build();
288+
private static final ConcurrentHashMap<Set<String>, Set<IndexPrivilege>> CACHE = new ConcurrentHashMap<>();
308289

309290
private final IndexComponentSelectorPredicate selectorPredicate;
310291

@@ -359,17 +340,13 @@ public static IndexPrivilege get(String actionOrPrivilege) {
359340
* All raw actions are treated as granting access to the {@link IndexComponentSelector#DATA} selector.
360341
*/
361342
public static Set<IndexPrivilege> resolveBySelectorAccess(Set<String> names) {
362-
try {
363-
return CACHE.computeIfAbsent(names, (theName) -> {
364-
if (theName.isEmpty()) {
365-
return Set.of(NONE);
366-
} else {
367-
return resolve(theName);
368-
}
369-
});
370-
} catch (ExecutionException e) {
371-
throw new RuntimeException(e);
372-
}
343+
return CACHE.computeIfAbsent(names, (theName) -> {
344+
if (theName.isEmpty()) {
345+
return Set.of(NONE);
346+
} else {
347+
return resolve(theName);
348+
}
349+
});
373350
}
374351

375352
@Nullable

0 commit comments

Comments
 (0)