mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-05 16:15:54 +00:00
[CID-1219446] - Resource leak in ClassicPluginStrategy
Resource leak may happen during the search of manifest file. Signed-off-by: Oleg Nenashev <o.v.nenashev@gmail.com>
This commit is contained in:
1 parent
2ea0276e7b
commit
5259996c44
1 file changed
+23
-13
@@ -116,22 +116,32 @@ public class ClassicPluginStrategy implements PluginStrategy {
|
||||
}
|
||||
|
||||
private static Manifest loadLinkedManifest(File archive) throws IOException {
|
||||
// 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);
|
||||
// resolve the .hpl file to the location of the manifest file
|
||||
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) {
|
||||
throw new IOException("Failed to load " + archive, e);
|
||||
} finally {
|
||||
in.close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user