mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
fix code
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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;
|
||||
}
|
||||
}
|
@@ -112,4 +112,6 @@ public class PropsTest {
|
||||
private Date theStageTime;//当前阶段开始日期
|
||||
private Date nextStageTime;//当前阶段结束日期/下一阶段开始日期
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
3
hutool-setting/src/test/resources/issue3008.properties
Normal file
3
hutool-setting/src/test/resources/issue3008.properties
Normal file
@@ -0,0 +1,3 @@
|
||||
person.hobby[0]=LOL
|
||||
person.hobby[1]=KFC
|
||||
person.hobby[2]=COFFE
|
Reference in New Issue
Block a user