diff --git a/src/main/java/org/opensearch/security/configuration/DlsFlsValveImpl.java b/src/main/java/org/opensearch/security/configuration/DlsFlsValveImpl.java index ede36819ed..abe65a717a 100644 --- a/src/main/java/org/opensearch/security/configuration/DlsFlsValveImpl.java +++ b/src/main/java/org/opensearch/security/configuration/DlsFlsValveImpl.java @@ -680,7 +680,7 @@ static Mode get(Settings settings) { public void updateConfiguration(SecurityDynamicConfiguration rolesConfiguration) { try { if (rolesConfiguration != null) { - this.dlsFlsProcessedConfig.set( + DlsFlsProcessedConfig oldConfig = this.dlsFlsProcessedConfig.getAndSet( new DlsFlsProcessedConfig( DynamicConfigFactory.addStatics(rolesConfiguration.clone()), clusterService.state().metadata().getIndicesLookup(), @@ -689,6 +689,10 @@ public void updateConfiguration(SecurityDynamicConfiguration rolesConfig fieldMaskingConfig ) ); + + if (oldConfig != null) { + oldConfig.shutdown(); + } } } catch (Exception e) { log.error("Error while updating DLS/FLS configuration with {}", rolesConfiguration, e);