diff --git a/changes/en-us/2.x.md b/changes/en-us/2.x.md index 2735e14a76d..a60f1b282fc 100644 --- a/changes/en-us/2.x.md +++ b/changes/en-us/2.x.md @@ -48,7 +48,7 @@ Add changes here for all PR submitted to the 2.x branch. - [[#7149](https://github.com/apache/incubator-seata/pull/7149)] Fix abnormal character display issues in ./distribution/NOTICE.md - [[#7170](https://github.com/apache/incubator-seata/pull/7170)] Optimize seata client I/O processing by adjusting thread count - [[#7179](https://github.com/apache/incubator-seata/pull/7179)] Use shared EventLoop for TM and RM clients to reduce thread overhead and improve performance - +- [[#7194](https://github.com/apache/incubator-seata/pull/7194)] automatically skipping proxy for datasource of type AbstractRoutingDataSource ### security: - [[#6069](https://github.com/apache/incubator-seata/pull/6069)] Upgrade Guava dependencies to fix security vulnerabilities @@ -89,5 +89,6 @@ Thanks to these contributors for their code commits. Please report an unintended - [xingfudeshi](https://github.com/xingfudeshi) - [YongGoose](https://github.com/YongGoose) - [Monilnarang](https://github.com/Monilnarang) +- [iAmClever](https://github.com/iAmClever) Also, we receive many valuable issues, questions and advices from our community. Thanks for you all. diff --git a/changes/zh-cn/2.x.md b/changes/zh-cn/2.x.md index 2f624c01c31..31e878a5871 100644 --- a/changes/zh-cn/2.x.md +++ b/changes/zh-cn/2.x.md @@ -49,7 +49,7 @@ - [[#7149](https://github.com/apache/incubator-seata/pull/7149)] 修复./distribution/NOTICE.md文件中的异常字符串显示问题 - [[#7170](https://github.com/apache/incubator-seata/pull/7170)] 通过调整线程数优化 Seata 客户端 I/O 处理 - [[#7179](https://github.com/apache/incubator-seata/pull/7179)] 使用共享的 EventLoop 来减少 TM 和 RM 客户端的线程开销并提高性能 - +- [[#7194](https://github.com/apache/incubator-seata/pull/7194)] 自动跳过对AbstractRoutingDataSource类型数据源的代理 ### security: - [[#6069](https://github.com/apache/incubator-seata/pull/6069)] 升级Guava依赖版本,修复安全漏洞 @@ -90,5 +90,6 @@ - [xingfudeshi](https://github.com/xingfudeshi) - [YongGoose](https://github.com/YongGoose) - [Monilnarang](https://github.com/Monilnarang) +- [iAmClever](https://github.com/iAmClever) 同时,我们收到了社区反馈的很多有价值的issue和建议,非常感谢大家。 diff --git a/spring/src/main/java/org/apache/seata/spring/annotation/datasource/SeataAutoDataSourceProxyCreator.java b/spring/src/main/java/org/apache/seata/spring/annotation/datasource/SeataAutoDataSourceProxyCreator.java index 50aff3449dc..ef50a211c31 100644 --- a/spring/src/main/java/org/apache/seata/spring/annotation/datasource/SeataAutoDataSourceProxyCreator.java +++ b/spring/src/main/java/org/apache/seata/spring/annotation/datasource/SeataAutoDataSourceProxyCreator.java @@ -71,7 +71,7 @@ protected boolean shouldSkip(Class beanClass, String beanName) { @Override protected Object wrapIfNecessary(Object bean, String beanName, Object cacheKey) { // we only care DataSource bean - if (!(bean instanceof DataSource)) { + if (!(bean instanceof DataSource) || isAbstractRoutingDataSource(bean)) { return bean; } @@ -108,6 +108,22 @@ protected Object wrapIfNecessary(Object bean, String beanName, Object cacheKey) return originEnhancer; } + /** + * Checks if the given bean is an instance of AbstractRoutingDataSource. + * + * @param bean the object to check + * @return true if the bean is an instance of AbstractRoutingDataSource, false otherwise + */ + private boolean isAbstractRoutingDataSource(Object bean) { + try { + Class clazz = Class.forName("org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource"); + return clazz.isAssignableFrom(bean.getClass()); + } catch (ClassNotFoundException e) { + // AbstractRoutingDataSource not found + return false; + } + } + SeataDataSourceProxy buildProxy(DataSource origin, String proxyMode) { if (BranchType.AT.name().equalsIgnoreCase(proxyMode)) { return new DataSourceProxy(origin);