Skip to content

Commit 2680a84

Browse files
committed
fix(datasource): 宽化异常捕获类型以避免潜在的关闭失败
- 将 IllegalAccessException 和 InvocationTargetException 合并为更通用的 Exception 类型 - 确保所有可能的异常都能被正确记录,提高数据源关闭操作的健壮性
1 parent 537e021 commit 2680a84

1 file changed

Lines changed: 1 addition & 2 deletions

File tree

dynamic-datasource-spring/src/main/java/com/baomidou/dynamic/datasource/destroyer/DefaultDataSourceDestroyer.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import org.springframework.util.ReflectionUtils;
2020

2121
import javax.sql.DataSource;
22-
import java.lang.reflect.InvocationTargetException;
2322
import java.lang.reflect.Method;
2423
import java.util.LinkedList;
2524
import java.util.List;
@@ -97,7 +96,7 @@ public void destroy(String name, DataSource realDataSource) {
9796
closeMethod.invoke(realDataSource);
9897
log.info("dynamic-datasource close the datasource named [{}] success,", name);
9998
}
100-
} catch (IllegalAccessException | InvocationTargetException e) {
99+
} catch (Exception e) {
101100
log.warn("dynamic-datasource close the datasource named [{}] failed,", name, e);
102101
}
103102
}

0 commit comments

Comments
 (0)