Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
f01ebf86
D
dragonwell8_jdk
项目概览
openanolis
/
dragonwell8_jdk
通知
4
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_jdk
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
f01ebf86
编写于
8月 11, 2009
作者:
A
alanb
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
6865748: (file) SimpleFileVisitor methods ignore null arguments
Reviewed-by: sherman
上级
695b4e15
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
42 addition
and
1 deletion
+42
-1
src/share/classes/java/nio/file/SimpleFileVisitor.java
src/share/classes/java/nio/file/SimpleFileVisitor.java
+16
-0
test/java/nio/file/Files/Misc.java
test/java/nio/file/Files/Misc.java
+26
-1
未找到文件。
src/share/classes/java/nio/file/SimpleFileVisitor.java
浏览文件 @
f01ebf86
...
...
@@ -47,6 +47,14 @@ public class SimpleFileVisitor<T> implements FileVisitor<T> {
protected
SimpleFileVisitor
()
{
}
/**
* Throws NullPointerException if obj is null.
*/
private
static
void
checkNotNull
(
Object
obj
)
{
if
(
obj
==
null
)
throw
new
NullPointerException
();
}
/**
* Invoked for a directory before entries in the directory are visited.
*
...
...
@@ -55,6 +63,7 @@ public class SimpleFileVisitor<T> implements FileVisitor<T> {
*/
@Override
public
FileVisitResult
preVisitDirectory
(
T
dir
)
{
checkNotNull
(
dir
);
return
FileVisitResult
.
CONTINUE
;
}
...
...
@@ -70,6 +79,8 @@ public class SimpleFileVisitor<T> implements FileVisitor<T> {
*/
@Override
public
FileVisitResult
preVisitDirectoryFailed
(
T
dir
,
IOException
exc
)
{
checkNotNull
(
dir
);
checkNotNull
(
exc
);
throw
new
IOError
(
exc
);
}
...
...
@@ -81,6 +92,8 @@ public class SimpleFileVisitor<T> implements FileVisitor<T> {
*/
@Override
public
FileVisitResult
visitFile
(
T
file
,
BasicFileAttributes
attrs
)
{
checkNotNull
(
file
);
checkNotNull
(
attrs
);
return
FileVisitResult
.
CONTINUE
;
}
...
...
@@ -96,6 +109,8 @@ public class SimpleFileVisitor<T> implements FileVisitor<T> {
*/
@Override
public
FileVisitResult
visitFileFailed
(
T
file
,
IOException
exc
)
{
checkNotNull
(
file
);
checkNotNull
(
exc
);
throw
new
IOError
(
exc
);
}
...
...
@@ -114,6 +129,7 @@ public class SimpleFileVisitor<T> implements FileVisitor<T> {
*/
@Override
public
FileVisitResult
postVisitDirectory
(
T
dir
,
IOException
exc
)
{
checkNotNull
(
dir
);
if
(
exc
!=
null
)
throw
new
IOError
(
exc
);
return
FileVisitResult
.
CONTINUE
;
...
...
test/java/nio/file/Files/Misc.java
浏览文件 @
f01ebf86
...
...
@@ -22,13 +22,14 @@
*/
/* @test
* @bug 4313887 6838333
* @bug 4313887 6838333
6865748
* @summary Unit test for java.nio.file.Files for miscellenous cases not
* covered by other tests
* @library ..
*/
import
java.nio.file.*
;
import
java.nio.file.attribute.Attributes
;
import
java.io.IOException
;
import
java.util.*
;
...
...
@@ -113,5 +114,29 @@ public class Misc {
npeExpected
();
}
catch
(
NullPointerException
e
)
{
}
SimpleFileVisitor
<
Path
>
visitor
=
new
SimpleFileVisitor
<
Path
>()
{
};
boolean
ranTheGauntlet
=
false
;
try
{
visitor
.
preVisitDirectory
(
null
);
}
catch
(
NullPointerException
x0
)
{
try
{
visitor
.
preVisitDirectoryFailed
(
null
,
new
IOException
());
}
catch
(
NullPointerException
x1
)
{
try
{
visitor
.
preVisitDirectoryFailed
(
dir
,
null
);
}
catch
(
NullPointerException
x2
)
{
try
{
visitor
.
visitFile
(
null
,
Attributes
.
readBasicFileAttributes
(
Paths
.
get
(
"."
)));
}
catch
(
NullPointerException
x3
)
{
try
{
visitor
.
visitFile
(
dir
,
null
);
}
catch
(
NullPointerException
x4
)
{
try
{
visitor
.
visitFileFailed
(
null
,
new
IOException
());
}
catch
(
NullPointerException
x5
)
{
try
{
visitor
.
visitFileFailed
(
dir
,
null
);
}
catch
(
NullPointerException
x6
)
{
try
{
visitor
.
postVisitDirectory
(
null
,
new
IOException
());
}
catch
(
NullPointerException
x7
)
{
// if we get here then all visit* methods threw NPE as expected
ranTheGauntlet
=
true
;
}}}}}}}}
if
(!
ranTheGauntlet
)
throw
new
RuntimeException
(
"A visit method did not throw NPE"
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录