ex172000 commented on code in PR #14808:
URL: https://github.com/apache/kafka/pull/14808#discussion_r1401350219
##########
clients/src/main/java/org/apache/kafka/common/security/authenticator/CredentialCache.java:
##########
@@ -16,53 +16,59 @@
*/
package org.apache.kafka.common.security.authenticator;
+import org.apache.kafka.common.security.scram.ScramCache;
+
import java.util.concurrent.ConcurrentHashMap;
public class CredentialCache {
- private final ConcurrentHashMap<String, Cache<?>> cacheMap = new
ConcurrentHashMap<>();
+ private final ConcurrentHashMap<String, Cache> cacheMap = new
ConcurrentHashMap<>();
+
+ public Cache createCache(String mechanism) {
+ Cache credentials = new Cache();
+ Cache oldCredentials = cacheMap.putIfAbsent(mechanism, credentials);
+ return oldCredentials == null ? credentials : oldCredentials;
+ }
- public <C> Cache<C> createCache(String mechanism, Class<C>
credentialClass) {
- Cache<C> cache = new Cache<>(credentialClass);
- @SuppressWarnings("unchecked")
- Cache<C> oldCache = (Cache<C>) cacheMap.putIfAbsent(mechanism, cache);
- return oldCache == null ? cache : oldCache;
+ public ScramCache createScramCache(String mechanism) {
+ if (scramCache(mechanism) != null)
+ return scramCache(mechanism);
+ ScramCache credentials = new ScramCache();
+ cacheMap.putIfAbsent(mechanism, credentials);
+ return credentials;
}
- @SuppressWarnings("unchecked")
Review Comment:
Yes, it is.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]