Bug 722614 - QPID JCA Adapter -- Incorrect handling of getSession in QpidManagedConnection
Summary: QPID JCA Adapter -- Incorrect handling of getSession in QpidManagedConnection
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat Enterprise MRG
Classification: Red Hat
Component: qpid-jca
Version: Development
Hardware: All
OS: All
unspecified
urgent
Target Milestone: 2.1.2
: ---
Assignee: Andrew Stitcher
QA Contact: MRG Quality Engineering
URL:
Whiteboard:
: 734030 (view as bug list)
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2011-07-15 21:04 UTC by Weston M. Price
Modified: 2016-02-22 00:59 UTC (History)
7 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed:
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
Diff for BZ 722614 (35.54 KB, patch)
2011-09-02 19:15 UTC, Weston M. Price
no flags Details | Diff

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


Note You need to log in before you can comment on or make changes to this bug.