Skip to content

Commit 120e83d

Browse files
committed
Empty cache after change
Signed-off-by: Craig Perkins <[email protected]>
1 parent fdfe49f commit 120e83d

File tree

1 file changed

+0
-28
lines changed

1 file changed

+0
-28
lines changed

src/main/java/org/opensearch/security/auth/BackendRegistry.java

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
import java.net.InetSocketAddress;
3131
import java.util.Collection;
3232
import java.util.Collections;
33-
import java.util.HashMap;
3433
import java.util.HashSet;
3534
import java.util.List;
3635
import java.util.Map;
@@ -107,13 +106,6 @@ public class BackendRegistry {
107106
private Cache<User, Set<String>> restRoleCache; //
108107

109108
private void createCaches() {
110-
Map<AuthCredentials, User> existingUserCache = new HashMap<>();
111-
Map<String, User> existingRestImpersonationCache = new HashMap<>();
112-
Map<User, Set<String>> existingRestRoleCache = new HashMap<>();
113-
if (userCache != null) {
114-
existingUserCache.putAll(userCache.asMap());
115-
}
116-
117109
userCache = CacheBuilder.newBuilder()
118110
.expireAfterWrite(ttlInMin, TimeUnit.MINUTES)
119111
.removalListener(new RemovalListener<AuthCredentials, User>() {
@@ -124,14 +116,6 @@ public void onRemoval(RemovalNotification<AuthCredentials, User> notification) {
124116
})
125117
.build();
126118

127-
if (!existingUserCache.isEmpty()) {
128-
userCache.putAll(existingUserCache);
129-
}
130-
131-
if (restImpersonationCache != null) {
132-
existingRestImpersonationCache.putAll(restImpersonationCache.asMap());
133-
}
134-
135119
restImpersonationCache = CacheBuilder.newBuilder()
136120
.expireAfterWrite(ttlInMin, TimeUnit.MINUTES)
137121
.removalListener(new RemovalListener<String, User>() {
@@ -142,14 +126,6 @@ public void onRemoval(RemovalNotification<String, User> notification) {
142126
})
143127
.build();
144128

145-
if (!existingRestImpersonationCache.isEmpty()) {
146-
restImpersonationCache.putAll(existingRestImpersonationCache);
147-
}
148-
149-
if (restRoleCache != null) {
150-
restRoleCache.putAll(existingRestRoleCache);
151-
}
152-
153129
restRoleCache = CacheBuilder.newBuilder()
154130
.expireAfterWrite(ttlInMin, TimeUnit.MINUTES)
155131
.removalListener(new RemovalListener<User, Set<String>>() {
@@ -159,10 +135,6 @@ public void onRemoval(RemovalNotification<User, Set<String>> notification) {
159135
}
160136
})
161137
.build();
162-
163-
if (!existingRestRoleCache.isEmpty()) {
164-
restRoleCache.putAll(existingRestRoleCache);
165-
}
166138
}
167139

168140
public void registerClusterSettingsChangeListener(final ClusterSettings clusterSettings) {

0 commit comments

Comments
 (0)