mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
fix bug
This commit is contained in:
@@ -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");
|
||||
|
Reference in New Issue
Block a user