maedhroz commented on a change in pull request #1205:
URL: https://github.com/apache/cassandra/pull/1205#discussion_r782573747



##########
File path: src/java/org/apache/cassandra/auth/AuthCacheService.java
##########
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.cassandra.auth;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Preconditions;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class AuthCacheService
+{
+    private static final Logger logger = 
LoggerFactory.getLogger(AuthCacheService.class);
+    public static final AuthCacheService instance = new AuthCacheService();
+
+    private final Set<AuthCache<?, ?>> caches = new HashSet<>();

Review comment:
       A few questions around this `caches` state and how it's protected...
   
   The first thing I noticed is that `warmCaches()` isn't synchronized, so we 
might be left open to a `ConcurrentModificationException`. Then I started 
looking at the actual sources of possible concurrent access to `caches`. It 
seems like the primary startup pathway isn't really a concern, but the 
`nodetool` commands for resuming bootstrap and join might be, since they hit 
`doAuthSetup()`. It that's the case, the `warmCaches()` issue above stands, but 
also only `Roles.init()` seems to protect us against double-adding its `cache`. 
(For `AuthenticatedUser`, that would be `permissionsCache` and 
`networkPermissionsCache`.) Then again, registering a few more things to 
`caches` on those `nodetool` commands might no matter, given `warmCaches()` is 
only called from `CassandraDaemon#setup()`. Finally, `Roles.init()` and 
`PasswordAuthenticator#setup()` aren't synchronized, so their `cache` fields 
aren't protected.




-- 
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]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to