From commits-return-22033-archive-asf-public=cust-asf.ponee.io@pulsar.apache.org Thu Feb 7 22:25:10 2019 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id 4DDE218067E for ; Thu, 7 Feb 2019 23:25:10 +0100 (CET) Received: (qmail 13508 invoked by uid 500); 7 Feb 2019 22:25:09 -0000 Mailing-List: contact commits-help@pulsar.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@pulsar.apache.org Delivered-To: mailing list commits@pulsar.apache.org Received: (qmail 13491 invoked by uid 99); 7 Feb 2019 22:25:09 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 07 Feb 2019 22:25:09 +0000 Received: by gitbox.apache.org (ASF Mail Server at gitbox.apache.org, from userid 33) id DDFAC80976; Thu, 7 Feb 2019 22:25:08 +0000 (UTC) Date: Thu, 07 Feb 2019 22:25:08 +0000 To: "commits@pulsar.apache.org" Subject: [pulsar] branch master updated: Use synchronized when accessing consumers identity map (#3540) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Message-ID: <154957830823.27773.6933767207248776519@gitbox.apache.org> From: mmerli@apache.org X-Git-Host: gitbox.apache.org X-Git-Repo: pulsar X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: 3a5df1ae71a29873fdd91295763342b90f9bc224 X-Git-Newrev: 1e531e0c5dd24db9f85f7e97bb49ed7ad93bf617 X-Git-Rev: 1e531e0c5dd24db9f85f7e97bb49ed7ad93bf617 X-Git-NotificationType: ref_changed_plus_diff X-Git-Multimail-Version: 1.5.dev Auto-Submitted: auto-generated This is an automated email from the ASF dual-hosted git repository. mmerli pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/pulsar.git The following commit(s) were added to refs/heads/master by this push: new 1e531e0 Use synchronized when accessing consumers identity map (#3540) 1e531e0 is described below commit 1e531e0c5dd24db9f85f7e97bb49ed7ad93bf617 Author: Matteo Merli AuthorDate: Thu Feb 7 14:22:28 2019 -0800 Use synchronized when accessing consumers identity map (#3540) --- .../java/org/apache/pulsar/client/impl/PulsarClientImpl.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/pulsar-client/src/main/java/org/apache/pulsar/client/impl/PulsarClientImpl.java b/pulsar-client/src/main/java/org/apache/pulsar/client/impl/PulsarClientImpl.java index 26b7937..63b4071 100644 --- a/pulsar-client/src/main/java/org/apache/pulsar/client/impl/PulsarClientImpl.java +++ b/pulsar-client/src/main/java/org/apache/pulsar/client/impl/PulsarClientImpl.java @@ -685,11 +685,13 @@ public class PulsarClientImpl implements PulsarClient { @SuppressWarnings("unchecked") private Optional> subscriptionExist(ConsumerConfigurationData conf) { - Optional> subscriber = consumers.keySet().stream() - .filter(consumerBase -> consumerBase.getSubType().equals(PulsarApi.CommandSubscribe.SubType.Shared)) - .filter(c -> c.getSubscription().equals(conf.getSubscriptionName())) - .findFirst(); - return subscriber.map(ConsumerBase.class::cast); + synchronized (consumers) { + Optional> subscriber = consumers.keySet().stream() + .filter(consumerBase -> consumerBase.getSubType().equals(PulsarApi.CommandSubscribe.SubType.Shared)) + .filter(c -> c.getSubscription().equals(conf.getSubscriptionName())) + .findFirst(); + return subscriber.map(ConsumerBase.class::cast); + } } private static EventLoopGroup getEventLoopGroup(ClientConfigurationData conf) {