From 78db68b01aee978e79e6f93af8d48139577f74d9 Mon Sep 17 00:00:00 2001 From: Nils Bandener Date: Fri, 2 Aug 2024 12:16:34 +0200 Subject: [PATCH] Capping heap size used by StatefulIndexPrivileges Signed-off-by: Nils Bandener --- build.gradle | 2 +- .../opensearch/security/privileges/ActionPrivileges.java | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/build.gradle b/build.gradle index c3658aa403..96cd373e2c 100644 --- a/build.gradle +++ b/build.gradle @@ -614,7 +614,7 @@ dependencies { implementation 'com.password4j:password4j:1.8.2' // Action privileges: check tables and compact collections - implementation 'com.selectivem.collections:special-collections-complete:1.3.0' + implementation 'com.selectivem.collections:special-collections-complete:1.3.1' //JWT implementation "io.jsonwebtoken:jjwt-api:${jjwt_version}" diff --git a/src/main/java/org/opensearch/security/privileges/ActionPrivileges.java b/src/main/java/org/opensearch/security/privileges/ActionPrivileges.java index 0b76137dc4..08bf56aee3 100644 --- a/src/main/java/org/opensearch/security/privileges/ActionPrivileges.java +++ b/src/main/java/org/opensearch/security/privileges/ActionPrivileges.java @@ -864,11 +864,11 @@ static class StatefulIndexPrivileges { String, CompactMapGroupBuilder.MapBuilder>> actionToIndexToRoles = new HashMap<>(); - CompactMapGroupBuilder> indexMapBuilder = - new CompactMapGroupBuilder<>(indices.keySet()); DeduplicatingCompactSubSetBuilder roleSetBuilder = new DeduplicatingCompactSubSetBuilder<>( roles.getCEntries().keySet() ); + CompactMapGroupBuilder> indexMapBuilder = + new CompactMapGroupBuilder<>(indices.keySet(), (k2) -> roleSetBuilder.createSubSetBuilder()); top: for (Map.Entry entry : roles.getCEntries().entrySet()) { try { @@ -907,7 +907,7 @@ static class StatefulIndexPrivileges { DeduplicatingCompactSubSetBuilder.SubSetBuilder> indexToRoles = actionToIndexToRoles .computeIfAbsent( action, - k -> indexMapBuilder.createMapBuilder((k2) -> roleSetBuilder.createSubSetBuilder()) + k -> indexMapBuilder.createMapBuilder() ); indexToRoles.get(indicesEntry.getKey()).add(roleName);