Throw IOException from JarScanner constructor
The constructor of JarScanner is throwing an InvalidPluginException when an IOException occurs while loading a JAR file. This exception is too specific here and it should be the responsibility of the caller to decide whether a given JAR file is a plugin or not. Therefore this constructor should throw a generic IOException instead. Change-Id: I60099f9cec0837e6bf9a72af0d085f9731495c14 Signed-off-by: Dariusz Luksza <dariusz@luksza.org>
This commit is contained in:
@@ -142,9 +142,10 @@ public class JarPluginProvider implements ServerPluginProvider {
|
||||
new URLClassLoader(urls.toArray(new URL[urls.size()]),
|
||||
PluginLoader.parentFor(type));
|
||||
|
||||
JarScanner jarScanner = createJarScanner(srcJar);
|
||||
ServerPlugin plugin =
|
||||
new ServerPlugin(name, description.canonicalUrl, description.user,
|
||||
srcJar, snapshot, new JarScanner(srcJar), description.dataDir,
|
||||
srcJar, snapshot, jarScanner, description.dataDir,
|
||||
pluginLoader);
|
||||
plugin.setCleanupHandle(new CleanupHandle(tmp, jarFile));
|
||||
keep = true;
|
||||
@@ -155,4 +156,13 @@ public class JarPluginProvider implements ServerPluginProvider {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private JarScanner createJarScanner(File srcJar)
|
||||
throws InvalidPluginException {
|
||||
try {
|
||||
return new JarScanner(srcJar);
|
||||
} catch (IOException e) {
|
||||
throw new InvalidPluginException("Cannot scan plugin file " + srcJar, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,12 +67,8 @@ public class JarScanner implements PluginContentScanner {
|
||||
|
||||
private final JarFile jarFile;
|
||||
|
||||
public JarScanner(File srcFile) throws InvalidPluginException {
|
||||
try {
|
||||
this.jarFile = new JarFile(srcFile);
|
||||
} catch (IOException e) {
|
||||
throw new InvalidPluginException("Cannot scan plugin file " + srcFile, e);
|
||||
}
|
||||
public JarScanner(File srcFile) throws IOException {
|
||||
this.jarFile = new JarFile(srcFile);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user