mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
fix bug
This commit is contained in:
parent
4f683f6445
commit
364bca150a
@ -28,6 +28,7 @@
|
|||||||
* 【extra 】 修复Archiver路径前带/问题(issue#I4NS0F@Gitee)
|
* 【extra 】 修复Archiver路径前带/问题(issue#I4NS0F@Gitee)
|
||||||
* 【extra 】 修复getMainColor方法中参数rgbFilters无效问题(pr#2034@Github)
|
* 【extra 】 修复getMainColor方法中参数rgbFilters无效问题(pr#2034@Github)
|
||||||
* 【core 】 修复ChineseDate无法区分闰月问题(issue#I4NQQW@Gitee)
|
* 【core 】 修复ChineseDate无法区分闰月问题(issue#I4NQQW@Gitee)
|
||||||
|
* 【core 】 修复BeanDesc大小写误判问题(issue#2009@Github)
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------
|
||||||
# 5.7.17 (2021-12-09)
|
# 5.7.17 (2021-12-09)
|
||||||
|
@ -143,7 +143,9 @@ public class BeanDesc implements Serializable {
|
|||||||
final Method[] methods = ReflectUtil.getMethods(this.beanClass);
|
final Method[] methods = ReflectUtil.getMethods(this.beanClass);
|
||||||
PropDesc prop;
|
PropDesc prop;
|
||||||
for (Field field : ReflectUtil.getFields(this.beanClass)) {
|
for (Field field : ReflectUtil.getFields(this.beanClass)) {
|
||||||
if (false == ModifierUtil.isStatic(field)) {
|
if (false == ModifierUtil.isStatic(field) &&
|
||||||
|
// 排除对象子类
|
||||||
|
false == "this$0".equals(field.getName())) {
|
||||||
//只针对非static属性
|
//只针对非static属性
|
||||||
prop = createProp(field, methods);
|
prop = createProp(field, methods);
|
||||||
// 只有不存在时才放入,防止父类属性覆盖子类属性
|
// 只有不存在时才放入,防止父类属性覆盖子类属性
|
||||||
@ -332,7 +334,7 @@ public class BeanDesc implements Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 包括boolean的任何类型只有一种匹配情况:name -》 setName
|
// 包括boolean的任何类型只有一种匹配情况:name -》 setName
|
||||||
return ("set" + fieldName).equals(methodName);
|
return ("set" + handledFieldName).equals(methodName);
|
||||||
}
|
}
|
||||||
// ------------------------------------------------------------------------------------------------------ Private method end
|
// ------------------------------------------------------------------------------------------------------ Private method end
|
||||||
}
|
}
|
||||||
|
@ -272,7 +272,7 @@ public class BeanCopier<T> implements Copier<T>, Serializable {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 检查属性名
|
// 检查属性名
|
||||||
String fieldName = prop.getFieldName();
|
final String fieldName = prop.getFieldName();
|
||||||
if (CollUtil.contains(ignoreSet, fieldName)) {
|
if (CollUtil.contains(ignoreSet, fieldName)) {
|
||||||
// 目标属性值被忽略或值提供者无此key时跳过
|
// 目标属性值被忽略或值提供者无此key时跳过
|
||||||
return;
|
return;
|
||||||
|
@ -6,7 +6,9 @@ import cn.hutool.core.bean.copier.ValueProvider;
|
|||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.collection.ListUtil;
|
import cn.hutool.core.collection.ListUtil;
|
||||||
import cn.hutool.core.map.MapUtil;
|
import cn.hutool.core.map.MapUtil;
|
||||||
|
import cn.hutool.core.thread.ThreadUtil;
|
||||||
import cn.hutool.core.util.ArrayUtil;
|
import cn.hutool.core.util.ArrayUtil;
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
@ -14,6 +16,7 @@ import lombok.Setter;
|
|||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
|
import org.junit.Ignore;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import java.beans.PropertyDescriptor;
|
import java.beans.PropertyDescriptor;
|
||||||
@ -29,6 +32,7 @@ import java.util.LinkedHashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bean工具单元测试
|
* Bean工具单元测试
|
||||||
@ -307,6 +311,37 @@ public class BeanUtilTest {
|
|||||||
Assert.assertEquals("sub名字", person1.getSubName());
|
Assert.assertEquals("sub名字", person1.getSubName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Ignore
|
||||||
|
public void multiThreadTest(){
|
||||||
|
Student student = new Student();
|
||||||
|
student.setName("张三");
|
||||||
|
student.setAge(123);
|
||||||
|
student.setNo(3158L);
|
||||||
|
|
||||||
|
Student student2 = new Student();
|
||||||
|
student.setName("李四");
|
||||||
|
student.setAge(125);
|
||||||
|
student.setNo(8848L);
|
||||||
|
|
||||||
|
List<Student> studentList = ListUtil.of(student, student2);
|
||||||
|
|
||||||
|
for (int i=0;i<5000;i++){
|
||||||
|
new Thread(()->{
|
||||||
|
List<Student> list = ObjectUtil.clone(studentList);
|
||||||
|
List<Student> listReps = list.stream().map(s1 -> {
|
||||||
|
Student s2 = new Student();
|
||||||
|
BeanUtil.copyProperties(s1, s2);
|
||||||
|
return s2;
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
|
||||||
|
System.out.println(listReps);
|
||||||
|
}).start();
|
||||||
|
}
|
||||||
|
|
||||||
|
ThreadUtil.waitForDie();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void copyPropertiesHasBooleanTest() {
|
public void copyPropertiesHasBooleanTest() {
|
||||||
SubPerson p1 = new SubPerson();
|
SubPerson p1 = new SubPerson();
|
||||||
@ -652,7 +687,9 @@ public class BeanUtilTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public static class Student {
|
public static class Student implements Serializable{
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
String name;
|
String name;
|
||||||
int age;
|
int age;
|
||||||
Long no;
|
Long no;
|
||||||
|
@ -0,0 +1,76 @@
|
|||||||
|
package cn.hutool.core.bean;
|
||||||
|
|
||||||
|
import org.junit.Assert;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* https://github.com/dromara/hutool/issues/2009
|
||||||
|
*/
|
||||||
|
public class Issue2009Test {
|
||||||
|
|
||||||
|
@SuppressWarnings("InnerClassMayBeStatic")
|
||||||
|
public class BaseA {
|
||||||
|
private String paPss;
|
||||||
|
|
||||||
|
public String getPaPss() {
|
||||||
|
return paPss;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPaPss(String paPss) {
|
||||||
|
this.paPss = paPss;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public class A extends BaseA {
|
||||||
|
private String papss;
|
||||||
|
|
||||||
|
public String getPapss() {
|
||||||
|
return papss;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPapss(String papss) {
|
||||||
|
this.papss = papss;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "A{" +
|
||||||
|
"papss='" + papss + '\'' +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public class B extends BaseA {
|
||||||
|
private String papss;
|
||||||
|
|
||||||
|
public B(String papss) {
|
||||||
|
this.papss = papss;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPapss() {
|
||||||
|
return papss;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPapss(String papss) {
|
||||||
|
this.papss = papss;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "B{" +
|
||||||
|
"papss='" + papss + '\'' +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test() {
|
||||||
|
B b = new B("a string text");
|
||||||
|
A a = new A();
|
||||||
|
BeanUtil.copyProperties(b, a);
|
||||||
|
|
||||||
|
Assert.assertEquals(b.getPapss(), a.getPapss());
|
||||||
|
}
|
||||||
|
}
|
@ -67,9 +67,9 @@ public class ImgUtilTest {
|
|||||||
@Ignore
|
@Ignore
|
||||||
public void pressImgTest() {
|
public void pressImgTest() {
|
||||||
ImgUtil.pressImage(
|
ImgUtil.pressImage(
|
||||||
FileUtil.file("d:/test/617180969474805871.jpg"),
|
FileUtil.file("d:/test/1435859438434136064.jpg"),
|
||||||
FileUtil.file("d:/test/dest.png"),
|
FileUtil.file("d:/test/dest.jpg"),
|
||||||
ImgUtil.read(FileUtil.file("d:/test/vbbb.png")), 0, 0, 0.9f);
|
ImgUtil.read(FileUtil.file("d:/test/qrcodeCustom.png")), 0, 0, 0.9f);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
Loading…
x
Reference in New Issue
Block a user