qpid-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (Jira)" <j...@apache.org>
Subject [jira] [Commented] (QPID-8510) [Broker-J] Incorect use of volatile modifier for array
Date Sat, 08 May 2021 20:17:00 GMT

    [ https://issues.apache.org/jira/browse/QPID-8510?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17341403#comment-17341403
] 

ASF GitHub Bot commented on QPID-8510:
--------------------------------------

asfgit closed pull request #84:
URL: https://github.com/apache/qpid-broker-j/pull/84


   


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

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


> [Broker-J] Incorect use of volatile modifier for array
> ------------------------------------------------------
>
>                 Key: QPID-8510
>                 URL: https://issues.apache.org/jira/browse/QPID-8510
>             Project: Qpid
>          Issue Type: Bug
>          Components: Broker-J
>            Reporter: Marek Laca
>            Priority: Minor
>              Labels: Broker, Java
>
> Based on Java documentation a change of volatile variable is always visible to other
threads. Hence, assignment a new array to the volatile variable guarantees the visibility
of the new array to another threads, but there is not any guarantee of the visibility of a
new element of the array. Because the insertion of a new element into the volatile array is
a change of the internal state of the array.
>  For example there is the method AMQPConnection_1_0Impl::removeTransaction:
> {code:java}
>     private volatile ServerTransaction[] _openTransactions = new ServerTransaction[16];
>     @Override
>     public void removeTransaction(final int txnId)
>     {
>         try
>         {
>             _openTransactions[txnId] = null; // There is not any  guarantee of the visibility,
when the change is propagated to another threads.
>         }
>         catch (ArrayIndexOutOfBoundsException e)
>         {
>             throw new UnknownTransactionException(txnId);
>         }
>     }
> {code}
> The same issue is in other methods of AMQPConnection_1_0Impl class.
> A concurrent collection can be used instead of the volatile array.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@qpid.apache.org
For additional commands, e-mail: dev-help@qpid.apache.org


Mime
View raw message