From cc2ca249e05b7a1e963da927533c6264c7f6ca22 Mon Sep 17 00:00:00 2001 From: Michael Yang Date: Mon, 14 Jul 2025 12:48:51 +0800 Subject: [PATCH] fix: fix and close #ICLQQ3 --- .../core/datasource/DataSourceKey.java | 33 +++---------------- 1 file changed, 4 insertions(+), 29 deletions(-) diff --git a/mybatis-flex-core/src/main/java/com/mybatisflex/core/datasource/DataSourceKey.java b/mybatis-flex-core/src/main/java/com/mybatisflex/core/datasource/DataSourceKey.java index dbb65038..122271ee 100644 --- a/mybatis-flex-core/src/main/java/com/mybatisflex/core/datasource/DataSourceKey.java +++ b/mybatis-flex-core/src/main/java/com/mybatisflex/core/datasource/DataSourceKey.java @@ -34,9 +34,11 @@ public class DataSourceKey { public static void use(String dataSourceKey) { Deque deque = lookup.get(); - if (deque != null) { - deque.push(dataSourceKey); + if (deque == null) { + deque = new ArrayDeque<>(1); + lookup.set(deque); } + deque.push(dataSourceKey); } public static String get() { @@ -95,31 +97,4 @@ public class DataSourceKey { return shardingDsKey != null ? shardingDsKey : dataSource; } - // === For Removal === - - @Deprecated - public static String getByManual() { - throw new UnsupportedOperationException("使用 DataSource.get() 代替。"); - } - - @Deprecated - public static String getByAnnotation() { - throw new UnsupportedOperationException("使用 DataSource.get() 代替。"); - } - - @Deprecated - public static void useWithAnnotation(String dataSourceKey) { - throw new UnsupportedOperationException("使用 DataSource.use(String) 代替。"); - } - - @Deprecated - public static void setAnnotationKeyThreadLocal(ThreadLocal annotationKeyThreadLocal) { - throw new UnsupportedOperationException("使用 DataSource.setThreadLocal(ThreadLocal>) 代替。"); - } - - @Deprecated - public static void setManualKeyThreadLocal(ThreadLocal manualKeyThreadLocal) { - throw new UnsupportedOperationException("使用 DataSource.setThreadLocal(ThreadLocal>) 代替。"); - } - }