diff --git a/spring-boot/src/main/java/org/springframework/boot/jta/bitronix/PoolingDataSourceBean.java b/spring-boot/src/main/java/org/springframework/boot/jta/bitronix/PoolingDataSourceBean.java index 1e658b4cb8..f0d4b6a00d 100644 --- a/spring-boot/src/main/java/org/springframework/boot/jta/bitronix/PoolingDataSourceBean.java +++ b/spring-boot/src/main/java/org/springframework/boot/jta/bitronix/PoolingDataSourceBean.java @@ -17,19 +17,17 @@ package org.springframework.boot.jta.bitronix; import java.io.PrintWriter; -import java.lang.reflect.Method; import java.sql.SQLException; import java.sql.SQLFeatureNotSupportedException; import java.util.Properties; import java.util.logging.Logger; +import javax.sql.DataSource; import javax.sql.XAConnection; import javax.sql.XADataSource; import org.springframework.beans.factory.BeanNameAware; import org.springframework.beans.factory.InitializingBean; -import org.springframework.jdbc.datasource.DelegatingDataSource; -import org.springframework.util.ReflectionUtils; import org.springframework.util.StringUtils; import bitronix.tm.resource.common.ResourceBean; @@ -86,7 +84,6 @@ public class PoolingDataSourceBean extends PoolingDataSource implements BeanName /** * Set the {@link XADataSource} directly, instead of calling * {@link #setClassName(String)}. - * * @param dataSource the data source to use */ public void setDataSource(XADataSource dataSource) { @@ -110,7 +107,13 @@ public class PoolingDataSourceBean extends PoolingDataSource implements BeanName @Override public Logger getParentLogger() throws SQLFeatureNotSupportedException { - return getParentLoggerForDataSource(this.dataSource); + try { + return ((DataSource) this).getParentLogger(); + } + catch (Exception ex) { + // Work around https://jira.codehaus.org/browse/BTM-134 + return Logger.getLogger(Logger.GLOBAL_LOGGER_NAME); + } } /** @@ -159,33 +162,14 @@ public class PoolingDataSourceBean extends PoolingDataSource implements BeanName } @Override - public Logger getParentLogger() { - return getParentLoggerForDataSource(this.dataSource); + public Logger getParentLogger() throws SQLFeatureNotSupportedException { + return this.dataSource.getParentLogger(); } public XADataSource getDataSource() { return this.dataSource; } - } - /** - * When running on Java 7 or later, delegates reflectively to the underlying - * {@link javax.sql.DataSource} or, when running on Java 6, does what - * {@link DelegatingDataSource} does - */ - private static Logger getParentLoggerForDataSource(XADataSource dataSource) { - - Method getParentLoggerMethod = ReflectionUtils.findMethod(XADataSource.class, - "getParentLogger"); - - if (getParentLoggerMethod != null) { - try { - return (Logger) getParentLoggerMethod.invoke(dataSource); - } - catch (Exception e) { - // Swallow and continue - } - } - return Logger.getLogger(Logger.GLOBAL_LOGGER_NAME); } + }