mirror of
https://gitee.com/dromara/hutool.git
synced 2025-05-04 12:47:59 +08:00
fix lock bug
This commit is contained in:
parent
04830bf06b
commit
010f0554ae
@ -14,6 +14,7 @@
|
||||
* 【core】 修复DateUtil.offset导致的时区错误问题(issue#I1294O@Gitee)
|
||||
* 【core】 修复RuntimeUtil.exec重载导致的问题(issue#544@Github)
|
||||
* 【db】 修复StatementUtil.getGeneratedKeys返回主键数量不足问题
|
||||
* 【db】 修复锁的问题(issue#546@Github)
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
@ -75,7 +75,7 @@ public class ConverterRegistry implements Serializable{
|
||||
/** 默认类型转换器 */
|
||||
private Map<Type, Converter<?>> defaultConverterMap;
|
||||
/** 用户自定义类型转换器 */
|
||||
private Map<Type, Converter<?>> customConverterMap;
|
||||
private volatile Map<Type, Converter<?>> customConverterMap;
|
||||
|
||||
/** 类级的内部类,也就是静态的成员式内部类,该内部类的实例与外部类的实例 没有绑定关系,而且只有被调用到才会装载,从而实现了延迟加载 */
|
||||
private static class SingletonHolder {
|
||||
|
@ -8,7 +8,6 @@ import cn.hutool.log.StaticLog;
|
||||
*
|
||||
* @author looly
|
||||
* @since 4.0.2
|
||||
*
|
||||
*/
|
||||
public class GlobalDSFactory {
|
||||
|
||||
@ -63,17 +62,19 @@ public class GlobalDSFactory {
|
||||
* @param customDSFactory 自定义数据源工厂
|
||||
* @return 自定义的数据源工厂
|
||||
*/
|
||||
synchronized public static DSFactory set(DSFactory customDSFactory) {
|
||||
if (null != factory) {
|
||||
if (factory.equals(customDSFactory)) {
|
||||
return factory;// 数据源工厂不变时返回原数据源工厂
|
||||
public static DSFactory set(DSFactory customDSFactory) {
|
||||
synchronized (lock) {
|
||||
if (null != factory) {
|
||||
if (factory.equals(customDSFactory)) {
|
||||
return factory;// 数据源工厂不变时返回原数据源工厂
|
||||
}
|
||||
// 自定义数据源工厂前关闭之前的数据源
|
||||
factory.destroy();
|
||||
}
|
||||
// 自定义数据源工厂前关闭之前的数据源
|
||||
factory.destroy();
|
||||
}
|
||||
|
||||
StaticLog.debug("Custom use [{}] datasource.", customDSFactory.dataSourceName);
|
||||
factory = customDSFactory;
|
||||
StaticLog.debug("Custom use [{}] DataSource.", customDSFactory.dataSourceName);
|
||||
factory = customDSFactory;
|
||||
}
|
||||
return factory;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user