mirror of
https://gitee.com/dromara/hutool.git
synced 2025-04-05 17:37:59 +08:00
fix bug
This commit is contained in:
parent
0f96a95f2c
commit
412160ac53
@ -31,6 +31,7 @@
|
||||
* 【db 】 修复Condition没占位符的情况下sql没引号问题(issue#1846@Github)
|
||||
* 【cache 】 修复FIFOCache中remove回调无效问题(pr#1856@Github)
|
||||
* 【json 】 修复JSONArray.set中,index为0报错问题(issue#1858@Github)
|
||||
* 【core 】 修复FileUtil.checkSlip中getCanonicalPath异常引起的问题(issue#1858@Github)
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
@ -3278,7 +3278,10 @@ public class FileUtil extends PathUtil {
|
||||
parentCanonicalPath = parentFile.getCanonicalPath();
|
||||
canonicalPath = file.getCanonicalPath();
|
||||
} catch (IOException e) {
|
||||
throw new IORuntimeException(e);
|
||||
// issue#I4CWMO@Gitee
|
||||
// getCanonicalPath有时会抛出奇怪的IO异常,此时忽略异常,使用AbsolutePath判断。
|
||||
parentCanonicalPath = parentFile.getAbsolutePath();
|
||||
canonicalPath = file.getAbsolutePath();
|
||||
}
|
||||
if (false == canonicalPath.startsWith(parentCanonicalPath)) {
|
||||
throw new IllegalArgumentException("New file is outside of the parent dir: " + file.getName());
|
||||
|
@ -712,6 +712,23 @@ public class CollUtilTest {
|
||||
Assert.assertEquals("d", map.get("keyd"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void mapToMapTest(){
|
||||
final HashMap<String, String> oldMap = new HashMap<>();
|
||||
oldMap.put("a", "1");
|
||||
oldMap.put("b", "12");
|
||||
oldMap.put("c", "134");
|
||||
|
||||
final Map<String, Long> map = CollUtil.toMap(oldMap.entrySet(),
|
||||
new HashMap<>(),
|
||||
Map.Entry::getKey,
|
||||
entry -> Long.parseLong(entry.getValue()));
|
||||
|
||||
Assert.assertEquals(1L, (long)map.get("a"));
|
||||
Assert.assertEquals(12L, (long)map.get("b"));
|
||||
Assert.assertEquals(134L, (long)map.get("c"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void countMapTest() {
|
||||
ArrayList<String> list = CollUtil.newArrayList("a", "b", "c", "c", "a", "b", "d");
|
||||
|
35
hutool-json/src/test/java/cn/hutool/json/issues1881Test.java
Normal file
35
hutool-json/src/test/java/cn/hutool/json/issues1881Test.java
Normal file
@ -0,0 +1,35 @@
|
||||
package cn.hutool.json;
|
||||
|
||||
import cn.hutool.core.lang.Console;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class issues1881Test {
|
||||
@Accessors(chain = true)
|
||||
@Data
|
||||
public class ThingsHolderContactVO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -8727337936070932370L;
|
||||
private Long id;
|
||||
private Integer type;
|
||||
private String memberId;
|
||||
private String name;
|
||||
private String phone;
|
||||
private String avatar;
|
||||
private Long createTime;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseTest(){
|
||||
List<ThingsHolderContactVO> holderContactVOList = new ArrayList<>();
|
||||
holderContactVOList.add(new ThingsHolderContactVO().setId(1L).setName("1"));
|
||||
holderContactVOList.add(new ThingsHolderContactVO().setId(2L).setName("2"));
|
||||
|
||||
Console.log(JSONUtil.parseArray(holderContactVOList));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user