This commit is contained in:
Looly
2023-03-26 08:53:56 +08:00
parent 1d4d4e0e76
commit f970dc7632
25 changed files with 308 additions and 98 deletions

View File

@@ -348,7 +348,7 @@ public final class Props extends Properties implements TypeGetter<CharSequence>
BeanUtil.setProperty(bean, StrUtil.subSuf(key, prefix.length()), entry.getValue());
} catch (final Exception e) {
// 忽略注入失败的字段(这些字段可能用于其它配置)
StaticLog.debug("Ignore property: [{}]", key);
StaticLog.debug("Ignore property: [{}],because of: {}", key, e);
}
}

View File

@@ -0,0 +1,26 @@
package cn.hutool.setting;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.setting.dialect.Props;
import cn.hutool.setting.dialect.PropsUtil;
import lombok.Data;
import org.junit.Assert;
import org.junit.Test;
public class Issue3008Test {
/**
* 数组字段追加后生成新的数组,造成赋值丢失<br>
* 修复见BeanUtil.setFieldValue
*/
@Test
public void toBeanTest() {
final Props props = PropsUtil.get("issue3008");
final MyUser user = props.toBean(MyUser.class, "person");
Assert.assertEquals("[LOL, KFC, COFFE]", ArrayUtil.toString(user.getHobby()));
}
@Data
static class MyUser {
private String[] hobby;
}
}

View File

@@ -112,4 +112,6 @@ public class PropsTest {
private Date theStageTime;//当前阶段开始日期
private Date nextStageTime;//当前阶段结束日期/下一阶段开始日期
}
}

View File

@@ -0,0 +1,3 @@
person.hobby[0]=LOL
person.hobby[1]=KFC
person.hobby[2]=COFFE