Bug 702247

Summary: qpid java client crashes with NPE at org.apache.qpid.client.AMQAnyDestination.getTopicName(AMQAnyDestination.java:75)
Product: Red Hat Enterprise MRG Reporter: Frantisek Reznicek <freznice>
Component: qpid-javaAssignee: Rajith Attapattu <rattapat+nobody>
Status: CLOSED CURRENTRELEASE QA Contact: Frantisek Reznicek <freznice>
Severity: urgent Docs Contact:
Priority: urgent    
Version: DevelopmentCC: esammons, gsim, iboverma
Target Milestone: 2.0   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-12-07 17:42:01 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Bug Depends On:    
Bug Blocks: 667771    

Description Frantisek Reznicek 2011-05-05 06:54:25 UTC
Description of problem:

Qpid java client crashes with NPE at org.apache.qpid.client.AMQAnyDestination.getTopicName(AMQAnyDestination.java:75)
using bug 667771 test program:
Exception occurred: java.lang.NullPointerException
java.lang.NullPointerException
        at org.apache.qpid.client.AMQAnyDestination.getTopicName(AMQAnyDestination.java:75)
        at org.apache.qpid.client.AMQSession.createDurableSubscriber(AMQSession.java:1065)
        at org.apache.qpid.client.AMQSession.createDurableSubscriber(AMQSession.java:1039)
        at DurableReceiver.main(DurableReceiver.java:24)


The issus seen on both RHEL 5.6 / 6.1s5 i[36]86 / x86_64.


Version-Release number of selected component (if applicable):
python-qpid-0.10-1.el5.noarch
python-qpid-qmf-0.10-6.el5.x86_64
qpid-cpp-client-0.10-4.el5.x86_64
qpid-cpp-client-devel-0.10-4.el5.x86_64
qpid-cpp-client-devel-docs-0.10-4.el5.x86_64
qpid-cpp-client-rdma-0.10-4.el5.x86_64
qpid-cpp-client-ssl-0.10-4.el5.x86_64
qpid-cpp-mrg-debuginfo-0.10-4.el5.x86_64
qpid-cpp-server-0.10-4.el5.x86_64
qpid-cpp-server-cluster-0.10-4.el5.x86_64
qpid-cpp-server-devel-0.10-4.el5.x86_64
qpid-cpp-server-rdma-0.10-4.el5.x86_64
qpid-cpp-server-ssl-0.10-4.el5.x86_64
qpid-cpp-server-store-0.10-4.el5.x86_64
qpid-cpp-server-xml-0.10-4.el5.x86_64
qpid-dotnet-0.4.738274-2.el5.x86_64
qpid-java-client-0.10-4.el5.noarch
qpid-java-common-0.10-4.el5.noarch
qpid-java-example-0.10-4.el5.noarch
qpid-qmf-0.10-6.el5.x86_64
qpid-qmf-debuginfo-0.10-6.el5.x86_64
qpid-qmf-devel-0.10-6.el5.x86_64
qpid-tests-0.10-1.el5.noarch
qpid-tools-0.10-4.el5.noarch
rh-qpid-cpp-tests-0.10-4.el5.x86_64
ruby-qpid-qmf-0.10-6.el5.x86_64
sesame-0.10-1.el5.x86_64
sesame-debuginfo-0.10-1.el5.x86_64


How reproducible:
100%

Steps to Reproduce:
1. start broker
2. get https://bugzilla.redhat.com/attachment.cgi?id=472108
3. jrunner DurableReceiver
   (see below)
  
Actual results:
Qpid client crashes.

Expected results:
Qpid client should not crash.


Additional info:

function jrunner ()
{
  local err_cnt=0
  local CLASS_NAME="DurableReceiver"
  local FILE_NAME="${CLASS_NAME}.java"
  
  ls -lA ${FILE_NAME} || return 1
  local QPID_DEPS=`find /usr/share/java/qpid-deps/*.jar | tr '\n' ":"`
  local QPID_JARS=`find /usr/share/java -name 'qpid-client*.jar' -or -name 'qpid-common*.jar' | tr '\n' ":"`
  local LOG4J="/usr/share/java/log4j.jar"
  local QPID_CLASSPATH=$QPID_DEPS$LOG4J:$QPID_JARS
  
  javac -cp "$QPID_DEPS$LOG4J:$QPID_JARS" ${FILE_NAME} || let "err_cnt++"
  java -cp "$QPID_DEPS$LOG4J:$QPID_JARS" ${CLASS_NAME} || let "err_cnt++"

  return ${err_cnt}
}


[root@mrg-qe-07 bz667771]# jrunner DurableReceiver
-rw-r--r--. 1 root root 2010 May  5 02:41 DurableReceiver.java
log4j:WARN No appenders could be found for logger (org.apache.qpid.jndi.PropertiesFileInitialContextFactory).
log4j:WARN Please initialize the log4j system properly.
Exception occurred: java.lang.NullPointerException
java.lang.NullPointerException
        at org.apache.qpid.client.AMQAnyDestination.getTopicName(AMQAnyDestination.java:75)
        at org.apache.qpid.client.AMQSession.createDurableSubscriber(AMQSession.java:1065)
        at org.apache.qpid.client.AMQSession.createDurableSubscriber(AMQSession.java:1039)
        at DurableReceiver.main(DurableReceiver.java:24)

Comment 1 Rajith Attapattu 2011-05-10 03:15:58 UTC
This is caused due to the address not being resolved properly. All though this is not a blocker, we probably needs to fix this. I will be posting a patch upstream shortly for review.

Comment 2 Rajith Attapattu 2011-05-10 03:21:36 UTC
This is caused due to the address not being resolved properly. All though this is not a blocker, we probably needs to fix this. I will be posting a patch upstream shortly for review.

Comment 3 Rajith Attapattu 2011-05-16 21:16:28 UTC
This issue is tracked in upstream via QPID-3254
This went through the review process in upstream Qpid project.
See https://reviews.apache.org/r/706/

Following is a list of commits that went in for this bug.

1. http://svn.apache.org/viewvc?view=revision&revision=1102002

This commit added logic to resolve an address string to ensure we have enough information to handle corner cases like addresses without subjects.
It also adds null checks for getRoutingKey() method and getTopicName() method in both AMQTopic and AMQAnyDestination classes, which causes the NPE mentioned in this bug.

2. http://svn.apache.org/viewvc?view=revision&revision=1102102

Added logic to ensure only Topics are used in creating durable subs to avoid any unnecessary complications arising as a result of using named Queues. It also marks the private queue being used as durable even if marked otherwise in the address string.

3. http://svn.apache.org/viewvc?rev=1103884&view=rev

Changed the default value for routing key based on a review comment by Robert Godfrey.

Comment 4 Frantisek Reznicek 2011-05-17 08:41:43 UTC
The issue has been corrected on qpid-java-0.10-6, tested on RHEL 5.6/6.1  i[36]86 / x86_64, no more NPE seen.


-> VERIFIED