mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-07 09:06:03 +00:00
[JENKINS-42934] Avoid using new FileInputStream / new FileOutputStream
This commit is contained in:
1 parent
4948d6c556
commit
f0cd7ae8ff
41 files changed
+188
-159
No files matched your search
@@ -23,6 +23,8 @@
|
||||
*/
|
||||
package hudson;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.nio.file.Files;
|
||||
import jenkins.util.SystemProperties;
|
||||
import com.google.common.collect.Lists;
|
||||
import hudson.Plugin.DummyImpl;
|
||||
@@ -123,11 +125,8 @@ public class ClassicPluginStrategy implements PluginStrategy {
|
||||
try {
|
||||
// Locate the manifest
|
||||
String firstLine;
|
||||
FileInputStream manifestHeaderInput = new FileInputStream(archive);
|
||||
try {
|
||||
try (InputStream manifestHeaderInput = Files.newInputStream(archive.toPath())) {
|
||||
firstLine = IOUtils.readFirstLine(manifestHeaderInput, "UTF-8");
|
||||
} finally {
|
||||
manifestHeaderInput.close();
|
||||
}
|
||||
if (firstLine.startsWith("Manifest-Version:")) {
|
||||
// this is the manifest already
|
||||
@@ -137,11 +136,8 @@ public class ClassicPluginStrategy implements PluginStrategy {
|
||||
}
|
||||
|
||||
// Read the manifest
|
||||
FileInputStream manifestInput = new FileInputStream(archive);
|
||||
try {
|
||||
try (InputStream manifestInput = Files.newInputStream(archive.toPath())) {
|
||||
return new Manifest(manifestInput);
|
||||
} finally {
|
||||
manifestInput.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new IOException("Failed to load " + archive, e);
|
||||
@@ -173,7 +169,7 @@ public class ClassicPluginStrategy implements PluginStrategy {
|
||||
"Plugin installation failed. No manifest at "
|
||||
+ manifestFile);
|
||||
}
|
||||
try (FileInputStream fin = new FileInputStream(manifestFile)) {
|
||||
try (InputStream fin = Files.newInputStream(manifestFile.toPath())) {
|
||||
manifest = new Manifest(fin);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user