Bug 784270 - AMQDestination equals() validation is broken for addresses
Summary: AMQDestination equals() validation is broken for addresses
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise MRG
Classification: Red Hat
Component: qpid-java
Version: 2.0
Hardware: All
OS: Linux
medium
medium
Target Milestone: 3.0
: ---
Assignee: Rajith Attapattu
QA Contact: Irina Boverman
URL:
Whiteboard:
: 958360 (view as bug list)
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2012-01-24 12:25 UTC by Siddhesh Poyarekar
Modified: 2018-12-01 18:45 UTC (History)
7 users (show)

Fixed In Version: qpid-java-0.22
Doc Type: Bug Fix
Doc Text:
It was discovered that the AMQDestination equals method did not take into account the differences between the ADDR and BURL syntax. The legacy fields were not populated until the address was validated resulting in a null pointer exception if equals was called beforehand. The fix now handles equals and hashcode separately for ADDR and BURL, which allow the equals and hashcode methods to behave as expected.
Clone Of:
Environment:
Last Closed: 2014-09-24 15:03:51 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
Fix AMQDestination validation (2.08 KB, patch)
2012-01-24 12:25 UTC, Siddhesh Poyarekar
no flags Details | Diff
Tar file containing test program source and test execution script. (2.00 KB, application/x-compressed-tar)
2013-10-08 20:18 UTC, Irina Boverman
no flags Details


Links
System ID Private Priority Status Summary Last Updated
Apache JIRA QPID-3769 0 None None None Never
Red Hat Product Errata RHEA-2014:1296 0 normal SHIPPED_LIVE Red Hat Enterprise MRG Messaging 3.0 Release 2014-09-24 19:00:06 UTC

Description Siddhesh Poyarekar 2012-01-24 12:25:39 UTC
Created attachment 557221 [details]
Fix AMQDestination validation

Description of problem:
AMQDestination has null values for _exchangeClass and _exchangeName if it is initialized with an address and checked for equality, one gets a NullPointerException.

Version-Release number of selected component (if applicable):
qpid-java-0.10-6.el5

How reproducible:
Always

Steps to Reproduce:

Compile and run:

import javax.jms.Destination;
import javax.naming.*;
import java.util.Properties;

public class DestinationTest {
	public static void main(String[] args) throws Exception {
		Properties props = new Properties();
		props.setProperty("java.naming.factory.initial", "org.apache.qpid.jndi.PropertiesFileInitialContextFactory");
		props.setProperty("destination.address1", "address1");
		props.setProperty("destination.address2", "address2");

		Context ctx = new InitialContext(props);
		Destination a1 = (Destination) ctx.lookup("address1");
		Destination a2 = (Destination) ctx.lookup("address2");
		if (a1.equals(a2))
			throw new Exception("No Exception and addresses are equal");
		else
			System.out.println("No exceptions");
	}
}

  
Actual results:
Exception in thread "main" java.lang.NullPointerException
	at org.apache.qpid.client.AMQDestination.equals(AMQDestination.java:577)
	at DestinationTest.main(DestinationTest.java:15)

Expected results:

No exception

Additional info:

Attached patch fixes validation for address strings and even between addresses that have different types and hence also fixes the NullPointerException.

Comment 3 Rajith Attapattu 2013-03-13 15:54:46 UTC
Fixed in upstream  (QPID-3769)
http://svn.apache.org/r1456007
http://svn.apache.org/r1456008

Committed a slightly modified version of Siddesh's patch.
Added a fix to hashcode as well and added a test case.

Comment 4 Rajith Attapattu 2013-03-26 21:32:41 UTC
Committed another fix at rev http://svn.apache.org/r1461324

Comment 5 Pavel Moravec 2013-05-14 05:33:48 UTC
*** Bug 958360 has been marked as a duplicate of this bug. ***

Comment 7 Ernie 2013-07-03 14:45:16 UTC
Verified on all supported platforms. Test case was included in the patch.

Comment 8 Ernie 2013-07-08 13:10:47 UTC
The issue has been fixed, tested on RHEL 5.9 / 5.10 / 6.4 / 6.5 / i[36]86 / x86_64 on packages:

qpid-java-0.22

Comment 11 Irina Boverman 2013-10-08 20:18:22 UTC
Created attachment 809540 [details]
Tar file containing test program source and test execution script.

Comment 15 errata-xmlrpc 2014-09-24 15:03:51 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHEA-2014-1296.html


Note You need to log in before you can comment on or make changes to this bug.