[jboss-jira] [JBoss JIRA] Closed: (JBMESSAGING-1793) Non-atomic increment operation on volatile field lastReceivedCommandID in class ChannelImpl

Tim Fox (JIRA) jira-events at lists.jboss.org
Tue Mar 2 03:15:10 EST 2010


     [ https://jira.jboss.org/jira/browse/JBMESSAGING-1793?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Tim Fox closed JBMESSAGING-1793.
--------------------------------

    Resolution: Rejected


We understand what the semantics of volatile are.

But this method is never called by more than one thread *concurrently* so this is a non issue.

> Non-atomic increment operation on volatile field lastReceivedCommandID in class ChannelImpl
> -------------------------------------------------------------------------------------------
>
>                 Key: JBMESSAGING-1793
>                 URL: https://jira.jboss.org/jira/browse/JBMESSAGING-1793
>             Project: JBoss Messaging
>          Issue Type: Bug
>          Components: Messaging Core
>    Affects Versions: 2.0.0.beta4
>         Environment: OS: Redhat-5 Linux 2.6.18-92.el5
> JDK: java version "1.6.0"
> Java(TM) SE Runtime Environment (build pxi3260sr4-20090219_01(SR4))
> IBM J9 VM (build 2.4, J2RE 1.6.0 IBM J9 2.4 Linux x86-32 jvmxi3260-20090215_29883 (JIT enabled, AOT enabled)
> J9VM - 20090215_029883_lHdSMr
> JIT - r9_20090213_2028
> GC - 20090213_AA)
> JCL - 20090218_01 
>            Reporter: Daniel Luo
>   Original Estimate: 15 minutes
>  Remaining Estimate: 15 minutes
>
> In class ChannelImpl, field "lastReceivedCommandID" is declared as volatile int, in method confirm(xxx), lastReceivedCommandID++; is seen, which is a three-step (read->modify->write) non-atomic operation. Volatile keyword only guarantees variable visibility, but not atomicity, so statement "lastReceivedCommandID++;" invoked by multiple threads can result to race condition and incorrect result. It's suggested to use synchronized block to protect "lastReceivedCommandID++;" or AtomicInteger class from java.util.concurrent package to do atomic increment operation.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the jboss-jira mailing list