You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ra...@apache.org on 2007/01/02 08:06:40 UTC

svn commit: r491753 - in /incubator/activemq/trunk/activemq-core/src: main/java/org/apache/activemq/command/ActiveMQTempDestination.java test/java/org/apache/activemq/command/ActiveMQDestinationTest.java

Author: rajdavies
Date: Mon Jan  1 23:06:39 2007
New Revision: 491753

URL: http://svn.apache.org/viewvc?view=rev&rev=491753
Log:
Fix for https://issues.apache.org/activemq/browse/AMQ-1110

Modified:
    incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQTempDestination.java
    incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/command/ActiveMQDestinationTest.java

Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQTempDestination.java
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQTempDestination.java?view=diff&rev=491753&r1=491752&r2=491753
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQTempDestination.java (original)
+++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQTempDestination.java Mon Jan  1 23:06:39 2007
@@ -1,83 +1,93 @@
 /**
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE
+ * file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file
+ * to You under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ * 
  * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * 
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
+ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
  */
+
 package org.apache.activemq.command;
 
 import javax.jms.JMSException;
-
 import org.apache.activemq.ActiveMQConnection;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
 /**
  * @openwire:marshaller
  * @version $Revision: 1.5 $
  */
-abstract public class ActiveMQTempDestination extends ActiveMQDestination {
-    
+abstract public class ActiveMQTempDestination extends ActiveMQDestination{
+
+    private static final Log log=LogFactory.getLog(ActiveMQTempDestination.class);
     protected transient ActiveMQConnection connection;
     protected transient String connectionId;
     protected transient int sequenceId;
-    
-    public ActiveMQTempDestination() {
+
+    public ActiveMQTempDestination(){
     }
-    
-    public ActiveMQTempDestination(String name) {
+
+    public ActiveMQTempDestination(String name){
         super(name);
     }
-    
-    public ActiveMQTempDestination(String connectionId, long sequenceId) {
+
+    public ActiveMQTempDestination(String connectionId,long sequenceId){
         super(connectionId+":"+sequenceId);
     }
 
-    public boolean isTemporary() {
+    public boolean isTemporary(){
         return true;
     }
 
-    public void delete() throws JMSException {
+    public void delete() throws JMSException{
         connection.deleteTempDestination(this);
     }
 
-    public ActiveMQConnection getConnection() {
+    public ActiveMQConnection getConnection(){
         return connection;
     }
 
-    public void setConnection(ActiveMQConnection connection) {
-        this.connection = connection;
+    public void setConnection(ActiveMQConnection connection){
+        this.connection=connection;
     }
 
-    public void setPhysicalName(String physicalName) {
+    public void setPhysicalName(String physicalName){
         super.setPhysicalName(physicalName);
-        if( !isComposite() ) {
+        if(!isComposite()){
             // Parse off the sequenceId off the end.
-            int p = this.physicalName.lastIndexOf(":");
-            sequenceId = Integer.parseInt(this.physicalName.substring(p+1).trim());
-            // The rest should be the connection id.
-            connectionId = this.physicalName.substring(0,p);
+            //this can fail if the temp destination is
+            //generated by another JMS system via the JMS<->JMS Bridge
+            int p=this.physicalName.lastIndexOf(":");
+            if(p>=0){
+                String seqStr=this.physicalName.substring(p+1).trim();
+                if(seqStr!=null&&seqStr.length()>0){
+                    try{
+                        sequenceId=Integer.parseInt(seqStr);
+                    }catch(NumberFormatException e){
+                        log.debug("Did not parse sequence Id from "+physicalName);
+                    }
+                    // The rest should be the connection id.
+                    connectionId=this.physicalName.substring(0,p);
+                }
+            }
         }
     }
 
-    public String getConnectionId() {
+    public String getConnectionId(){
         return connectionId;
     }
-    
-    public void setConnectionId(String connectionId) {
-        this.connectionId = connectionId;
+
+    public void setConnectionId(String connectionId){
+        this.connectionId=connectionId;
     }
 
-    public int getSequenceId() {
+    public int getSequenceId(){
         return sequenceId;
     }
 }

Modified: incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/command/ActiveMQDestinationTest.java
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/command/ActiveMQDestinationTest.java?view=diff&rev=491753&r1=491752&r2=491753
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/command/ActiveMQDestinationTest.java (original)
+++ incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/command/ActiveMQDestinationTest.java Mon Jan  1 23:06:39 2007
@@ -44,6 +44,8 @@
                 new ActiveMQTopic("TEST"),
                 new ActiveMQTempQueue("TEST:1"),
                 new ActiveMQTempTopic("TEST:1"),
+                new ActiveMQTempQueue("TEST"),
+                new ActiveMQTempTopic("TEST"),
                 new ActiveMQQueue("TEST?option=value"),
                 new ActiveMQTopic("TEST?option=value"),
                 new ActiveMQTempQueue("TEST:1?option=value"),
@@ -79,7 +81,8 @@
         List actual = new ArrayList(set);
         assertEquals("Sorted order", expected, actual);
     }
-
+    
+   
     public static Test suite() {
         return suite(ActiveMQDestinationTest.class);
     }