Bug 738361

Summary: JMS Connection.getMetaData returns a usable enumeration only on the first call to getMetaData
Product: Red Hat Enterprise MRG Reporter: Justin Ross <jross>
Component: qpid-javaAssignee: messaging-bugs <messaging-bugs>
Status: CLOSED ERRATA QA Contact: MRG Quality Engineering <mrgqe-bugs>
Severity: low Docs Contact:
Priority: low    
Version: DevelopmentCC: freznice, jneedle, jross, mcressma, rattapat+nobody, tross, zkraus
Target Milestone: 2.0.3   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: qpid-java-0.10-9 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: 704566 Environment:
Last Closed: 2011-09-28 15:53:32 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: 704566    
Bug Blocks: 736252    

Description Justin Ross 2011-09-14 15:38:21 UTC
+++ This bug was initially created as a clone of Bug #704566 +++

Description of problem:
JMS Connection.getMetaData returns a usable enumeration only 
on the first call to getMetaData. Invoking getMetaData multiple times, 
either on the same connection or even completely different connections 
results in a empty Enumeration.

To me more precise, after the first call to getMetaData, subsequent 
calls during the duration of the JVM, on any connection will return a 
empty Enumeration.

Looks like this is is a bug in the MRG client implementation. Debugging 
shows that org.apache.qpid.client.CustomJMSXProperty is used to return 
the metadata Enumeration. But the _names member in this class is static, 
which means that all connections get the same Enumeration object.

So, if someone gets the connection meta and iterates over the 
Enumeration, other connections see the same modified Enumeration as 
well. And because the Enumeration's pointer has already been advanced to 
the end, others are not able to get elements from the Enumeration.

How reproducible:
Always

Steps to Reproduce:
1. Run a client with the following code

Connection conn = factory.createConnection();
for (Enumeration meta = conn.getMetaData().getJMSXPropertyNames(); meta.hasMoreElements();)
{
  System.out.println(meta.nextElement());
}
            
System.out.println("Getting connection meta data again");
for (Enumeration meta = conn.getMetaData().getJMSXPropertyNames(); meta.hasMoreElements();)
{
  System.out.println(meta.nextElement());
}

2. Observe that the second time around nothing is printed, since the enumeration is empty.

  
Actual results:
If conn.getMetaData().getJMSXPropertyNames() is called a second time on the same connection or in a different connection (from the same JVM) an empty enumeration is returned.

Expected results:
Every time getJMSXPropertyNames() is called, a enumeration with the property names should be returned.

--- Additional comment from rattapat on 2011-08-30 14:46:52 EDT ---

This issue is tracked in upstream via https://issues.apache.org/jira/browse/QPID-3270

A fix has been committed in upstream. Details as follows.
http://svn.apache.org/viewvc?view=rev&rev=1138295
http://svn.apache.org/viewvc?view=rev&rev=1138296

--- Additional comment from zkraus on 2011-09-14 08:03:52 EDT ---

Fix was tested on:
RHEL 5.7 x86/x64
qpid-java-common-0.10-9.el5
qpid-java-client-0.10-9.el5
qpid-java-jca-0.10-9.el5
qpid-java-example-0.10-9.el5

RHEL 6.1 x86/x64
qpid-java-jca-0.10-9.el6.noarch
qpid-java-common-0.10-9.el6.noarch
qpid-java-example-0.10-9.el6.noarch
qpid-java-client-0.10-9.el6.noarch

changing to VERIFIED

Comment 1 errata-xmlrpc 2011-09-28 15:53:32 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/RHBA-2011-1340.html