[JENKINS-43531] Plugins may not be expecting InvalidPathException

- Plugins should really be expecting it, but as historically they have not, may as well convert to IOE for them
This commit is contained in:
Stephen Connolly committed 2017-04-19 14:04:33 +01:00
1 parent 33942677d4
commit 3871d7778e
31 files changed
+209 -46

No files matched your search

@@ -25,6 +25,7 @@ package hudson;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.InvalidPathException;
import jenkins.util.SystemProperties;
import com.google.common.collect.Lists;
import hudson.Plugin.DummyImpl;
@@ -127,6 +128,8 @@ public class ClassicPluginStrategy implements PluginStrategy {
String firstLine;
try (InputStream manifestHeaderInput = Files.newInputStream(archive.toPath())) {
firstLine = IOUtils.readFirstLine(manifestHeaderInput, "UTF-8");
} catch (InvalidPathException e) {
throw new IOException(e);
}
if (firstLine.startsWith("Manifest-Version:")) {
// this is the manifest already
@@ -138,6 +141,8 @@ public class ClassicPluginStrategy implements PluginStrategy {
// Read the manifest
try (InputStream manifestInput = Files.newInputStream(archive.toPath())) {
return new Manifest(manifestInput);
} catch (InvalidPathException e) {
throw new IOException(e);
}
} catch (IOException e) {
throw new IOException("Failed to load " + archive, e);
@@ -171,6 +176,8 @@ public class ClassicPluginStrategy implements PluginStrategy {
}
try (InputStream fin = Files.newInputStream(manifestFile.toPath())) {
manifest = new Manifest(fin);
} catch (InvalidPathException e) {
throw new IOException(e);
}
}