szetszwo commented on code in PR #1154:
URL: https://github.com/apache/ratis/pull/1154#discussion_r1776312405


##########
ratis-server/src/main/java/org/apache/ratis/server/impl/ConfigurationManager.java:
##########
@@ -42,10 +42,10 @@ public class ConfigurationManager {
    * the last entry of the map. Otherwise is initialConf.
    */
   @SuppressWarnings({"squid:S3077"}) // Suppress volatile for generic type
-  private volatile RaftConfigurationImpl currentConf;
+  private RaftConfigurationImpl currentConf;
   /** Cache the peer corresponding to {@link #id}. */
   @SuppressWarnings({"squid:S3077"}) // Suppress volatile for generic type
-  private volatile RaftPeer currentPeer;
+  private RaftPeer currentPeer;

Review Comment:
   Please remove also the `@SuppressWarnings({"squid:S3077"})` for both fields. 
 It was for the `volatile` [false 
positive](https://community.sonarsource.com/t/rule-s3077-frequently-generates-a-false-positive/27479).



##########
ratis-server/src/main/java/org/apache/ratis/server/impl/RoleInfo.java:
##########
@@ -47,7 +47,7 @@ class RoleInfo {
   public static final Logger LOG = LoggerFactory.getLogger(RoleInfo.class);
 
   private final RaftPeerId id;
-  private volatile RaftPeerRole role;
+  private final AtomicReference<RaftPeerRole> role = new AtomicReference<>();

Review Comment:
   Okay, I am fine to use `AtomicReference`.



##########
ratis-server/src/main/java/org/apache/ratis/server/impl/LeaderStateImpl.java:
##########
@@ -219,16 +219,13 @@ void addAll(Collection<LogAppender> newSenders) {
       Preconditions.assertTrue(changed);
     }
 
-    boolean removeAll(Collection<LogAppender> c) {
+    synchronized boolean removeAll(Collection<LogAppender> c) {

Review Comment:
   We don't need `synchronized` for both `addAll` and `removeAll` since it uses 
a `CopyOnWriteArrayList`.



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

Reply via email to