diff --git a/sharding-proxy/src/main/java/io/shardingsphere/proxy/backend/jdbc/datasource/JDBCXABackendDataSourceFactory.java b/sharding-proxy/src/main/java/io/shardingsphere/proxy/backend/jdbc/datasource/JDBCXABackendDataSourceFactory.java index bfae3b9556390..bc8e326cf1b45 100644 --- a/sharding-proxy/src/main/java/io/shardingsphere/proxy/backend/jdbc/datasource/JDBCXABackendDataSourceFactory.java +++ b/sharding-proxy/src/main/java/io/shardingsphere/proxy/backend/jdbc/datasource/JDBCXABackendDataSourceFactory.java @@ -39,18 +39,17 @@ public final class JDBCXABackendDataSourceFactory implements JDBCBackendDataSour public DataSource build(final String dataSourceName, final DataSourceParameter dataSourceParameter) throws Exception { XATransactionManager xaTransactionManager = (XATransactionManager) ShardingTransactionManagerRegistry.getInstance().getShardingTransactionManager(TransactionType.XA); Class xaDataSourceClass = loadClass(XA_DRIVER_CLASS_NAME); - XADataSource xaDataSource = xaDataSourceClass.newInstance(); - return xaTransactionManager.wrapDataSource(xaDataSource, dataSourceName, dataSourceParameter); + return xaTransactionManager.wrapDataSource(xaDataSourceClass.newInstance(), dataSourceName, dataSourceParameter); } - private Class loadClass(String className) throws ClassNotFoundException { - Class clazz; - + @SuppressWarnings("unchecked") + private Class loadClass(final String className) throws ClassNotFoundException { + Class result; try { - clazz = Thread.currentThread().getContextClassLoader().loadClass(className); - } catch (ClassNotFoundException e) { - clazz = Class.forName(className); + result = Thread.currentThread().getContextClassLoader().loadClass(className); + } catch (final ClassNotFoundException ignored) { + result = Class.forName(className); } - return clazz; + return result; } } diff --git a/sharding-transaction/src/main/java/io/shardingsphere/transaction/manager/xa/atomikos/AtomikosTransactionManager.java b/sharding-transaction/src/main/java/io/shardingsphere/transaction/manager/xa/atomikos/AtomikosTransactionManager.java index 91a6a01bf87a9..0940722d44692 100644 --- a/sharding-transaction/src/main/java/io/shardingsphere/transaction/manager/xa/atomikos/AtomikosTransactionManager.java +++ b/sharding-transaction/src/main/java/io/shardingsphere/transaction/manager/xa/atomikos/AtomikosTransactionManager.java @@ -95,10 +95,10 @@ public DataSource wrapDataSource(final XADataSource xaDataSource, final String d result.setUniqueResourceName(dataSourceName); result.setMaxPoolSize(dataSourceParameter.getMaximumPoolSize()); result.setTestQuery("SELECT 1"); - Properties properties = getXAProperties(dataSourceParameter); - PropertyUtils.setProperties(xaDataSource, properties); + Properties xaProperties = getXAProperties(dataSourceParameter); + PropertyUtils.setProperties(xaDataSource, xaProperties); result.setXaDataSource(xaDataSource); - result.setXaProperties(properties); + result.setXaProperties(xaProperties); return result; }