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>
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/plugins/JarPluginProvider.java b/gerrit-server/src/main/java/com/google/gerrit/server/plugins/JarPluginProvider.java
index 7c35014..53f39f1 100644
--- a/gerrit-server/src/main/java/com/google/gerrit/server/plugins/JarPluginProvider.java
+++ b/gerrit-server/src/main/java/com/google/gerrit/server/plugins/JarPluginProvider.java
@@ -142,9 +142,10 @@
           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 @@
       }
     }
   }
+
+  private JarScanner createJarScanner(File srcJar)
+      throws InvalidPluginException {
+    try {
+      return new JarScanner(srcJar);
+    } catch (IOException e) {
+      throw new InvalidPluginException("Cannot scan plugin file " + srcJar, e);
+    }
+  }
 }
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/plugins/JarScanner.java b/gerrit-server/src/main/java/com/google/gerrit/server/plugins/JarScanner.java
index d7d0efd..4fcc102 100644
--- a/gerrit-server/src/main/java/com/google/gerrit/server/plugins/JarScanner.java
+++ b/gerrit-server/src/main/java/com/google/gerrit/server/plugins/JarScanner.java
@@ -67,12 +67,8 @@
 
   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