mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-04-19 03:01:48 +08:00
!1331 修复删除Path时如果为null时空指针bug
Merge pull request !1331 from IzayoiYurin/v5-dev
This commit is contained in:
commit
56afebae55
@ -165,7 +165,7 @@ public class PathUtil {
|
||||
* @since 4.4.2
|
||||
*/
|
||||
public static boolean del(Path path) throws IORuntimeException {
|
||||
if (Files.notExists(path)) {
|
||||
if (null == path || Files.notExists(path)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,7 @@ import static org.junit.jupiter.api.Assertions.*;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
|
||||
@ -93,4 +94,11 @@ public class PathUtilTest {
|
||||
public void moveTest2(){
|
||||
PathUtil.move(Paths.get("D:\\project\\test1.txt"), Paths.get("D:\\project\\test2.txt"), false);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled
|
||||
public void delNullDirTest() {
|
||||
Path path = null;
|
||||
assertTrue(PathUtil.del(path));
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user