qpid-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rajith Attapattu (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (QPID-3769) NPE in client AMQDestination.equals()
Date Mon, 11 Mar 2013 21:03:13 GMT

    [ https://issues.apache.org/jira/browse/QPID-3769?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13599289#comment-13599289
] 

Rajith Attapattu commented on QPID-3769:
----------------------------------------

There are two options for implementing the equals method (and hashcode).

1. Check the "type" and "name" to ensure they both point to the same "destination" (which
could be a queue or an exchange in pre 1.0 terms).

2. Do a comprehensive check on the internal address data structure to ensure that all fields,
properties, options are the same.

(Please note that comparing two address strings is not a good idea as there can whitespaces).

I prefer option one and have attached a patch for that.
What do others think?

{code}
         final AMQDestination that = (AMQDestination) o;
 
-        if (!_exchangeClass.equals(that._exchangeClass))
+        if (_destSyntax != that.getDestSyntax())
         {
             return false;
         }
-        if (!_exchangeName.equals(that._exchangeName))
+
+        if (_destSyntax == DestSyntax.ADDR)
         {
-            return false;
+            if (_addressType != that.getAddressType())
+            {
+                return false;
+            }
+            if (!_name.equals(that.getAddressName()))
+            {
+                return false;
+            }
         }
-        if ((_queueName == null && that._queueName != null) ||
-            (_queueName != null && !_queueName.equals(that._queueName)))
+        else
         {
-            return false;
+            if (!_exchangeClass.equals(that._exchangeClass))
+            {
+                return false;
+            }
+            if (!_exchangeName.equals(that._exchangeName))
+            {
+                return false;
+            }
+            if ((_queueName == null && that._queueName != null) ||
+                (_queueName != null && !_queueName.equals(that._queueName)))
+            {
+                return false;
+            }
         }
-
         return true;
     }
 
{code}
                
> NPE in client AMQDestination.equals()
> -------------------------------------
>
>                 Key: QPID-3769
>                 URL: https://issues.apache.org/jira/browse/QPID-3769
>             Project: Qpid
>          Issue Type: Bug
>          Components: Java Client
>    Affects Versions: 0.12
>            Reporter: Jan BareŇ°
>              Labels: addressing
>
> Code of org.apache.qpid.client.AMQDestination.equals(Object) is buggy, it should test
for null on _exchangeClass and _exchangeName before dereferencing them, lines 522 and 526.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@qpid.apache.org
For additional commands, e-mail: dev-help@qpid.apache.org


Mime
View raw message