Return-Path: Delivered-To: apmail-activemq-commits-archive@www.apache.org Received: (qmail 41500 invoked from network); 24 Jul 2007 17:08:53 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 24 Jul 2007 17:08:53 -0000 Received: (qmail 40719 invoked by uid 500); 24 Jul 2007 17:08:55 -0000 Delivered-To: apmail-activemq-commits-archive@activemq.apache.org Received: (qmail 40692 invoked by uid 500); 24 Jul 2007 17:08:54 -0000 Mailing-List: contact commits-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list commits@activemq.apache.org Received: (qmail 40683 invoked by uid 99); 24 Jul 2007 17:08:54 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 24 Jul 2007 10:08:54 -0700 X-ASF-Spam-Status: No, hits=-99.5 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 24 Jul 2007 10:08:52 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id 9F16E1A981C; Tue, 24 Jul 2007 10:08:32 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r559111 - /activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/RegionBroker.java Date: Tue, 24 Jul 2007 17:08:32 -0000 To: commits@activemq.apache.org From: chirino@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20070724170832.9F16E1A981C@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: chirino Date: Tue Jul 24 10:08:31 2007 New Revision: 559111 URL: http://svn.apache.org/viewvc?view=rev&rev=559111 Log: Fix for AMQ-1341 - Improve the InvalidClientIDException message so that we know where the previous connection was established from. Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/RegionBroker.java Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/RegionBroker.java URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/RegionBroker.java?view=diff&rev=559111&r1=559110&r2=559111 ============================================================================== --- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/RegionBroker.java (original) +++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/RegionBroker.java Tue Jul 24 10:08:31 2007 @@ -24,23 +24,20 @@ import java.util.HashMap; import java.util.Map; import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.CopyOnWriteArrayList; import javax.jms.InvalidClientIDException; import javax.jms.JMSException; -import org.apache.activemq.ActiveMQMessageAudit; import org.apache.activemq.broker.Broker; import org.apache.activemq.broker.BrokerService; import org.apache.activemq.broker.Connection; import org.apache.activemq.broker.ConnectionContext; import org.apache.activemq.broker.ConsumerBrokerExchange; -import org.apache.activemq.broker.DestinationAlreadyExistsException; import org.apache.activemq.broker.ProducerBrokerExchange; -import org.apache.activemq.broker.TransactionBroker; import org.apache.activemq.broker.region.policy.DeadLetterStrategy; -import org.apache.activemq.broker.region.policy.PendingDurableSubscriberMessageStoragePolicy; import org.apache.activemq.broker.region.policy.PolicyMap; -import org.apache.activemq.broker.region.policy.VMPendingDurableSubscriberMessageStoragePolicy; import org.apache.activemq.command.ActiveMQDestination; import org.apache.activemq.command.BrokerId; import org.apache.activemq.command.BrokerInfo; @@ -70,9 +67,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.CopyOnWriteArrayList; - /** * Routes Broker operations to the correct messaging regions for processing. @@ -100,7 +94,7 @@ private final LongSequenceGenerator sequenceGenerator = new LongSequenceGenerator(); private BrokerId brokerId; private String brokerName; - private Map clientIdSet = new HashMap(); // we will synchronize access + private Map clientIdSet = new HashMap(); // we will synchronize access private final DestinationInterceptor destinationInterceptor; private ConnectionContext adminConnectionContext; protected DestinationFactory destinationFactory; @@ -213,11 +207,12 @@ throw new InvalidClientIDException("No clientID specified for connection request"); } synchronized (clientIdSet ) { - if (clientIdSet.containsKey(clientId)) { - throw new InvalidClientIDException("Broker: " + getBrokerName() + " - Client: " + clientId + " already connected"); + ConnectionContext oldContext = clientIdSet.get(clientId); + if (oldContext!=null) { + throw new InvalidClientIDException("Broker: " + getBrokerName() + " - Client: " + clientId + " already connected from "+oldContext.getConnection().getRemoteAddress()); } else { - clientIdSet.put(clientId, info); + clientIdSet.put(clientId, context); } } @@ -230,10 +225,10 @@ throw new InvalidClientIDException("No clientID specified for connection disconnect request"); } synchronized (clientIdSet) { - ConnectionInfo oldValue = (ConnectionInfo) clientIdSet.get(clientId); + ConnectionContext oldValue = clientIdSet.get(clientId); // we may be removing the duplicate connection, not the first connection to be created // so lets check that their connection IDs are the same - if (oldValue != null) { + if (oldValue == context ) { if (isEqual(oldValue.getConnectionId(), info.getConnectionId())) { clientIdSet.remove(clientId); }