diff --git a/core/src/main/java/hudson/PluginWrapper.java b/core/src/main/java/hudson/PluginWrapper.java index ee027da13fca495acc85c06b6bc882383744d8d0..3cf835fe242c29b0dad76db04996bb5d9df39be6 100644 --- a/core/src/main/java/hudson/PluginWrapper.java +++ b/core/src/main/java/hudson/PluginWrapper.java @@ -147,12 +147,17 @@ public final class PluginWrapper { if(isLinked) { // resolve the .hpl file to the location of the manifest file - String firstLine = new BufferedReader(new FileReader(archive)).readLine(); - if(firstLine.startsWith("Manifest-Version:")) { - // this is the manifest already - } else { - // indirection - archive = resolve(archive, firstLine); + BufferedReader archiveReader = new BufferedReader(new FileReader(archive)); + try { + String firstLine = archiveReader.readLine(); + if(firstLine.startsWith("Manifest-Version:")) { + // this is the manifest already + } else { + // indirection + archive = resolve(archive, firstLine); + } + } finally { + archiveReader.close(); } // then parse manifest FileInputStream in = new FileInputStream(archive);