diff --git a/README.md b/README.md
index f6594a9..d1f7015 100644
--- a/README.md
+++ b/README.md
@@ -8,7 +8,7 @@ This BeanUtils library is a Java bean copy utility with powerful functionality a
com.github.yangtu222
BeanUtils
- 1.0.8
+ 1.0.9
~~~
diff --git a/pom.xml b/pom.xml
index dd38da6..9984788 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,7 +5,7 @@
com.github.yangtu222
BeanUtils
BeanUtils
- 1.0.8
+ 1.0.9
BeanUtils library is a Java bean copy utility with powerful functionality and high performance.
https://github.com/yangtu222/BeanUtils
@@ -27,7 +27,7 @@
scm:git:https://github.com/yangtu222/BeanUtils.git
scm:git:https://github.com/yangtu222/BeanUtils.git
https://github.com/yangtu222/BeanUtils.git
- v1.0.8
+ v1.0.9
diff --git a/src/main/java/com/tuyang/beanutils/internal/cache/BeanCopyCache.java b/src/main/java/com/tuyang/beanutils/internal/cache/BeanCopyCache.java
index 49d5d2f..52471c2 100644
--- a/src/main/java/com/tuyang/beanutils/internal/cache/BeanCopyCache.java
+++ b/src/main/java/com/tuyang/beanutils/internal/cache/BeanCopyCache.java
@@ -76,9 +76,11 @@ public static void setBeanCopyConfig(BeanCopyConfig beanCopyConfig) {
if( beanCopyConfig == null )
beanCopyConfig = new BeanCopyConfig();
BeanCopyCache.beanCopyConfig = beanCopyConfig;
- if( beanCopyFactory!= null && !beanCopyFactory.getClass().equals(beanCopyConfig.getBeanCopyFactory() ) )
- beanCopyCacheMap.clear();
- beanCopyFactory = null;
+ synchronized (BeanCopyCache.class) {
+ if( beanCopyFactory != null && !beanCopyFactory.equals(beanCopyConfig.getBeanCopyFactory() ) )
+ beanCopyCacheMap.clear();
+ beanCopyFactory = null;
+ }
}
public static BeanCopier getBeanCopy(Class> sourceClass, Class> targetClass, Class> optionClass) {
diff --git a/src/test/java/com/tuyang/test/testBasic/Test01.java b/src/test/java/com/tuyang/test/testBasic/Test01.java
index 9af0eda..abb8a94 100644
--- a/src/test/java/com/tuyang/test/testBasic/Test01.java
+++ b/src/test/java/com/tuyang/test/testBasic/Test01.java
@@ -5,6 +5,7 @@
import org.junit.Test;
import com.tuyang.beanutils.BeanCopyUtils;
+import com.tuyang.beanutils.config.BeanCopyConfig;
public class Test01 {
@@ -37,6 +38,12 @@ public void testBasic() {
assertEquals( fromBean.getBeanDouble(), toBean.getBeanDouble(), 0 );
assertEquals( fromBean.getBeanString(), toBean.getBeanString() );
assertEquals(fromBean.getmId(), toBean.getmId());
+
+ BeanCopyConfig.setBeanCopyConfig(null);
+
+ ToBean toBean2 = BeanCopyUtils.copyBean(fromBean, ToBean.class);
+ assertEquals(fromBean.isBeanBool(), toBean2.isBeanBool() );
+
}
}