提交 4ac0604c 编写于 作者: A andrew

8003120: ResourceManager.getApplicationResources() does not close InputStreams

Summary: Add finally blocks to close the InputStream instances
Reviewed-by: lancea
上级 f6e03a56
...@@ -542,14 +542,26 @@ public final class ResourceManager { ...@@ -542,14 +542,26 @@ public final class ResourceManager {
try { try {
NamingEnumeration<InputStream> resources = NamingEnumeration<InputStream> resources =
helper.getResources(cl, APP_RESOURCE_FILE_NAME); helper.getResources(cl, APP_RESOURCE_FILE_NAME);
while (resources.hasMore()) { try {
Properties props = new Properties(); while (resources.hasMore()) {
props.load(resources.next()); Properties props = new Properties();
InputStream istream = resources.next();
if (result == null) { try {
result = props; props.load(istream);
} else { } finally {
mergeTables(result, props); istream.close();
}
if (result == null) {
result = props;
} else {
mergeTables(result, props);
}
}
} finally {
while (resources.hasMore()) {
InputStream istream = (InputStream)resources.next();
istream.close();
} }
} }
...@@ -557,13 +569,17 @@ public final class ResourceManager { ...@@ -557,13 +569,17 @@ public final class ResourceManager {
InputStream istream = InputStream istream =
helper.getJavaHomeLibStream(JRELIB_PROPERTY_FILE_NAME); helper.getJavaHomeLibStream(JRELIB_PROPERTY_FILE_NAME);
if (istream != null) { if (istream != null) {
Properties props = new Properties(); try {
props.load(istream); Properties props = new Properties();
props.load(istream);
if (result == null) {
result = props; if (result == null) {
} else { result = props;
mergeTables(result, props); } else {
mergeTables(result, props);
}
} finally {
istream.close();
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册