Skip to content

Commit

Permalink
Merge pull request #3464 from oleg-nenashev/bug/JENKINS-51608
Browse files Browse the repository at this point in the history
[JENKINS-51608] - Improve diagnostics of errorneous cases in ClassicPluginStrategy#getShortName()
  • Loading branch information
oleg-nenashev committed Jun 8, 2018
2 parents 8c1b8b8 + 9bd1332 commit ec10b8c
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions core/src/main/java/hudson/ClassicPluginStrategy.java
Expand Up @@ -25,6 +25,8 @@

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;
Expand Down Expand Up @@ -110,11 +112,20 @@ public ClassicPluginStrategy(PluginManager pluginManager) {

@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());
Expand Down

0 comments on commit ec10b8c

Please sign in to comment.