summaryrefslogtreecommitdiff
path: root/java/client/src
diff options
context:
space:
mode:
authorRajith Muditha Attapattu <rajith@apache.org>2011-05-11 18:03:36 +0000
committerRajith Muditha Attapattu <rajith@apache.org>2011-05-11 18:03:36 +0000
commit033eb9e75a08ce2d68485e826d303e48cf7bb157 (patch)
tree61ba4c9e80996675be1a29d4eba58be341af9ac2 /java/client/src
parent8f52baddd9f3a5c9b6e6a5723e748300e0ef16bd (diff)
downloadqpid-python-033eb9e75a08ce2d68485e826d303e48cf7bb157.tar.gz
QPID-3254
Added logic to resolve the address to ensure corner cases such addresses without subjects are handled properly. The address resolotuion code will determine the defaults for subject (and routing key) by querying the name specified in the address. I also added null checks for getRoutingKey() method and getTopicName() method in both AMQTopic and AMQAnyDestination classes. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1102002 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/client/src')
-rw-r--r--java/client/src/main/java/org/apache/qpid/client/AMQAnyDestination.java13
-rw-r--r--java/client/src/main/java/org/apache/qpid/client/AMQSession.java28
-rw-r--r--java/client/src/main/java/org/apache/qpid/client/AMQTopic.java20
3 files changed, 46 insertions, 15 deletions
diff --git a/java/client/src/main/java/org/apache/qpid/client/AMQAnyDestination.java b/java/client/src/main/java/org/apache/qpid/client/AMQAnyDestination.java
index a201f7d61e..999b22299c 100644
--- a/java/client/src/main/java/org/apache/qpid/client/AMQAnyDestination.java
+++ b/java/client/src/main/java/org/apache/qpid/client/AMQAnyDestination.java
@@ -72,6 +72,17 @@ public class AMQAnyDestination extends AMQDestination implements Queue, Topic
public String getTopicName() throws JMSException
{
- return super.getRoutingKey().toString();
+ if (getRoutingKey() != null)
+ {
+ return getRoutingKey().asString();
+ }
+ else if (getSubject() != null)
+ {
+ return getSubject();
+ }
+ else
+ {
+ return null;
+ }
}
}
diff --git a/java/client/src/main/java/org/apache/qpid/client/AMQSession.java b/java/client/src/main/java/org/apache/qpid/client/AMQSession.java
index d1e7aae94a..f85b1e655d 100644
--- a/java/client/src/main/java/org/apache/qpid/client/AMQSession.java
+++ b/java/client/src/main/java/org/apache/qpid/client/AMQSession.java
@@ -1050,7 +1050,23 @@ public abstract class AMQSession<C extends BasicMessageConsumer, P extends Basic
{
checkNotClosed();
Topic origTopic = checkValidTopic(topic, true);
+
AMQTopic dest = AMQTopic.createDurableTopic(origTopic, name, _connection);
+ if (dest.getDestSyntax() == DestSyntax.ADDR &&
+ !dest.isAddressResolved())
+ {
+ try
+ {
+ handleAddressBasedDestination(dest,false,true);
+ }
+ catch(AMQException e)
+ {
+ JMSException ex = new JMSException("Error when verifying destination");
+ ex.initCause(e);
+ ex.setLinkedException(e);
+ throw ex;
+ }
+ }
String messageSelector = ((selector == null) || (selector.trim().length() == 0)) ? null : selector;
@@ -1062,15 +1078,9 @@ public abstract class AMQSession<C extends BasicMessageConsumer, P extends Basic
// Not subscribed to this name in the current session
if (subscriber == null)
{
- AMQShortString topicName;
- if (topic instanceof AMQTopic)
- {
- topicName = ((AMQTopic) topic).getRoutingKey();
- } else
- {
- topicName = new AMQShortString(topic.getTopicName());
- }
-
+ // After the address is resolved routing key will not be null.
+ AMQShortString topicName = dest.getRoutingKey();
+
if (_strictAMQP)
{
if (_strictAMQPFATAL)
diff --git a/java/client/src/main/java/org/apache/qpid/client/AMQTopic.java b/java/client/src/main/java/org/apache/qpid/client/AMQTopic.java
index c573da9def..79624a774f 100644
--- a/java/client/src/main/java/org/apache/qpid/client/AMQTopic.java
+++ b/java/client/src/main/java/org/apache/qpid/client/AMQTopic.java
@@ -147,13 +147,17 @@ public class AMQTopic extends AMQDestination implements Topic
public String getTopicName() throws JMSException
{
- if (super.getRoutingKey() == null && super.getSubject() != null)
+ if (getRoutingKey() != null)
{
- return super.getSubject();
+ return getRoutingKey().asString();
+ }
+ else if (getSubject() != null)
+ {
+ return getSubject();
}
else
{
- return super.getRoutingKey().toString();
+ return null;
}
}
@@ -172,12 +176,18 @@ public class AMQTopic extends AMQDestination implements Topic
public AMQShortString getRoutingKey()
{
- if (super.getRoutingKey() == null && super.getSubject() != null)
+ if (super.getRoutingKey() != null)
+ {
+ return super.getRoutingKey();
+ }
+ else if (getSubject() != null)
{
- return new AMQShortString(super.getSubject());
+ return new AMQShortString(getSubject());
}
else
{
+ setRoutingKey(new AMQShortString("#"));
+ setSubject("#");
return super.getRoutingKey();
}
}