From 219c42d7cedac58cc9c56457f37ea35572fba06e Mon Sep 17 00:00:00 2001 From: Jay Modi Date: Thu, 13 Oct 2016 09:27:51 -0400 Subject: [PATCH] update to use TimeValue in CacheBuilder Original commit: elastic/x-pack-elasticsearch@7f5a59bd73ac7ec42c42acf40f635b8a22ff85a9 --- .../security/authc/support/CachingUsernamePasswordRealm.java | 4 ++-- .../xpack/security/authz/store/NativeRolesStore.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/elasticsearch/src/main/java/org/elasticsearch/xpack/security/authc/support/CachingUsernamePasswordRealm.java b/elasticsearch/src/main/java/org/elasticsearch/xpack/security/authc/support/CachingUsernamePasswordRealm.java index 142276af267..931b2456479 100644 --- a/elasticsearch/src/main/java/org/elasticsearch/xpack/security/authc/support/CachingUsernamePasswordRealm.java +++ b/elasticsearch/src/main/java/org/elasticsearch/xpack/security/authc/support/CachingUsernamePasswordRealm.java @@ -36,9 +36,9 @@ public abstract class CachingUsernamePasswordRealm extends UsernamePasswordRealm super(type, config); hasher = Hasher.resolve(config.settings().get(CACHE_HASH_ALGO_SETTING, null), Hasher.SSHA256); TimeValue ttl = config.settings().getAsTime(CACHE_TTL_SETTING, DEFAULT_TTL); - if (ttl.millis() > 0) { + if (ttl.getNanos() > 0) { cache = CacheBuilder.builder() - .setExpireAfterAccess(TimeUnit.MILLISECONDS.toNanos(ttl.getMillis())) + .setExpireAfterAccess(ttl) .setMaximumWeight(config.settings().getAsInt(CACHE_MAX_USERS_SETTING, DEFAULT_MAX_USERS)) .build(); } else { diff --git a/elasticsearch/src/main/java/org/elasticsearch/xpack/security/authz/store/NativeRolesStore.java b/elasticsearch/src/main/java/org/elasticsearch/xpack/security/authz/store/NativeRolesStore.java index c4964ce7506..de8be2db93d 100644 --- a/elasticsearch/src/main/java/org/elasticsearch/xpack/security/authz/store/NativeRolesStore.java +++ b/elasticsearch/src/main/java/org/elasticsearch/xpack/security/authz/store/NativeRolesStore.java @@ -135,7 +135,7 @@ public class NativeRolesStore extends AbstractComponent implements RolesStore, C this.client = client; this.roleCache = CacheBuilder.builder() .setMaximumWeight(CACHE_SIZE_SETTING.get(settings)) - .setExpireAfterWrite(CACHE_TTL_SETTING.get(settings).getNanos()) + .setExpireAfterWrite(CACHE_TTL_SETTING.get(settings)) .build(); this.isTribeNode = settings.getGroups("tribe", true).isEmpty() == false; }