activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r511092 - in /activemq/branches/activemq-4.1: ./ activemq-core/src/main/java/org/apache/activemq/broker/region/RegionBroker.java
Date Fri, 23 Feb 2007 20:26:06 GMT
Author: chirino
Date: Fri Feb 23 12:26:06 2007
New Revision: 511092

URL: http://svn.apache.org/viewvc?view=rev&rev=511092
Log:
 r248@34:  chirino | 2007-02-23 14:50:13 -0500
 Fix to avoid a deadlock.  Better synchonization
 

Modified:
    activemq/branches/activemq-4.1/   (props changed)
    activemq/branches/activemq-4.1/activemq-core/src/main/java/org/apache/activemq/broker/region/RegionBroker.java

Propchange: activemq/branches/activemq-4.1/
------------------------------------------------------------------------------
--- svk:merge (original)
+++ svk:merge Fri Feb 23 12:26:06 2007
@@ -1 +1 @@
-635f1f41-eb29-0410-ac9d-be9e2c357fdd:/local/amq-4.1-port:247
+635f1f41-eb29-0410-ac9d-be9e2c357fdd:/local/amq-4.1-port:248

Modified: activemq/branches/activemq-4.1/activemq-core/src/main/java/org/apache/activemq/broker/region/RegionBroker.java
URL: http://svn.apache.org/viewvc/activemq/branches/activemq-4.1/activemq-core/src/main/java/org/apache/activemq/broker/region/RegionBroker.java?view=diff&rev=511092&r1=511091&r2=511092
==============================================================================
--- activemq/branches/activemq-4.1/activemq-core/src/main/java/org/apache/activemq/broker/region/RegionBroker.java
(original)
+++ activemq/branches/activemq-4.1/activemq-core/src/main/java/org/apache/activemq/broker/region/RegionBroker.java
Fri Feb 23 12:26:06 2007
@@ -83,7 +83,7 @@
     protected final DestinationStatistics destinationStatistics = new DestinationStatistics();
     
     private final CopyOnWriteArrayList connections = new CopyOnWriteArrayList();
-    private final HashMap destinations = new HashMap();
+    private final Map destinations = new ConcurrentHashMap();
     private final CopyOnWriteArrayList brokerInfos = new CopyOnWriteArrayList();
 
     private final LongSequenceGenerator sequenceGenerator = new LongSequenceGenerator();
   
@@ -240,60 +240,62 @@
         return rc;
     }
 
-    public Destination addDestination(ConnectionContext context, ActiveMQDestination destination)
throws Exception {
-    	
-    	Destination answer;
-    	synchronized(destinations) {
-    		answer = (Destination) destinations.get(destination);
-            if( answer!=null )
-            	return answer;
-    	}
-    	
-        switch(destination.getDestinationType()) {
-        case ActiveMQDestination.QUEUE_TYPE:
-            answer  = queueRegion.addDestination(context, destination);
-            break;
-        case ActiveMQDestination.TOPIC_TYPE:
-            answer = topicRegion.addDestination(context, destination);
-            break;
-        case ActiveMQDestination.TEMP_QUEUE_TYPE:
-            answer = tempQueueRegion.addDestination(context, destination);
-            break;
-        case ActiveMQDestination.TEMP_TOPIC_TYPE:
-            answer = tempTopicRegion.addDestination(context, destination);
-            break;
-        default:
-            throw createUnknownDestinationTypeException(destination);
-        }
+    public Destination addDestination(ConnectionContext context,
+			ActiveMQDestination destination) throws Exception {
 
-    	synchronized(destinations) {
-            destinations.put(destination, answer);
-            return answer;
-    	}
-    }
-
-    public void removeDestination(ConnectionContext context,ActiveMQDestination destination,long
timeout) throws Exception{
-    	synchronized(destinations) {
-	        if( destinations.remove(destination)!=null ){
-	            switch(destination.getDestinationType()){
-	            case ActiveMQDestination.QUEUE_TYPE:
-	                queueRegion.removeDestination(context,destination,timeout);
-	                break;
-	            case ActiveMQDestination.TOPIC_TYPE:
-	                topicRegion.removeDestination(context,destination,timeout);
-	                break;
-	            case ActiveMQDestination.TEMP_QUEUE_TYPE:
-	                tempQueueRegion.removeDestination(context,destination,timeout);
-	                break;
-	            case ActiveMQDestination.TEMP_TOPIC_TYPE:
-	                tempTopicRegion.removeDestination(context,destination,timeout);
-	                break;
-	            default:
-	                throw createUnknownDestinationTypeException(destination);
-	            }
-	        }
-    	}
-    }
+		Destination answer;
+
+		answer = (Destination) destinations.get(destination);
+		if (answer != null)
+			return answer;
+
+		switch (destination.getDestinationType()) {
+		case ActiveMQDestination.QUEUE_TYPE:
+			answer = queueRegion.addDestination(context, destination);
+			break;
+		case ActiveMQDestination.TOPIC_TYPE:
+			answer = topicRegion.addDestination(context, destination);
+			break;
+		case ActiveMQDestination.TEMP_QUEUE_TYPE:
+			answer = tempQueueRegion.addDestination(context, destination);
+			break;
+		case ActiveMQDestination.TEMP_TOPIC_TYPE:
+			answer = tempTopicRegion.addDestination(context, destination);
+			break;
+		default:
+			throw createUnknownDestinationTypeException(destination);
+		}
+
+		destinations.put(destination, answer);
+		return answer;
+
+	}
+
+	public void removeDestination(ConnectionContext context,
+			ActiveMQDestination destination, long timeout) throws Exception {
+
+		if (destinations.remove(destination) != null) {
+			switch (destination.getDestinationType()) {
+			case ActiveMQDestination.QUEUE_TYPE:
+				queueRegion.removeDestination(context, destination, timeout);
+				break;
+			case ActiveMQDestination.TOPIC_TYPE:
+				topicRegion.removeDestination(context, destination, timeout);
+				break;
+			case ActiveMQDestination.TEMP_QUEUE_TYPE:
+				tempQueueRegion
+						.removeDestination(context, destination, timeout);
+				break;
+			case ActiveMQDestination.TEMP_TOPIC_TYPE:
+				tempTopicRegion
+						.removeDestination(context, destination, timeout);
+				break;
+			default:
+				throw createUnknownDestinationTypeException(destination);
+			}
+		}
+
+	}
     
     public void addDestinationInfo(ConnectionContext context,DestinationInfo info) throws
Exception{
         addDestination(context,info.getDestination());
@@ -306,14 +308,14 @@
     }
 
     public ActiveMQDestination[] getDestinations() throws Exception {
-    	ArrayList l;
-    	synchronized(destinations) {
-	        l = new ArrayList(destinations.values());
-    	}
-        ActiveMQDestination rc[] = new ActiveMQDestination[l.size()];
-        l.toArray(rc);
-        return rc;
-    }
+		ArrayList l;
+
+		l = new ArrayList(destinations.values());
+
+		ActiveMQDestination rc[] = new ActiveMQDestination[l.size()];
+		l.toArray(rc);
+		return rc;
+	}
 
 
     public void addSession(ConnectionContext context, SessionInfo info) throws Exception
{



Mime
View raw message