fix: FlexMapperProxy.getMethodDsKey

This commit is contained in:
Michael Yang 2024-06-03 11:36:16 +08:00
parent 18f7406f79
commit c5af830585

View File

@ -25,18 +25,14 @@ import com.mybatisflex.core.mybatis.FlexConfiguration;
import com.mybatisflex.core.row.RowMapper;
import com.mybatisflex.core.table.TableInfo;
import com.mybatisflex.core.table.TableInfoFactory;
import com.mybatisflex.core.util.MapUtil;
import com.mybatisflex.core.util.StringUtil;
import org.apache.ibatis.reflection.ExceptionUtil;
import org.apache.ibatis.session.SqlSession;
import java.lang.reflect.Method;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
public class FlexMapperProxy<T> extends MybatisMapperProxy<T> {
private static final String NULL_KEY = "@NK@";
private static final Map<Method, String> methodDsKeyCache = new ConcurrentHashMap<>();
private final FlexDataSource dataSource;
public FlexMapperProxy(SqlSession sqlSession, Class<T> mapperInterface, Map<Method, MapperMethodInvoker> methodCache,
@ -106,7 +102,6 @@ public class FlexMapperProxy<T> extends MybatisMapperProxy<T> {
private static String getMethodDsKey(Method method, Object proxy) {
String result = MapUtil.computeIfAbsent(methodDsKeyCache, method, m -> {
UseDataSource methodAnno = method.getAnnotation(UseDataSource.class);
if (methodAnno != null && StringUtil.isNotBlank(methodAnno.value())) {
return methodAnno.value();
@ -129,10 +124,7 @@ public class FlexMapperProxy<T> extends MybatisMapperProxy<T> {
}
}
}
return NULL_KEY;
});
return NULL_KEY.equals(result) ? null : result;
return null;
}
}