Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
d58c230b
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看板
提交
d58c230b
编写于
14年前
作者:
S
sherman
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
6962067: TEST_BUG: Tests in java/util/zip/ZipFile leave file open
Summary: Close zipfile and io stream when done Reviewed-by: alanb
上级
a830a508
无相关合并请求
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
94 addition
and
85 deletion
+94
-85
test/ProblemList.txt
test/ProblemList.txt
+0
-12
test/java/util/zip/InfoZip.java
test/java/util/zip/InfoZip.java
+17
-11
test/java/util/zip/ZipFile/Comment.java
test/java/util/zip/ZipFile/Comment.java
+13
-8
test/java/util/zip/ZipFile/CorruptedZipFiles.java
test/java/util/zip/ZipFile/CorruptedZipFiles.java
+16
-12
test/java/util/zip/ZipFile/ManyEntries.java
test/java/util/zip/ZipFile/ManyEntries.java
+48
-42
未找到文件。
test/ProblemList.txt
浏览文件 @
d58c230b
...
...
@@ -1205,17 +1205,5 @@ java/util/Locale/LocaleTest.java generic-all
# Need to be marked othervm, or changed to be samevm safe
java/util/WeakHashMap/GCDuringIteration.java generic-all
# Possible missing input stream close()? Causes samevm issues on windows
java/util/zip/InfoZip.java generic-all
# Missing a close() on file Test0.zip? windows samevm cascade problem
java/util/zip/ZipFile/Comment.java generic-all
# Suspect missing close() on bad*.zip files, windows cascade errors with samevm
java/util/zip/ZipFile/CorruptedZipFiles.java generic-all
# Should be samevm but causes problems with samevm, no details:
java/util/zip/ZipFile/ManyEntries.java generic-all
############################################################################
This diff is collapsed.
Click to expand it.
test/java/util/zip/InfoZip.java
浏览文件 @
d58c230b
/*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005,
2010,
Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
...
...
@@ -103,19 +103,25 @@ public class InfoZip {
os
.
close
();
ZipFile
zf
=
new
ZipFile
(
f
);
Enumeration
<?
extends
ZipEntry
>
entries
=
zf
.
entries
();
ZipEntry
ze
=
entries
.
nextElement
();
check
(!
entries
.
hasMoreElements
());
checkZipEntry
(
ze
,
contents
(
zf
,
ze
));
zf
.
close
();
ZipEntry
ze
=
null
;
try
{
Enumeration
<?
extends
ZipEntry
>
entries
=
zf
.
entries
();
ze
=
entries
.
nextElement
();
check
(!
entries
.
hasMoreElements
());
checkZipEntry
(
ze
,
contents
(
zf
,
ze
));
}
finally
{
zf
.
close
();
}
ZipInputStream
is
=
new
ZipInputStream
(
new
FileInputStream
(
f
));
ze
=
is
.
getNextEntry
();
checkZipEntry
(
ze
,
contents
(
is
));
check
(
is
.
getNextEntry
()
==
null
);
try
{
ze
=
is
.
getNextEntry
();
checkZipEntry
(
ze
,
contents
(
is
));
check
(
is
.
getNextEntry
()
==
null
);
}
finally
{
is
.
close
();
}
f
.
delete
();
System
.
out
.
printf
(
"passed = %d, failed = %d%n"
,
passed
,
failed
);
if
(
failed
>
0
)
throw
new
Exception
(
"Some tests failed"
);
}
...
...
This diff is collapsed.
Click to expand it.
test/java/util/zip/ZipFile/Comment.java
浏览文件 @
d58c230b
/*
* Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003,
2010,
Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
...
...
@@ -58,13 +58,16 @@ public class Comment {
throws
IOException
{
ZipOutputStream
zos
=
new
ZipOutputStream
(
new
FileOutputStream
(
name
));
zos
.
setComment
(
comment
);
ZipEntry
ze
=
new
ZipEntry
(
entryName
);
ze
.
setMethod
(
ZipEntry
.
DEFLATED
);
zos
.
putNextEntry
(
ze
);
new
DataOutputStream
(
zos
).
writeUTF
(
entryContents
);
zos
.
closeEntry
();
zos
.
close
();
try
{
zos
.
setComment
(
comment
);
ZipEntry
ze
=
new
ZipEntry
(
entryName
);
ze
.
setMethod
(
ZipEntry
.
DEFLATED
);
zos
.
putNextEntry
(
ze
);
new
DataOutputStream
(
zos
).
writeUTF
(
entryContents
);
zos
.
closeEntry
();
}
finally
{
zos
.
close
();
}
}
private
static
void
verifyZipFile
(
String
name
,
String
comment
)
...
...
@@ -91,6 +94,8 @@ public class Comment {
file
.
seek
(
file
.
length
()
-
comment
.
length
());
byte
[]
bytes
=
new
byte
[
comment
.
length
()];
file
.
readFully
(
bytes
);
zipFile
.
close
();
file
.
close
();
if
(!
comment
.
equals
(
new
String
(
bytes
,
"UTF8"
)))
throw
new
Exception
(
"Zip file comment corrupted"
);
}
...
...
This diff is collapsed.
Click to expand it.
test/java/util/zip/ZipFile/CorruptedZipFiles.java
浏览文件 @
d58c230b
/*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005,
2010,
Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
...
...
@@ -47,13 +47,14 @@ public class CorruptedZipFiles {
}
public
static
void
main
(
String
[]
args
)
throws
Exception
{
ZipOutputStream
zos
=
new
ZipOutputStream
(
new
FileOutputStream
(
"x.zip"
));
ZipEntry
e
=
new
ZipEntry
(
"x"
);
zos
.
putNextEntry
(
e
);
zos
.
write
((
int
)
'x'
);
zos
.
close
();
zos
=
null
;
ZipOutputStream
zos
=
new
ZipOutputStream
(
new
FileOutputStream
(
"x.zip"
));
try
{
ZipEntry
e
=
new
ZipEntry
(
"x"
);
zos
.
putNextEntry
(
e
);
zos
.
write
((
int
)
'x'
);
}
finally
{
zos
.
close
();
}
int
len
=
(
int
)(
new
File
(
"x.zip"
).
length
());
byte
[]
good
=
new
byte
[
len
];
...
...
@@ -153,12 +154,15 @@ public class CorruptedZipFiles {
fos
.
write
(
data
);
fos
.
close
();
ZipFile
zf
=
new
ZipFile
(
zipName
);
if
(
getInputStream
)
{
InputStream
is
=
zf
.
getInputStream
(
new
ZipEntry
(
"x"
));
is
.
read
();
try
{
if
(
getInputStream
)
{
InputStream
is
=
zf
.
getInputStream
(
new
ZipEntry
(
"x"
));
is
.
read
();
}
}
finally
{
zf
.
close
();
}
fail
(
"Failed to throw expected ZipException"
);
zf
.
close
();
}
catch
(
ZipException
e
)
{
if
(
e
.
getMessage
().
matches
(
msgPattern
))
passed
++;
...
...
This diff is collapsed.
Click to expand it.
test/java/util/zip/ZipFile/ManyEntries.java
浏览文件 @
d58c230b
/*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005,
2010,
Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
...
...
@@ -55,52 +55,58 @@ public class ManyEntries {
File
zipFile
=
new
File
(++
uniquifier
+
".zip"
);
try
{
zipFile
.
delete
();
ZipOutputStream
zos
=
new
ZipOutputStream
(
new
BufferedOutputStream
(
new
FileOutputStream
(
zipFile
)));
for
(
int
i
=
0
;
i
<
N
;
i
++)
{
ZipEntry
e
=
new
ZipEntry
(
"DIR/"
+
i
);
e
.
setMethod
(
method
);
e
.
setTime
(
time
);
if
(
method
==
ZipEntry
.
STORED
)
{
e
.
setSize
(
1
);
crc32
.
reset
();
crc32
.
update
((
byte
)
i
);
e
.
setCrc
(
crc32
.
getValue
());
}
else
{
e
.
setSize
(
0
);
e
.
setCrc
(
0
);
ZipOutputStream
zos
=
new
ZipOutputStream
(
new
BufferedOutputStream
(
new
FileOutputStream
(
zipFile
)));
try
{
for
(
int
i
=
0
;
i
<
N
;
i
++)
{
ZipEntry
e
=
new
ZipEntry
(
"DIR/"
+
i
);
e
.
setMethod
(
method
);
e
.
setTime
(
time
);
if
(
method
==
ZipEntry
.
STORED
)
{
e
.
setSize
(
1
);
crc32
.
reset
();
crc32
.
update
((
byte
)
i
);
e
.
setCrc
(
crc32
.
getValue
());
}
else
{
e
.
setSize
(
0
);
e
.
setCrc
(
0
);
}
zos
.
putNextEntry
(
e
);
zos
.
write
(
i
);
}
zos
.
putNextEntry
(
e
);
zos
.
write
(
i
);
}
finally
{
zos
.
close
();
zos
=
null
;
}
zos
.
close
();
zos
=
null
;
ZipFile
zip
=
new
ZipFile
(
zipFile
);
if
(!
(
zip
.
size
()
==
N
))
throw
new
Exception
(
"Bad ZipFile size: "
+
zip
.
size
());
Enumeration
entries
=
zip
.
entries
();
ZipFile
zip
=
zip
=
new
ZipFile
(
zipFile
);
try
{
if
(!
(
zip
.
size
()
==
N
))
throw
new
Exception
(
"Bad ZipFile size: "
+
zip
.
size
());
Enumeration
entries
=
zip
.
entries
();
for
(
int
i
=
0
;
i
<
N
;
i
++)
{
if
(
i
%
1000
==
0
)
{
System
.
gc
();
System
.
runFinalization
();}
if
(!
(
entries
.
hasMoreElements
()))
throw
new
Exception
(
"only "
+
i
+
" elements"
);
ZipEntry
e
=
(
ZipEntry
)
entries
.
nextElement
();
if
(!
(
e
.
getSize
()
==
1
))
throw
new
Exception
(
"bad size: "
+
e
.
getSize
());
if
(!
(
e
.
getName
().
equals
(
"DIR/"
+
i
)))
throw
new
Exception
(
"bad name: "
+
i
);
if
(!
(
e
.
getMethod
()
==
method
))
throw
new
Exception
(
"getMethod="
+
e
.
getMethod
()+
", method="
+
method
);
if
(!
(
e
.
getTime
()
==
time
))
throw
new
Exception
(
"getTime="
+
e
.
getTime
()+
", time="
+
time
);
if
(!
(
zip
.
getInputStream
(
e
).
read
()
==
(
i
&
0xff
)))
throw
new
Exception
(
"Bad file contents: "
+
i
);
for
(
int
i
=
0
;
i
<
N
;
i
++)
{
if
(
i
%
1000
==
0
)
{
System
.
gc
();
System
.
runFinalization
();}
if
(!
(
entries
.
hasMoreElements
()))
throw
new
Exception
(
"only "
+
i
+
" elements"
);
ZipEntry
e
=
(
ZipEntry
)
entries
.
nextElement
();
if
(!
(
e
.
getSize
()
==
1
))
throw
new
Exception
(
"bad size: "
+
e
.
getSize
());
if
(!
(
e
.
getName
().
equals
(
"DIR/"
+
i
)))
throw
new
Exception
(
"bad name: "
+
i
);
if
(!
(
e
.
getMethod
()
==
method
))
throw
new
Exception
(
"getMethod="
+
e
.
getMethod
()+
", method="
+
method
);
if
(!
(
e
.
getTime
()
==
time
))
throw
new
Exception
(
"getTime="
+
e
.
getTime
()+
", time="
+
time
);
if
(!
(
zip
.
getInputStream
(
e
).
read
()
==
(
i
&
0xff
)))
throw
new
Exception
(
"Bad file contents: "
+
i
);
}
if
(
entries
.
hasMoreElements
())
throw
new
Exception
(
"too many elements"
);
}
finally
{
zip
.
close
();
}
if
(
entries
.
hasMoreElements
())
throw
new
Exception
(
"too many elements"
);
}
finally
{
zipFile
.
delete
();
...
...
This diff is collapsed.
Click to expand it.
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录
反馈
建议
客服
返回
顶部