Bug 785014

Summary: Unable to create QueueBrowsers from destinations defined in the jndi.properties file.
Product: Red Hat Enterprise MRG Reporter: Rajith Attapattu <rattapat+nobody>
Component: qpid-javaAssignee: Rajith Attapattu <rattapat+nobody>
Status: CLOSED CURRENTRELEASE QA Contact: ppecka <ppecka>
Severity: medium Docs Contact:
Priority: high    
Version: DevelopmentCC: freznice, iboverma, jross, ppecka
Target Milestone: 2.1.2   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: qpid-jca-0.14-6 Doc Type: Bug Fix
Doc Text:
Cause: For address strings specified in jndi.properties the destination implementation returned is AMQAnyDestination, while QueueBrowser code is looking for an AMQQueue. Consequence: QueueBrowser creation fails with a class cast exception. Fix: The code converts an AMQAnyDestination into an AMQQueue object. Result: QueueBrowsers can now be created using address strings specified in jndi.properties.
Story Points: ---
Clone Of: Environment:
Last Closed: 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
Proposed patch
none
Proposed patch none

Description Rajith Attapattu 2012-01-26 22:30:13 UTC
Description of problem:

Currently you can't create a QueueBrowser from an address string defined
in the jndi.properties file due it being created as an AMQAnyDestination object.
The queue browser code specifically expects an AMQQueue object.

This was a mismatch due to the way the code is organized.

Version-Release number of selected component (if applicable):
All java rpms that support addressing

How reproducible:
always

Steps to Reproduce:
There is a JMS TCK failure.
You could also use a simple program to create a QueueBrowser from a Destination defined in the jndi.properties.

Ex. destination.MY_QUEUE=MY_QUEUE; {create : always}
Then in the code,
Queue dest = (Queue)ctx.lookup("MY_QUEUE");
QueueBrowser queueBrowser = queueSession.createBrowser(queue);  

Actual results:
A class cast exception is thrown (ex cannot cast AMQAnyDestination into AMQQueue)

Expected results:
QueueBrowser creation should work.

Comment 1 Rajith Attapattu 2012-01-26 22:32:07 UTC
I have a tactical fix for this issue. I'm in discussions with some upstream folks to see if I could get this upstream until we provide a more elegant solution with the destination refactoring.

If the patch doesn't go upstream we could carry it as a patch in our internal git branch.

Comment 2 Rajith Attapattu 2012-01-31 15:48:28 UTC
Created attachment 558637 [details]
Proposed patch

Impact : This only affects queue browsers and is a workaround to ensure we convert the AMQAnyDestination to an AMQQueue.

Potential issues : If somebody tries to use a queue browser on a Topic this will not prevent it. So simply it's not idiot proof.

Upstream : I will have a chat with Robbie et all and see if they are willing to accept this as a workaround.
                   However issues like this are going to be addressed with the new addressing work.

Comment 3 Rajith Attapattu 2012-01-31 17:22:37 UTC
Created attachment 558647 [details]
Proposed patch

The previous patch does not seem to work cleanly.
I regenerated the patch.

Also this patch depends on commit 1232992
http://svn.apache.org/viewvc?rev=1232992&view=rev

This is a fairly safe patch and one that is needed for JCA anyways to allow appserver integration easy.

Comment 5 Rajith Attapattu 2012-03-12 15:27:55 UTC
    Technical note added. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    New Contents:
Cause: For address strings specified in jndi.properties the destination implementation returned is AMQAnyDestination, while QueueBrowser code is looking for an AMQQueue.

Consequence:  QueueBrowser creation fails with a class cast exception.

Fix:  The code converts an AMQAnyDestination into an AMQQueue object.

Result:  QueueBrowsers can now be created using address strings specified in jndi.properties.

Comment 6 ppecka 2012-03-26 13:26:34 UTC
Verified with simple JMS client (no jca involved) on RHEL5.8 / RHEL6.2 ( both x686, x86_64)

python-qpid-0.14-5.el6.noarch
python-qpid-qmf-0.14-4.el6.i686
qpid-cpp-client-0.14-10.el6.i686
qpid-cpp-client-devel-0.14-10.el6.i686
qpid-cpp-client-devel-docs-0.14-10.el6.noarch
qpid-cpp-server-0.14-10.el6.i686
qpid-cpp-server-cluster-0.14-10.el6.i686
qpid-cpp-server-devel-0.14-10.el6.i686
qpid-cpp-server-store-0.14-10.el6.i686
qpid-cpp-server-xml-0.14-10.el6.i686
qpid-java-client-0.14-3.el6.noarch
qpid-java-common-0.14-3.el6.noarch
qpid-java-example-0.14-3.el6.noarch
qpid-jca-0.14-9.el5.noarch
qpid-qmf-0.14-4.el6.i686
qpid-tools-0.14-1.el6.noarch