Uploaded image for project: 'Hama'
  1. Hama
  2. HAMA-971

An increment to a volatile field isn't atomic

Add voteWatch issue
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Patch Available
    • Minor
    • Resolution: Unresolved
    • None
    • None
    • bsp core
    • None

    Description

      I found a defect from FindBugs Analysis.

      // AsyncRcvdMsgCheckpointImpl.java
      volatile private long checkpointMessageCount;
      ...
      ++checkpointMessageCount;
      
      // Server.java
      private volatile int rpcCount = 0; // number of outstanding rpcs
      ...
      rpcCount--;
      rpcCount++;
      

      This code increments a volatile field. Increments of volatile fields aren't atomic. If more than one thread is incrementing the field at the same time, increments could be lost.

      I think AtomicInteger and AtomicLong can be used instead of volatile fields.

      Attachments

        1. HAMA-971.patch
          3 kB
          JongYoon Lim

        Activity

          People

            Unassigned Unassigned
            seedengine JongYoon Lim

            Dates

              Created:
              Updated:

              Slack

                Issue deployment