activemq-issues 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] (ARTEMIS-1408) FindBugs: Synchronization on java.util.concurrent objects in MQTTSessionState.java
Date Tue, 23 Jan 2018 16:59:00 GMT

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

ASF GitHub Bot commented on ARTEMIS-1408:
-----------------------------------------

GitHub user jbertram opened a pull request:

    https://github.com/apache/activemq-artemis/pull/1811

    ARTEMIS-1408 document synchronization

    

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/jbertram/activemq-artemis ARTEMIS-1408

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/activemq-artemis/pull/1811.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #1811
    
----
commit be722aa86a5983a7c419f5531d953c43b9468336
Author: Justin Bertram <jbertram@...>
Date:   2018-01-23T16:58:07Z

    ARTEMIS-1408 document synchronization

----


> FindBugs: Synchronization on java.util.concurrent objects in MQTTSessionState.java
> ----------------------------------------------------------------------------------
>
>                 Key: ARTEMIS-1408
>                 URL: https://issues.apache.org/jira/browse/ARTEMIS-1408
>             Project: ActiveMQ Artemis
>          Issue Type: Bug
>          Components: Broker, MQTT
>    Affects Versions: 2.4.0
>            Reporter: Jiri Daněk
>            Assignee: Justin Bertram
>            Priority: Minor
>
> {noformat}
> 82   boolean addSubscription(MqttTopicSubscription subscription, WildcardConfiguration
wildcardConfiguration) {
>    	
> CID 1419151 (#1 of 1): JLM: Synchronization on java.util.concurrent objects (FB.JLM_JSR166_UTILCONCURRENT_MONITORENTER)
> 1. defect: Synchronization performed on java.util.concurrent.ConcurrentHashMap.
>  83      synchronized (subscriptions) {
>  84         addressMessageMap.putIfAbsent(MQTTUtil.convertMQTTAddressFilterToCore(subscription.topicName(),
wildcardConfiguration), new ConcurrentHashMap<Long, Integer>());
>  85
>  86         MqttTopicSubscription existingSubscription = subscriptions.get(subscription.topicName());
>  87         if (existingSubscription != null) {
>  88            if (subscription.qualityOfService().value() > existingSubscription.qualityOfService().value())
{
>  89               subscriptions.put(subscription.topicName(), subscription);
>  90               return true;
>  91            }
>  92         } else {
>  93            subscriptions.put(subscription.topicName(), subscription);
>  94            return true;
>  95         }
>  96      }
>  97      return false;
>  98   }
>  99
> {noformat}
> {noformat}
> 100   void removeSubscription(String address) {
>    	
> CID 1419085 (#1 of 1): JLM: Synchronization on java.util.concurrent objects (FB.JLM_JSR166_UTILCONCURRENT_MONITORENTER)
> 1. defect: Synchronization performed on java.util.concurrent.ConcurrentHashMap.
> 101      synchronized (subscriptions) {
> 102         subscriptions.remove(address);
> 103         addressMessageMap.remove(address);
> 104      }
> 105   }
> {noformat}
> {quote}
> JLM: Synchronization performed on util.concurrent instance (JLM_JSR166_UTILCONCURRENT_MONITORENTER)
> This method performs synchronization an object that is an instance of a class from the
java.util.concurrent package (or its subclasses). Instances of these classes have their own
concurrency control mechanisms that are orthogonal to the synchronization provided by the
Java keyword synchronized. For example, synchronizing on an AtomicBoolean will not prevent
other threads from modifying the AtomicBoolean.
> Such code may be correct, but should be carefully reviewed and documented, and may confuse
people who have to maintain the code at a later date.
> {quote}
> http://findbugs.sourceforge.net/bugDescriptions.html#JLM_JSR166_UTILCONCURRENT_MONITORENTER



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message