Bug 722614

Summary: QPID JCA Adapter -- Incorrect handling of getSession in QpidManagedConnection
Product: Red Hat Enterprise MRG Reporter: Weston M. Price <wprice>
Component: qpid-jcaAssignee: Andrew Stitcher <astitcher>
Status: CLOSED CURRENTRELEASE QA Contact: MRG Quality Engineering <mrgqe-bugs>
Severity: urgent Docs Contact:
Priority: unspecified    
Version: DevelopmentCC: astitcher, cdewolf, iboverma, jpechane, jross, jsedlace, tross
Target Milestone: 2.1.2   
Target Release: ---   
Hardware: All   
OS: All   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
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:
Embargoed:
Attachments:
Description Flags
Diff for BZ 722614 none

Description Weston M. Price 2011-07-15 21:04:08 UTC
Description of problem:
In some scenarios, the transaction manager in an EE compatible container will optimize the two phase commit protocol when there is only one resource in the transaction and use local transactions as opposed to XA. Currently, the QPID JCA adapter does not correctly handle this optimization in the call to getSession. In the current version, the managed connection checks to see if the XAResource is not null before either returning an XASession or a non-XASession. In the above scenario, the XAResource is never initialized being that local transactions are being used. As a result, the managed connection incorrectly returns a non XA session which is null being that the adapter assumes XA by default. 

The result is a null session which in turn causes any code using the adapter to fail.

Version-Release number of selected component (if applicable):
Current development version of the QPID JCA adapter

How reproducible:
Immediate

Steps to Reproduce:
Deploy the JCA adapter and the example application. Run the client and observe the NPE thrown. 
  
Actual results:
NullPointerException

Expected results:
NullPointerException

Additional info:

Comment 1 Jiri Sedlacek 2011-09-01 15:06:43 UTC
*** Bug 734030 has been marked as a duplicate of this bug. ***

Comment 3 Weston M. Price 2011-09-02 19:15:19 UTC
Created attachment 521275 [details]
Diff for BZ 722614

Produced by

git diff 8b990cd45f4c4891e0223071bb2c4cbde831fb0e e1b74c7ae7b6511f28bc31fd7e36c435fa34abcf

Comment 4 Weston M. Price 2011-09-02 19:17:57 UTC
The issue is this:

If you are using a XA but not running in the context of a txn, the previous code:


 if(_xaResource != null && _inManagedTx && !_mcf.getUseLocalTx())
 
would cause a complete failure as _inManagedTx would be false. Being that we construct an XASession, independent of whether or not there is an active transaction, the _inManagedTx flag is invalid and should be removed. 

This showed up when using the QpidJMSXA connection factory in the Servlet example as this is non-transactional.

Comment 5 Weston M. Price 2011-09-02 19:29:14 UTC
In reading the original bug description, this is incorrect. The issue is:


If you are using a XA but not running in the context of a txn, the previous
code:


 if(_xaResource != null && _inManagedTx && !_mcf.getUseLocalTx())

would cause a complete failure as _inManagedTx would be false. Being that we
construct an XASession if the MCF is XA aware, independent of whether or not there is an active
transaction, the _inManagedTx flag is invalid and should be removed as whether or not we are in a transaction, a valid Session has to be returned.

The original bug description was wrong and has nothing to do with the TxnManager or the LastResourceCommit optimization.

Comment 7 Andrew Stitcher 2011-09-22 13:30:29 UTC
This has been fixed in package qpid-java-jca-0.10-10