提交 5259996c 编写于 作者: O Oleg Nenashev

[CID-1219446] - Resource leak in ClassicPluginStrategy

Resource leak may happen during the search of manifest file.
Signed-off-by: NOleg Nenashev <o.v.nenashev@gmail.com>
上级 2ea0276e
...@@ -116,22 +116,32 @@ public class ClassicPluginStrategy implements PluginStrategy { ...@@ -116,22 +116,32 @@ public class ClassicPluginStrategy implements PluginStrategy {
} }
private static Manifest loadLinkedManifest(File archive) throws IOException { private static Manifest loadLinkedManifest(File archive) throws IOException {
// resolve the .hpl file to the location of the manifest file // resolve the .hpl file to the location of the manifest file
final String firstLine = IOUtils.readFirstLine(new FileInputStream(archive), "UTF-8");
if (firstLine.startsWith("Manifest-Version:")) {
// this is the manifest already
} else {
// indirection
archive = resolve(archive, firstLine);
}
// then parse manifest
FileInputStream in = new FileInputStream(archive);
try { try {
return new Manifest(in); // Locate the manifest
String firstLine;
FileInputStream manifestHeaderInput = new FileInputStream(archive);
try {
firstLine = IOUtils.readFirstLine(manifestHeaderInput, "UTF-8");
} finally {
manifestHeaderInput.close();
}
if (firstLine.startsWith("Manifest-Version:")) {
// this is the manifest already
} else {
// indirection
archive = resolve(archive, firstLine);
}
// Read the manifest
FileInputStream manifestInput = new FileInputStream(archive);
try {
return new Manifest(manifestInput);
} finally {
manifestInput.close();
}
} catch (IOException e) { } catch (IOException e) {
throw new IOException("Failed to load " + archive, e); throw new IOException("Failed to load " + archive, e);
} finally {
in.close();
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册