You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-issues@hadoop.apache.org by GitBox <gi...@apache.org> on 2022/03/31 10:56:48 UTC

[GitHub] [hadoop] 9uapaw commented on a change in pull request #4119: YARN-11103. SLS cleanup after previously merged SLS refactor jiras

9uapaw commented on a change in pull request #4119:
URL: https://github.com/apache/hadoop/pull/4119#discussion_r839443638



##########
File path: hadoop-tools/hadoop-sls/src/main/java/org/apache/hadoop/yarn/sls/AMRunner.java
##########
@@ -53,7 +53,7 @@
 
 public class AMRunner {
   private static final Logger LOG = LoggerFactory.getLogger(AMRunner.class);
-  static int REMAINING_APPS = 0;
+  static int remainingApps = 0;

Review comment:
       AFAIU SpotBugs does not warn because it is not thread safe. A non-static int is not thread safe either, unless you make it an AtomicInteger or wrap it around a mutex (though static AND thread unsafe variables are more dangerous I agree). SpotBugs simply warns because you are incrementing a static int outside of the class that owns it, hence it warns of a possible bug.
   In order to make it safer while removing the SpotBugs error:
   - Make it an AtomicInteger
   - Increment it via a static increment method (this is not any safer, but it would most probably remove the error message)




-- 
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: common-issues-unsubscribe@hadoop.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-issues-help@hadoop.apache.org