|
33 | 33 | import org.elasticsearch.action.search.TransportSearchShardsAction; |
34 | 34 | import org.elasticsearch.action.support.IndexComponentSelector; |
35 | 35 | 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; |
40 | 36 | import org.elasticsearch.common.util.set.Sets; |
41 | 37 | import org.elasticsearch.core.Nullable; |
42 | | -import org.elasticsearch.core.TimeValue; |
43 | 38 | import org.elasticsearch.index.seqno.RetentionLeaseActions; |
44 | 39 | import org.elasticsearch.xpack.core.ccr.action.ForgetFollowerAction; |
45 | 40 | import org.elasticsearch.xpack.core.ccr.action.PutFollowAction; |
|
58 | 53 | import java.util.Map; |
59 | 54 | import java.util.Set; |
60 | 55 | import java.util.SortedMap; |
61 | | -import java.util.concurrent.ExecutionException; |
| 56 | +import java.util.concurrent.ConcurrentHashMap; |
62 | 57 | import java.util.function.Predicate; |
63 | 58 | import java.util.stream.Collectors; |
64 | 59 | import java.util.stream.Stream; |
@@ -290,21 +285,7 @@ private static Map<String, IndexPrivilege> combineSortedInOrder( |
290 | 285 | public static final Predicate<String> ACTION_MATCHER = ALL.predicate(); |
291 | 286 | public static final Predicate<String> CREATE_INDEX_MATCHER = CREATE_INDEX.predicate(); |
292 | 287 |
|
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<>(); |
308 | 289 |
|
309 | 290 | private final IndexComponentSelectorPredicate selectorPredicate; |
310 | 291 |
|
@@ -359,17 +340,13 @@ public static IndexPrivilege get(String actionOrPrivilege) { |
359 | 340 | * All raw actions are treated as granting access to the {@link IndexComponentSelector#DATA} selector. |
360 | 341 | */ |
361 | 342 | 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 | + }); |
373 | 350 | } |
374 | 351 |
|
375 | 352 | @Nullable |
|
0 commit comments