mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-07 09:06:03 +00:00
[JENKINS-51608] - Improve diagnostics of errorneous cases in ClassicPluginStrategy#getShortName()
This commit is contained in:
1 parent
8872b44cc8
commit
9bd13323c8
1 file changed
+11
@@ -25,6 +25,8 @@ package hudson;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.InvalidPathException;
|
||||
@@ -110,11 +112,20 @@ public class ClassicPluginStrategy implements PluginStrategy {
|
||||
|
||||
@Override public String getShortName(File archive) throws IOException {
|
||||
Manifest manifest;
|
||||
if (!archive.exists()) {
|
||||
throw new FileNotFoundException("Failed to load " + archive + ". The file does not exist");
|
||||
} else if (!archive.isFile()) {
|
||||
throw new FileNotFoundException("Failed to load " + archive + ". It is not a file");
|
||||
}
|
||||
|
||||
if (isLinked(archive)) {
|
||||
manifest = loadLinkedManifest(archive);
|
||||
} else {
|
||||
try (JarFile jf = new JarFile(archive, false)) {
|
||||
manifest = jf.getManifest();
|
||||
} catch (IOException ex) {
|
||||
// Mention file name in the exception
|
||||
throw new IOException("Failed to load " + archive, ex);
|
||||
}
|
||||
}
|
||||
return PluginWrapper.computeShortName(manifest, archive.getName());
|
||||
|
||||
Reference in new issue
Block a user