Bug 784270

Summary: AMQDestination equals() validation is broken for addresses
Product: Red Hat Enterprise MRG Reporter: Siddhesh Poyarekar <spoyarek>
Component: qpid-javaAssignee: Rajith Attapattu <rattapat+nobody>
Status: CLOSED ERRATA QA Contact: Irina Boverman <iboverma>
Severity: medium Docs Contact:
Priority: medium    
Version: 2.0CC: eallen, iboverma, jross, jshepherd, lzhaldyb, mnewsome, sauchter
Target Milestone: 3.0Keywords: Patch
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
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.
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-09-24 15:03:51 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Attachments:
Description Flags
Fix AMQDestination validation
none
Tar file containing test program source and test execution script. none

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