You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aries.apache.org by ti...@apache.org on 2018/01/23 16:40:53 UTC

[aries-tx-control] 01/02: Tx Control spec compliance - failing the CT due to unwrapping failure

This is an automated email from the ASF dual-hosted git repository.

timothyjward pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/aries-tx-control.git

commit 63ce9b15944ae81c6ab42672f8518063fd556ad6
Author: Tim Ward <ti...@apache.org>
AuthorDate: Tue Jan 23 11:35:05 2018 -0500

    Tx Control spec compliance - failing the CT due to unwrapping failure
---
 .../xa/impl/JDBCConnectionProviderFactoryImpl.java | 28 +++++++++++++++-------
 1 file changed, 19 insertions(+), 9 deletions(-)

diff --git a/tx-control-providers/jdbc/tx-control-provider-jdbc-xa/src/main/java/org/apache/aries/tx/control/jdbc/xa/impl/JDBCConnectionProviderFactoryImpl.java b/tx-control-providers/jdbc/tx-control-provider-jdbc-xa/src/main/java/org/apache/aries/tx/control/jdbc/xa/impl/JDBCConnectionProviderFactoryImpl.java
index 7d1e5b4..34c3f86 100644
--- a/tx-control-providers/jdbc/tx-control-provider-jdbc-xa/src/main/java/org/apache/aries/tx/control/jdbc/xa/impl/JDBCConnectionProviderFactoryImpl.java
+++ b/tx-control-providers/jdbc/tx-control-provider-jdbc-xa/src/main/java/org/apache/aries/tx/control/jdbc/xa/impl/JDBCConnectionProviderFactoryImpl.java
@@ -93,16 +93,26 @@ public class JDBCConnectionProviderFactoryImpl extends AbstractInternalJDBCConne
 		boolean xaEnabled = toBoolean(resourceProviderProperties, XA_ENLISTMENT_ENABLED, true);
 		boolean localEnabled = toBoolean(resourceProviderProperties, LOCAL_ENLISTMENT_ENABLED, true);
 		
-		try {
-			checkEnlistment(xaEnabled, localEnabled, ds.isWrapperFor(XADataSource.class));
-			DataSource toUse = poolIfNecessary(resourceProviderProperties, xaEnabled ?
-					new XADataSourceMapper(ds.unwrap(XADataSource.class)) : ds);
-	
-			return new JDBCConnectionProviderImpl(toUse, xaEnabled, localEnabled, 
-					getRecoveryId(resourceProviderProperties, xaEnabled));
-		} catch (SQLException sqle) {
-			throw new TransactionException("Unable to create the JDBC resource provider", sqle);
+		XADataSource xaDS;
+		if(ds instanceof XADataSource) {
+			xaDS = (XADataSource) ds;
+		} else {
+			try {
+				if(ds.isWrapperFor(XADataSource.class)) {
+					xaDS = ds.unwrap(XADataSource.class);
+				} else {
+					xaDS = null;
+				}
+			} catch (SQLException sqle) {
+				xaDS = null;
+			}
 		}
+		checkEnlistment(xaEnabled, localEnabled, xaDS != null);
+		DataSource toUse = poolIfNecessary(resourceProviderProperties, xaEnabled ?
+				new XADataSourceMapper(xaDS) : ds);
+
+		return new JDBCConnectionProviderImpl(toUse, xaEnabled, localEnabled, 
+				getRecoveryId(resourceProviderProperties, xaEnabled));
 	}
 
 	@Override

-- 
To stop receiving notification emails like this one, please contact
timothyjward@apache.org.