knox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kris...@apache.org
Subject knox git commit: KNOX-1552 - DefaultKeystoreService cache doesn't add entries to cache
Date Thu, 08 Nov 2018 16:27:06 GMT
Repository: knox
Updated Branches:
  refs/heads/master 7968d476e -> d3046fee5


KNOX-1552 - DefaultKeystoreService cache doesn't add entries to cache

Signed-off-by: Kevin Risden <krisden@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/knox/repo
Commit: http://git-wip-us.apache.org/repos/asf/knox/commit/d3046fee
Tree: http://git-wip-us.apache.org/repos/asf/knox/tree/d3046fee
Diff: http://git-wip-us.apache.org/repos/asf/knox/diff/d3046fee

Branch: refs/heads/master
Commit: d3046fee5084968978d1802f2f9753a037dca9ff
Parents: 7968d47
Author: Kevin Risden <krisden@apache.org>
Authored: Fri Nov 2 17:30:08 2018 -0400
Committer: Kevin Risden <krisden@apache.org>
Committed: Thu Nov 8 11:26:45 2018 -0500

----------------------------------------------------------------------
 .../security/impl/DefaultKeystoreService.java   | 35 +++++++++-----------
 1 file changed, 16 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/knox/blob/d3046fee/gateway-server/src/main/java/org/apache/knox/gateway/services/security/impl/DefaultKeystoreService.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/main/java/org/apache/knox/gateway/services/security/impl/DefaultKeystoreService.java
b/gateway-server/src/main/java/org/apache/knox/gateway/services/security/impl/DefaultKeystoreService.java
index 08257ca..c2c7a17 100644
--- a/gateway-server/src/main/java/org/apache/knox/gateway/services/security/impl/DefaultKeystoreService.java
+++ b/gateway-server/src/main/java/org/apache/knox/gateway/services/security/impl/DefaultKeystoreService.java
@@ -446,37 +446,34 @@ public class DefaultKeystoreService extends BaseKeystoreService implements
   private char[] checkCache(String clusterName, String alias) {
     char[] c = null;
     String cred = null;
-      HashMap<String, String> clusterCache = (HashMap<String, String>) cache.get(clusterName);
-      if (clusterCache == null) {
-        return null;
-      }
-      cred = clusterCache.get(alias);
-      if (cred != null) {
-        c = cred.toCharArray();
-      }
-      return c;
+    Map<String, String> clusterCache = cache.get(clusterName);
+    if (clusterCache == null) {
+      return null;
+    }
+    cred = clusterCache.get(alias);
+    if (cred != null) {
+      c = cred.toCharArray();
+    }
+    return c;
   }
 
   /**
    * Called only from within critical sections of other methods above.
    */
   private void addToCache(String clusterName, String alias, String credentialString) {
-      HashMap<String, String> clusterCache = (HashMap<String, String>) cache.get(clusterName);
-      if (clusterCache == null) {
-        clusterCache = new HashMap<>();
-      }
-      clusterCache.put(alias, credentialString);
+    Map<String, String> clusterCache = cache.computeIfAbsent(clusterName, k -> new
HashMap<>());
+    clusterCache.put(alias, credentialString);
   }
 
   /**
    * Called only from within critical sections of other methods above.
    */
   private void removeFromCache(String clusterName, String alias) {
-      HashMap<String, String> clusterCache = (HashMap<String, String>) cache.get(clusterName);
-      if (clusterCache == null) {
-        return;
-      }
-      clusterCache.remove(alias);
+    Map<String, String> clusterCache = cache.get(clusterName);
+    if (clusterCache == null) {
+      return;
+    }
+    clusterCache.remove(alias);
   }
 
   @Override


Mime
View raw message