Jiri Danek created ARTEMIS-1408: ----------------------------------- Summary: 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 Danek 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 (v6.4.14#64029)