Bug 890532

Summary: NullPointerException raised in AMQDestination.equals method
Product: Red Hat Enterprise MRG Reporter: Pavel Moravec <pmoravec>
Component: qpid-javaAssignee: Rajith Attapattu <rattapat+nobody>
Status: CLOSED ERRATA QA Contact: Valiantsina Hubeika <vhubeika>
Severity: medium Docs Contact:
Priority: medium    
Version: 2.2CC: esammons, iboverma, jross, lzhaldyb, vhubeika
Target Milestone: 3.0Keywords: EasyFix, Patch, TestCaseProvided
Target Release: ---   
Hardware: All   
OS: All   
Whiteboard:
Fixed In Version: qpid-java-0.22-1.el5, qpid-java-0.22-2.el6 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, which resulted in a null pointer exception if equals was called beforehand.The fix now handles equals and hashcode separately for ADDR and BURL, which now allow the equals and and hashcode methods to behave as expected.
Story Points: ---
Clone Of:
: 956764 (view as bug list) Environment:
Last Closed: 2014-09-24 15:05:59 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 956764    
Attachments:
Description Flags
reproducer
none
Proposed patch none

Description Pavel Moravec 2012-12-27 15:07:59 UTC
Description of problem:
Running simple attached reproducer in maven, NPE is raised.


Version-Release number of selected component (if applicable):
0.18-2


How reproducible:
100%


Steps to Reproduce:
1. Install junit, spring-framework and maven
2. unzip attachment, optionally modify brokerlist in MrgmNpeTest-context.xml to whatever else than default "localhost"
3. mvn test
4. If repeating the test, ensure that maven repository contains proper jar files!!! It automatically tries to _download_ files from qpid.apache.org, ignoring whatever is installed. To replace maven repository, do:
cp -f /usr/share/java/qpid-common-0.18.jar /root/.m2/repository/org/apache/qpid/qpid-common/0.18/qpid-common-0.18.jar 
cp -f /usr/share/java/qpid-client-0.18.jar /root/.m2/repository/org/apache/qpid/qpid-client/0.18/qpid-client-0.18.jar
(and re-run the test with -o option to make maven offline)



Actual results:
-------------------------------------------------------------------------------
Test set: com.redhat.mrgm.npe.MrgmNpeTest
-------------------------------------------------------------------------------
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 1.012 sec <<< FAILURE!
testNpe(com.redhat.mrgm.npe.MrgmNpeTest)  Time elapsed: 0.879 sec  <<< ERROR!
java.lang.NullPointerException
        at org.apache.qpid.client.AMQDestination.equals(AMQDestination.java:603)
        at org.springframework.jms.connection.CachingConnectionFactory$DestinationCacheKey.destinationEquals(CachingConnectionFactory.java:467)
        at org.springframework.jms.connection.CachingConnectionFactory$DestinationCacheKey.equals(CachingConnectionFactory.java:474)
        at java.util.HashMap.get(HashMap.java:305)
        at org.springframework.jms.connection.CachingConnectionFactory$CachedSessionInvocationHandler.getCachedProducer(CachingConnectionFactory.java:353)
        at org.springframework.jms.connection.CachingConnectionFactory$CachedSessionInvocationHandler.invoke(CachingConnectionFactory.java:320)
        at $Proxy9.createProducer(Unknown Source)
        at org.springframework.jms.core.JmsTemplate.doCreateProducer(JmsTemplate.java:971)
        at org.springframework.jms.core.JmsTemplate.createProducer(JmsTemplate.java:952)
        at org.springframework.jms.core.JmsTemplate.doSend(JmsTemplate.java:563)
        at org.springframework.jms.core.JmsTemplate$4.doInJms(JmsTemplate.java:546)
        at org.springframework.jms.core.JmsTemplate.execute(JmsTemplate.java:466)
        at org.springframework.jms.core.JmsTemplate.send(JmsTemplate.java:543)
        at com.redhat.mrgm.npe.MrgmNpeTest.testNpe(MrgmNpeTest.java:34)
..


Expected results:
Test passes.


Additional info:
Simple patch proposed.

Comment 1 Pavel Moravec 2012-12-27 15:09:50 UTC
Created attachment 669620 [details]
reproducer

Comment 2 Pavel Moravec 2012-12-27 15:11:31 UTC
Created attachment 669622 [details]
Proposed patch

Proposed patch.

Comment 3 Weston M. Price 2013-01-04 16:34:59 UTC
*** Bug 853197 has been marked as a duplicate of this bug. ***

Comment 5 Weston M. Price 2013-01-10 16:39:50 UTC
Switching assignment as BZ-784270 appears to be a duplicate, or at the very least close to the same issue. As Rajith is looking at this makes sense for him to kill two birds with one stone...so to speak.

Comment 6 Rajith Attapattu 2013-03-13 15:55:20 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 7 Valiantsina Hubeika 2013-06-20 14:46:23 UTC
tested on packages:

qpid-java-common-0.22-2.el5
qpid-java-client-0.22-2.el5

&

qpid-java-common-0.22-3.el6.noarch
qpid-java-client-0.22-3.el6.noarch

Comment 10 errata-xmlrpc 2014-09-24 15:05:59 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